From d1a4ef8aab22e1bbd7cd46b1ef1714b3dc3021f4 Mon Sep 17 00:00:00 2001 From: Leif Denby Date: Thu, 29 Oct 2026 11:35:33 +0100 Subject: [PATCH 1/2] Use setuptools-scm for tag-based versioning Derive the package version from git tags (as in mlwp-data-specs and mlwp-data-loaders) instead of a hardcoded version string, and expose it as mxalign.__version__. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/tests.yaml | 2 ++ pyproject.toml | 14 +++++++++++--- src/mxalign/__init__.py | 4 ++++ tests/test_version.py | 11 +++++++++++ uv.lock | 1 - 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 tests/test_version.py diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3cf38b3..9bd34be 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -15,6 +15,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7.0.0 + with: + fetch-depth: 0 - uses: astral-sh/setup-uv@v8.2.0 with: python-version: "3.12" diff --git a/pyproject.toml b/pyproject.toml index dc42813..6288660 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mxalign" -version = "0.1.0" +dynamic = ["version"] description = "Add your description here" readme = "README.md" authors = [ @@ -39,8 +39,16 @@ jobqueue = [ ] [build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" +requires = ["setuptools>=69", "setuptools-scm>=8", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +package-dir = {"" = "src"} + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools_scm] [dependency-groups] dev = [ diff --git a/src/mxalign/__init__.py b/src/mxalign/__init__.py index 1ce5e4f..c219638 100644 --- a/src/mxalign/__init__.py +++ b/src/mxalign/__init__.py @@ -1,3 +1,5 @@ +from importlib.metadata import version + from .transformations.transform import transform from .transformations.registry import available_transformations, register_transformation from .interpolations.interpolate import interpolate @@ -10,6 +12,7 @@ from . import interpolations __all__ = [ + "__version__", "transform", "available_transformations", "register_transformation", @@ -22,3 +25,4 @@ "transformations", "interpolations", ] +__version__ = version("mxalign") diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 0000000..1be4c64 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,11 @@ +import mxalign + + +def test_version_is_set() -> None: + """Check that the package version is resolved from the git tag. + + A fallback version of ``0.0.0`` means setuptools-scm could not find any + git metadata when the package was installed. + """ + assert isinstance(mxalign.__version__, str) + assert mxalign.__version__ not in ("", "0.0.0") diff --git a/uv.lock b/uv.lock index 50f1119..bf30a7a 100644 --- a/uv.lock +++ b/uv.lock @@ -1701,7 +1701,6 @@ wheels = [ [[package]] name = "mxalign" -version = "0.1.0" source = { editable = "." } dependencies = [ { name = "bokeh" }, From 502600d0c01f5e9ae4f6f7003c4142eb0ccd0d88 Mon Sep 17 00:00:00 2001 From: Leif Denby Date: Thu, 29 Oct 2026 11:36:08 +0100 Subject: [PATCH 2/2] Add changelog entry for #49 Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce4f4f3..164a647 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Store dataset properties as netCDF-safe individual attributes while keeping read compatibility with legacy `attrs["properties"]` dict/JSON data. [\#21](https://github.com/mlwp-tools/mxalign/pull/21) @observingClouds - Added CI test workflow with first unit tests. [\#21](https://github.com/mlwp-tools/mxalign/pull/21) @observingClouds - Added CI action for package build and upload to pypi.org on releases. [\#28](https://github.com/mlwp-tools/mxalign/pull/28) @leifdenby +- Package version is now derived from git tags via `setuptools-scm` (build backend switched from hatchling to setuptools) and exposed as `mxalign.__version__`. [\#49](https://github.com/mlwp-tools/mxalign/pull/49) @leifdenby ## [0.1.0](https://github.com/mlwp-tools/mxalign/releases/tag/v0.1.0)