From f392619c563eb3c80a7980a400b8cfd827a5bc93 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Mon, 22 Apr 2024 09:58:03 +0200 Subject: [PATCH] setup.cfg -> pyproject.toml (#2408) Let's reduce the number of package configuration files... --- .github/workflows/deploy_release.yml | 2 +- python/sdist/amici/custom_commands.py | 8 +- python/sdist/bin | 1 - python/sdist/pyproject.toml | 110 +++++++++++++++++++++++++- python/sdist/setup.cfg | 91 --------------------- python/sdist/setup.py | 10 --- 6 files changed, 116 insertions(+), 106 deletions(-) delete mode 120000 python/sdist/bin delete mode 100644 python/sdist/setup.cfg diff --git a/.github/workflows/deploy_release.yml b/.github/workflows/deploy_release.yml index de7a073cc2..25eaf97a0e 100644 --- a/.github/workflows/deploy_release.yml +++ b/.github/workflows/deploy_release.yml @@ -39,7 +39,7 @@ jobs: - name: Remove direct dependencies from setup.cfg # Remove any "git+https"-based dependencies that are not supported # by PyPI and are only required for testing. - run: sed -i '/git+https/d' python/sdist/setup.cfg + run: sed -i '/git+https/d' python/sdist/pyproject.toml - name: sdist run: scripts/buildSdist.sh diff --git a/python/sdist/amici/custom_commands.py b/python/sdist/amici/custom_commands.py index 46abfe3290..36fcd17605 100644 --- a/python/sdist/amici/custom_commands.py +++ b/python/sdist/amici/custom_commands.py @@ -17,13 +17,17 @@ class AmiciInstall(install): """Custom `install` command to handle extra arguments""" - print("running AmiciInstall") - # Passing --no-clibs allows to install the Python-only part of AMICI user_options = install.user_options + [ ("no-clibs", None, "Don't build AMICI C++ extension"), ] + def run(self): + """Setuptools entry-point""" + print(f"running {self.__class__.__name__}") + + super().run() + def initialize_options(self): super().initialize_options() self.no_clibs = False diff --git a/python/sdist/bin b/python/sdist/bin deleted file mode 120000 index 353d1e9f9e..0000000000 --- a/python/sdist/bin +++ /dev/null @@ -1 +0,0 @@ -../bin/ \ No newline at end of file diff --git a/python/sdist/pyproject.toml b/python/sdist/pyproject.toml index 91b8484af6..15ee06df73 100644 --- a/python/sdist/pyproject.toml +++ b/python/sdist/pyproject.toml @@ -1,6 +1,8 @@ +# https://packaging.python.org/en/latest/guides/writing-pyproject-toml/ +# https://setuptools.pypa.io/en/latest/userguide/index.html [build-system] requires = [ - "setuptools>=40.6.3", + "setuptools>=61", "wheel", # oldest-supported-numpy helps us to pin numpy here to the lowest supported # version to have ABI-compatibility with the numpy version in the runtime @@ -13,6 +15,112 @@ requires = [ ] build-backend = "setuptools.build_meta" +[project] +name = "amici" +dynamic = ["version"] +description = "Advanced multi-language Interface to CVODES and IDAS" +requires-python = ">=3.9" +dependencies = [ + "cmake-build-extension==0.5.1", + "sympy>=1.9", + "numpy>=1.19.3; python_version=='3.9'", + "numpy>=1.21.4; python_version>='3.10'", + "numpy>=1.23.2; python_version=='3.11'", + "numpy; python_version>='3.12'", + "python-libsbml", + "pandas>=2.0.2", + "pyarrow", + "wurlitzer", + "toposort", + "setuptools>=48", + "mpmath", +] +license = {text = "BSD 3-Clause License"} +authors = [ + {name = "Fabian Froehlich", email = "froehlichfab@gmail.com"}, + {name = "Daniel Weindl", email = "sci@danielweindl.de"}, + {name = "Jan Hasenauer"}, + {name = "AMICI contributors"}, +] +maintainers = [ + {name = "Fabian Froehlich", email = "froehlichfab@gmail.com"}, + {name = "Daniel Weindl", email = "sci@danielweindl.de"}, +] +readme = "README.md" +keywords =["differential equations", "simulation", "ode", "cvodes", + "systems biology", "sensitivity analysis", "sbml", "pysb", "petab"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Operating System :: POSIX :: Linux", + "Operating System :: MacOS :: MacOS X", + "Programming Language :: Python", + "Programming Language :: C++", + "Topic :: Scientific/Engineering :: Bio-Informatics", +] + +[project.optional-dependencies] +# Don't include any URLs here - they are not supported by PyPI: +# HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/ +# Invalid value for requires_dist. Error: Can't have direct dependency: ... +petab = ["petab>=0.2.9"] +pysb = ["pysb>=1.13.1"] +test = [ + "benchmark_models_petab @ git+https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab.git@master#subdirectory=src/python", + "h5py", + "pytest", + "pytest-cov", + "pytest-rerunfailures", + "coverage", + "shyaml", + "antimony>=2.13", + # see https://github.com/sys-bio/antimony/issues/92 + # unsupported x86_64 / x86_64h + "antimony!=2.14; platform_system=='Darwin' and platform_machine in 'x86_64h'", + "scipy", + "pooch" +] +vis =[ + "matplotlib", + "seaborn", +] +examples =[ + "jupyter", + "scipy", +] + +[project.scripts] +# amici_import_petab.py is kept for backwards compatibility +amici_import_petab = "amici.petab.cli.import_petab:_main" +"amici_import_petab.py" = "amici.petab.cli.import_petab:_main" + +[project.urls] +Homepage = "https://github.com/AMICI-dev/AMICI" +Documentation = "https://amici.readthedocs.io/en/latest/" +Repository = "https://github.com/AMICI-dev/AMICI.git" +"Bug Tracker" = "https://github.com/AMICI-dev/AMICI/issues" + +# TODO: consider using setuptools_scm +#[tool.setuptools_scm] +## https://setuptools-scm.readthedocs.io/en/latest/ +#root = "../.." + +[tool.setuptools.package-data] +amici = [ + "amici/include/amici/*", + "src/*template*", + "swig/*", + "libs/*", + "setup.py.template", +] + +[tool.setuptools.exclude-package-data] +"*" = ["README.txt"] + +[tool.setuptools.dynamic] +version = {attr = "amici.__version__"} + [tool.black] line-length = 79 diff --git a/python/sdist/setup.cfg b/python/sdist/setup.cfg deleted file mode 100644 index d34d42f98f..0000000000 --- a/python/sdist/setup.cfg +++ /dev/null @@ -1,91 +0,0 @@ -[metadata] -name = amici -description = Advanced multi-language Interface to CVODES and IDAS -version = file: amici/version.txt -license = BSD 3-Clause License -url = https://github.com/AMICI-dev/AMICI -keywords = differential equations, simulation, ode, cvodes, systems biology, sensitivity analysis, sbml, pysb, petab -author = Fabian Froehlich, Jan Hasenauer, Daniel Weindl and Paul Stapor -author_email = fabian_froehlich@hms.harvard.edu -project_urls = - Bug Reports = https://github.com/AMICI-dev/AMICI/issues - Source = https://github.com/AMICI-dev/AMICI - Documentation = https://amici.readthedocs.io/en/latest/ -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Science/Research - License :: OSI Approved :: BSD License - Operating System :: POSIX :: Linux - Operating System :: MacOS :: MacOS X - Programming Language :: Python - Programming Language :: C++ - Topic :: Scientific/Engineering :: Bio-Informatics - -[options] -packages = find_namespace: -package_dir = - amici = amici -python_requires = >=3.9 -install_requires = - cmake-build-extension==0.5.1 - sympy>=1.9 - numpy>=1.19.3; python_version=='3.9' - numpy>=1.21.4; python_version>='3.10' - numpy>=1.23.2; python_version=='3.11' - numpy; python_version>='3.12' - python-libsbml - pandas>=2.0.2 - pyarrow - wurlitzer - toposort - setuptools>=48 - mpmath -include_package_data = True -zip_safe = False - -[options.extras_require] -# Don't include any URLs here - they are not supported by PyPI: -# HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/ -# Invalid value for requires_dist. Error: Can't have direct dependency: ... -petab = petab>=0.2.9 -pysb = pysb>=1.13.1 -test = - benchmark_models_petab @ git+https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab.git@master#subdirectory=src/python - h5py - pytest - pytest-cov - pytest-rerunfailures - coverage - shyaml - antimony>=2.13 - # see https://github.com/sys-bio/antimony/issues/92 - # unsupported x86_64 / x86_64h - antimony!=2.14; platform_system=='Darwin' and platform_machine in 'x86_64h' - scipy - pooch -vis = - matplotlib - seaborn -examples = - jupyter - scipy - -[options.package_data] -amici = - amici/include/amici/* - src/*template* - swig/* - libs/* - setup.py.template - -[options.exclude_package_data] -* = - README.txt - - -[options.entry_points] - -; amici_import_petab.py is kept for backwards compatibility -console_scripts = - amici_import_petab = amici.petab.cli.import_petab:_main - amici_import_petab.py = amici.petab.cli.import_petab:_main diff --git a/python/sdist/setup.py b/python/sdist/setup.py index 2f44a18342..cfc474ebe8 100755 --- a/python/sdist/setup.py +++ b/python/sdist/setup.py @@ -158,14 +158,6 @@ def get_extensions(): def main(): - # Readme as long package description to go on PyPi - # (https://pypi.org/project/amici/) - with open( - os.path.join(os.path.dirname(__file__), "README.md"), - encoding="utf-8", - ) as fh: - long_description = fh.read() - ext_modules = get_extensions() # handle parallel building @@ -185,8 +177,6 @@ def main(): "develop": AmiciDevelop, "build_py": AmiciBuildPy, }, - long_description=long_description, - long_description_content_type="text/markdown", ext_modules=ext_modules, )