From 6680903e48962774d2fdda3fbf7d05f2a4f650de Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Tue, 15 Oct 2024 12:25:58 +0200 Subject: [PATCH] Use setuptools_scm for package versions Removes some extra `build-system.requires` entries. --- src/python/benchmark_models_petab/__init__.py | 8 +++++++- src/python/benchmark_models_petab/version.py | 3 --- src/python/pyproject.toml | 13 +++---------- 3 files changed, 10 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/pyproject.toml b/src/python/pyproject.toml index 8030d7a..c7a7850 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,15 @@ 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] + [tool.ruff] line-length = 79 - [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"]