Skip to content

Commit c163e11

Browse files
authored
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.
1 parent 91ac49f commit c163e11

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/python/benchmark_models_petab/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,11 @@
66

77
from .base import get_problem, get_problem_yaml_path
88
from .C import MODEL_DIRS, MODELS, MODELS_DIR
9-
from .version import __version__
109
from .overview import get_overview_df
10+
from importlib.metadata import PackageNotFoundError, version
11+
12+
try:
13+
__version__ = version("benchmark_models_petab")
14+
except PackageNotFoundError:
15+
# package is not installed
16+
pass

src/python/benchmark_models_petab/version.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/python/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ cp -r "../../$DATA_DIR" $BUILD_DIR/$CODE_DIR
3636
# Hop into
3737
cd $BUILD_DIR
3838

39+
# update git root in setuptools_scm configuration
40+
sed -ri 's/root = "..\/.."/root = "..\/..\/.."/' pyproject.toml
41+
3942
# Build
4043
pip install --upgrade build
4144
python -m build --sdist

src/python/pyproject.toml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
[build-system]
2-
requires = [
3-
"setuptools",
4-
"wheel",
5-
"petab",
6-
]
2+
requires = ["setuptools>=64", "setuptools-scm>=8"]
73
build-backend = "setuptools.build_meta"
84

9-
105
[project]
116
name = "benchmark_models_petab"
127
description = "A collection of models with experimental data in the PEtab format"
@@ -33,17 +28,16 @@ dependencies = [
3328
[project.optional-dependencies]
3429
dev = ["ruff"]
3530

36-
[tool.setuptools.dynamic]
37-
version = {attr = "benchmark_models_petab.__version__"}
38-
3931
[project.scripts]
4032
bmp-petablint = "benchmark_models_petab.check_petablint:main"
4133
bmp-check-sbml-metadata = "benchmark_models_petab.check_sbml_metadata:main"
4234
bmp-create-overview = "benchmark_models_petab.overview:main"
4335

36+
[tool.setuptools_scm]
37+
root = "../.."
38+
4439
[tool.ruff]
4540
line-length = 79
4641

47-
4842
[tool.ruff.lint.per-file-ignores]
4943
"__init__.py" = ["F401"]

0 commit comments

Comments
 (0)