diff --git a/conda_recipe/meta.yaml b/conda_recipe/meta.yaml index 77064c52a..caf994d59 100644 --- a/conda_recipe/meta.yaml +++ b/conda_recipe/meta.yaml @@ -26,7 +26,7 @@ requirements: - numpy - scipy - matplotlib - - cython >=0.26 + - Cython >=0.26 - nose - pygments @@ -39,7 +39,7 @@ requirements: - numpy - scipy - matplotlib - - cython >=0.26 + - Cython >=0.26 - nose - pygments diff --git a/doc/source/installation.rst b/doc/source/installation.rst index a529ef79c..a81cfd51c 100644 --- a/doc/source/installation.rst +++ b/doc/source/installation.rst @@ -143,6 +143,6 @@ To install tofu as a developer, we recommend using the conda ecosystem (Minicond (long) `__ or `this short one `__ - Run ``pip install -e .[dev]``. This will install dependencies, compile the - tofu Cython extensions and install it into your conda environment while you can still + tofu cython extensions and install it into your conda environment while you can still modify the source files in the current repository.` - Make sure tofu tests are running by typing ``nosetests`` diff --git a/doc/source/release_notes/release_notes_141.rst b/doc/source/release_notes/release_notes_141.rst index 3ad9c8380..bebf56516 100644 --- a/doc/source/release_notes/release_notes_141.rst +++ b/doc/source/release_notes/release_notes_141.rst @@ -225,7 +225,7 @@ Code structure and format Restructuring of the geometry modules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Created Cython include files ``*.pxd`` and ``*.pyx`` for the following +Created cython include files ``*.pxd`` and ``*.pyx`` for the following group of functions: - ``_basic_geom_tools.*``: global variables definition (``_VSMALL`` and ``_SMALL``), and basic geometric tools (vector calculus, path distance point-point, point-vector,...) - @@ -244,7 +244,7 @@ Installation and portability impossible - git dependency is now optional (issue #67 ) - changes in ``setup.py`` for **Windows** portability -- Now only supporting ``Cython`` versions ``>=0.26`` +- Now only supporting ``cython`` versions ``>=0.26`` - Removed all **pandas** dependencies - Using ``-O3`` flag instead of ``-O0`` for faster execution time even if compilation is slower diff --git a/requirements.txt b/requirements.txt index 08858cb0c..0632b2965 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,4 @@ scipy matplotlib ######## Requirements with Version Specifier ######## -cython>=0.26 +Cython>=0.26 diff --git a/setup.py b/setup.py index b47fc41c1..e260e1edb 100644 --- a/setup.py +++ b/setup.py @@ -11,19 +11,31 @@ import platform import subprocess from codecs import open -import Cython as cth -from Cython.Distutils import build_ext -from Cython.Build import cythonize -import numpy as np +try: + import numpy as np + import Cython as cth + from Cython.Distutils import build_ext + from Cython.Build import cythonize + from Cython.Build import build_ext as cthBext + # Why do we need two different build_ext command ? + + def npgetinclude(): return np.get_include() + print("cython version =", cth.__version__) + print("numpy version =", np.__version__) + print("cython file =", cth.__file__) + print("numpy file =", np.__file__) +except ImportError: + def npgetinclude(): + import numpy as np + return np.get_include() + def cythonize(*args, **kwargs): + from Cython.Build import cythonize + return cythonize(*args, **kwargs) + def cthBext(*args, **kwargs): + from Cython.Build import build_ext as cthBext + return cthBext(*args, **kwargs) import _updateversion as up -from distutils.command.clean import clean as Clean - - -print("cython version =", cth.__version__) -print("numpy version =", np.__version__) -print("cython version =", cth.__file__) -print("numpy version =", np.__file__) logging.basicConfig(level=logging.INFO) logger = logging.getLogger("tofu.setup") @@ -36,6 +48,9 @@ from distutils.core import setup from distutils.extension import Extension +# Is there a clean command from setuptools instead of distutils ? +from distutils.command.clean import clean as Clean + is_platform_windows = False if platform.system() == "Windows": is_platform_windows = True @@ -282,7 +297,7 @@ def get_version_tofu(path=_HERE): # The version is stored only in the setup.py file and read from it (option # 1 in https://packaging.python.org/en/latest/single_source_version.html) use_scm_version=False, - # setup_requires=['setuptools_scm'], + setup_requires=['numpy', 'cython>=0.26'], description="A python library for Tomography for Fusion", long_description=long_description, long_description_content_type=long_description_content_type, @@ -384,7 +399,7 @@ def get_version_tofu(path=_HERE): # ], # }, ext_modules=extensions, - cmdclass={"build_ext": cth.Build.build_ext, + cmdclass={"build_ext": cthBext, "clean": CleanCommand}, - include_dirs=[np.get_include()], + include_dirs=[npgetinclude()], ) diff --git a/tofu/geom/_GG.pyx b/tofu/geom/_GG.pyx index 4ffa3a155..7143e078f 100644 --- a/tofu/geom/_GG.pyx +++ b/tofu/geom/_GG.pyx @@ -10,7 +10,7 @@ import numpy as np import scipy.integrate as scpintg from matplotlib.path import Path -# -- Cython libraries imports -------------------------------------------------- +# -- cython libraries imports -------------------------------------------------- from cpython cimport bool from cpython.array cimport array, clone from cython.parallel import prange @@ -3679,7 +3679,7 @@ def comp_dist_los_circle(np.ndarray[double,ndim=1,mode='c'] ray_vdir, to the circle --- This is the PYTHON function, use only if you need this computation from - Python, if you need it from Cython, use `dist_los_circle_core` + Python, if you need it from cython, use `dist_los_circle_core` """ cdef double[2] res _dt.dist_los_circle_core(ray_vdir.data, @@ -3714,7 +3714,7 @@ def comp_dist_los_circle_vec(int nlos, int ncircles, with the distance between each LOS to each circle --- This is the PYTHON function, use only if you need this computation from - Python, if you need it from Cython, use `dist_los_circle_core` + Python, if you need it from cython, use `dist_los_circle_core` """ cdef array kmin_tab = clone(array('d'), nlos*ncircles, True) cdef array dist_tab = clone(array('d'), nlos*ncircles, True) @@ -3748,7 +3748,7 @@ def is_close_los_circle(np.ndarray[double,ndim=1,mode='c'] ray_vdir, The result is True when distance < epsilon --- This is the PYTHON function, use only if you need this computation from - Python, if you need it from Cython, use `is_los_close_circle_core` + Python, if you need it from cython, use `is_los_close_circle_core` """ return _dt.is_close_los_circle_core(ray_vdir.data, ray_orig.data, @@ -3767,7 +3767,7 @@ def is_close_los_circle_vec(int nlos, int ncircles, double epsilon, The result is True when distance < epsilon --- This is the PYTHON function, use only if you need this computation from - Python, if you need it from Cython, use `is_los_close_circle_core` + Python, if you need it from cython, use `is_los_close_circle_core` """ cdef array res = clone(array('i'), nlos, True) @@ -3824,7 +3824,7 @@ def comp_dist_los_vpoly(double[:, ::1] ray_orig, `distance[i]` is the distance from P_i to the extruded polygon. --- This is the PYTHON function, use only if you need this computation from - Python, if you need it from Cython, use `simple_dist_los_vpoly_core` + Python, if you need it from cython, use `simple_dist_los_vpoly_core` """ cdef int npts_poly = ves_poly.shape[1] cdef int nlos = ray_orig.shape[1] @@ -3929,7 +3929,7 @@ def comp_dist_los_vpoly_vec(int nvpoly, int nlos, extruded poly. --- This is the PYTHON function, use only if you need this computation from - Python, if you need it from Cython, use `comp_dist_los_vpoly_vec_core` + Python, if you need it from cython, use `comp_dist_los_vpoly_vec_core` """ if not algo_type.lower() == "simple" or not ves_type.lower() == "tor": assert False, "The function is only implemented with the simple"\ @@ -4003,7 +4003,7 @@ def is_close_los_vpoly_vec(int nvpoly, int nlos, and j-th poly are closer than epsilon. (True if distance