From c163e117268e45a6356030d2e3c8df15aea9830e Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Tue, 15 Oct 2024 13:36:02 +0200 Subject: [PATCH] Use setuptools_scm for package versions (#243) Removes some extra `build-system.requires` entries. So far, repository versions were date-based (well, there was only one, v20230717). The Python package had a constant version number `0.0.0a1`. To work well with the default setuptools_scm schema, future releases should ideally use `vYYYY.MM.DD` tags. The Python package will then also have the same version as the benchmark collection as such. --- src/python/benchmark_models_petab/__init__.py | 8 +++++++- src/python/benchmark_models_petab/version.py | 3 --- src/python/build.sh | 3 +++ src/python/pyproject.toml | 14 ++++---------- 4 files changed, 14 insertions(+), 14 deletions(-) delete mode 100644 src/python/benchmark_models_petab/version.py diff --git a/src/python/benchmark_models_petab/__init__.py b/src/python/benchmark_models_petab/__init__.py index 6bf4828..66be078 100644 --- a/src/python/benchmark_models_petab/__init__.py +++ b/src/python/benchmark_models_petab/__init__.py @@ -6,5 +6,11 @@ from .base import get_problem, get_problem_yaml_path from .C import MODEL_DIRS, MODELS, MODELS_DIR -from .version import __version__ from .overview import get_overview_df +from importlib.metadata import PackageNotFoundError, version + +try: + __version__ = version("benchmark_models_petab") +except PackageNotFoundError: + # package is not installed + pass diff --git a/src/python/benchmark_models_petab/version.py b/src/python/benchmark_models_petab/version.py deleted file mode 100644 index 3424ddf..0000000 --- a/src/python/benchmark_models_petab/version.py +++ /dev/null @@ -1,3 +0,0 @@ -"""Version.""" - -__version__ = "0.0.0a1" diff --git a/src/python/build.sh b/src/python/build.sh index dbfe47a..f61f49a 100755 --- a/src/python/build.sh +++ b/src/python/build.sh @@ -36,6 +36,9 @@ cp -r "../../$DATA_DIR" $BUILD_DIR/$CODE_DIR # Hop into cd $BUILD_DIR +# update git root in setuptools_scm configuration +sed -ri 's/root = "..\/.."/root = "..\/..\/.."/' pyproject.toml + # Build pip install --upgrade build python -m build --sdist diff --git a/src/python/pyproject.toml b/src/python/pyproject.toml index 8030d7a..309249c 100644 --- a/src/python/pyproject.toml +++ b/src/python/pyproject.toml @@ -1,12 +1,7 @@ [build-system] -requires = [ - "setuptools", - "wheel", - "petab", -] +requires = ["setuptools>=64", "setuptools-scm>=8"] build-backend = "setuptools.build_meta" - [project] name = "benchmark_models_petab" description = "A collection of models with experimental data in the PEtab format" @@ -33,17 +28,16 @@ dependencies = [ [project.optional-dependencies] dev = ["ruff"] -[tool.setuptools.dynamic] -version = {attr = "benchmark_models_petab.__version__"} - [project.scripts] bmp-petablint = "benchmark_models_petab.check_petablint:main" bmp-check-sbml-metadata = "benchmark_models_petab.check_sbml_metadata:main" bmp-create-overview = "benchmark_models_petab.overview:main" +[tool.setuptools_scm] +root = "../.." + [tool.ruff] line-length = 79 - [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"]