diff --git a/.travis.yml b/.travis.yml index 460d5e775..d5bd833db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,7 +59,7 @@ deploy: skip_cleanup: true - provider: pypi user: "Didou09" - distributions: "sdist" + distributions: "sdist bdist_wheel" skip_cleanup: true on: tags: true diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..914ec2419 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools>=40.8.0", "wheel", "cython>0.26", "numpy"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/setup.py b/setup.py index e260e1edb..8dd25cc59 100644 --- a/setup.py +++ b/setup.py @@ -4,59 +4,36 @@ https://github.com/ToFuProject/tofu """ import os -import sys import glob import shutil import logging import platform import subprocess from codecs import open -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) +# ... setup tools +from setuptools import setup, find_packages +from setuptools import Extension +# ... packages that need to be in pyproject.toml +import Cython as cth +from Cython.Distutils import build_ext +import numpy as np +# ... import _updateversion as up +# ... for `clean` command +from distutils.command.clean import clean as Clean -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger("tofu.setup") - -# Always prefer setuptools over distutils -try: - from setuptools import setup, find_packages - from setuptools import Extension -except ImportError: - 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 +# == Checking platform ========================================================= is_platform_windows = False if platform.system() == "Windows": is_platform_windows = True -# ============================================================================== +# === Setting clean command ==================================================== +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger("tofu.setup") + class CleanCommand(Clean): description = "Remove build artifacts from the source tree" @@ -120,8 +97,6 @@ def run(self): logger.info("removing '%s'", path) except OSError: pass - - # ============================================================================== @@ -159,23 +134,16 @@ def check_for_openmp(cc_var): shutil.rmtree(tmpdir) return result - # ....... Using function -print("................ checking if openmp installed...") if is_platform_windows: openmp_installed = False else: openmp_installed = not check_for_openmp("cc") -print("................ checking if openmp installed... > ", openmp_installed) - - - # ============================================================================== +# == Getting tofu version ====================================================== _HERE = os.path.abspath(os.path.dirname(__file__)) - - def get_version_tofu(path=_HERE): # Try from git @@ -211,14 +179,14 @@ def get_version_tofu(path=_HERE): version_tofu = version_tofu.lower().replace("v", "") return version_tofu - version_tofu = get_version_tofu(path=_HERE) print("") print("Version for setup.py : ", version_tofu) print("") +# ============================================================================== - +# ============================================================================== # Get the long description from the README file # Get the readme file whatever its extension (md vs rst) @@ -235,9 +203,11 @@ def get_version_tofu(path=_HERE): long_description_content_type = "text/markdown" else: long_description_content_type = "text/x-rst" +# ============================================================================== -# ... Compiling files ........................................................ +# ============================================================================== +# Compiling files if openmp_installed: extra_compile_args = ["-O3", "-Wall", "-fopenmp", "-fno-wrapv"] extra_link_args = ["-fopenmp"] @@ -297,17 +267,21 @@ 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=['numpy', 'cython>=0.26'], + + # Description of what tofu does description="A python library for Tomography for Fusion", long_description=long_description, long_description_content_type=long_description_content_type, + # The project's main homepage. url="https://github.com/ToFuProject/tofu", # Author details author="Didier VEZINET", author_email="didier.vezinet@gmail.com", + # Choose your license license="MIT", + # See https://pypi.python.org/pypi?%3Aaction=list_classifiers classifiers=[ # How mature is this project? Common values are @@ -327,8 +301,10 @@ def get_version_tofu(path=_HERE): # In which language most of the code is written ? "Natural Language :: English", ], + # What does your project relate to? keywords="tomography geometry 3D inversion synthetic fusion", + # You can just specify the packages manually here if your project is # simple. Or you can use find_packages(). packages=find_packages( @@ -346,6 +322,7 @@ def get_version_tofu(path=_HERE): "tests10_plugins", ] ), + # packages = ['tofu','tofu.geom'], # Alternatively, if you want to distribute just a my_module.py, uncomment # this: @@ -356,6 +333,7 @@ def get_version_tofu(path=_HERE): # https://packaging.python.org/en/latest/requirements.html install_requires=["numpy", "scipy", "matplotlib", "cython>=0.26"], python_requires=">=3.6", + # List additional groups of dependencies here (e.g. development # dependencies). You can install these using the following syntax, # for example: @@ -370,6 +348,7 @@ def get_version_tofu(path=_HERE): "sphinx_bootstrap_theme", ] }, + # If there are data files included in your packages that need to be # installed, specify them here. If using Python 2.6 or less, then these # have to be included in MANIFEST.in as well. @@ -384,6 +363,7 @@ def get_version_tofu(path=_HERE): "tofu.geom.inputs": ["*.txt"], }, include_package_data=True, + # Although 'package_data' is the preferred approach, in some case you may # need to place data files outside of your packages. See: # http://docs.python.org/3.4/distutils/setupscript.html @@ -399,7 +379,7 @@ def get_version_tofu(path=_HERE): # ], # }, ext_modules=extensions, - cmdclass={"build_ext": cthBext, + cmdclass={"build_ext": build_ext, "clean": CleanCommand}, - include_dirs=[npgetinclude()], + include_dirs=[np.get_include()], )