From 096c3e7841ab14798115ddc5adc01fe607d03f1a Mon Sep 17 00:00:00 2001 From: Bas des Tombe Date: Fri, 17 Jul 2026 09:08:08 +0200 Subject: [PATCH 1/3] Derive package version from git tags via hatch-vcs Replace the static version with git-tag-derived versioning (hatch-vcs / setuptools-scm) so every commit builds with a unique, increasing version such as 1.2.1.devN+g. Plain pip and uv installs from git then pick up new commits even into an existing environment, without manual bumps. - Anchored by tag v1.2.0 on main (matches the previous static version) - fetch-depth: 0 in workflows that install the package, so CI derives the real version instead of a 0.1.devN shallow-clone fallback - .git_archival.txt + .gitattributes so GitHub source archives (Download ZIP) of any commit reachable from a tag still build --- .git_archival.txt | 3 +++ .gitattributes | 1 + .github/workflows/data-validation.yml | 2 ++ .github/workflows/lint.yml | 2 ++ pyproject.toml | 7 +++++-- 5 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .git_archival.txt create mode 100644 .gitattributes diff --git a/.git_archival.txt b/.git_archival.txt new file mode 100644 index 0000000..7c51009 --- /dev/null +++ b/.git_archival.txt @@ -0,0 +1,3 @@ +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..00a7b00 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.git_archival.txt export-subst diff --git a/.github/workflows/data-validation.yml b/.github/workflows/data-validation.yml index d7143c0..1d0bea3 100644 --- a/.github/workflows/data-validation.yml +++ b/.github/workflows/data-validation.yml @@ -16,6 +16,8 @@ jobs: HATCH_VERBOSE: 1 steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # hatch-vcs needs the tag history to derive the version - name: Set up Python uses: actions/setup-python@v5 with: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1502ab7..054c64d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,6 +21,8 @@ jobs: HATCH_VERBOSE: 1 steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # hatch-vcs needs the tag history to derive the version - name: Set up Python uses: actions/setup-python@v5 with: diff --git a/pyproject.toml b/pyproject.toml index b941928..5f15ed9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] build-backend = "hatchling.build" -requires = ["hatchling"] +requires = ["hatchling", "hatch-vcs"] [project] authors = [{ name = "Bas des Tombe", email = "bas.des.tombe@pwn.nl" }] @@ -16,13 +16,13 @@ classifiers = [ "Topic :: Utilities", ] description = "Data part of the NHFLO modeling environment owned by HHNK, Artesia, and PWN." +dynamic = ["version"] keywords = ["NHFLO"] license = { file = "LICENSE.txt" } maintainers = [{ name = "Bas des Tombe", email = "bas.des.tombe@pwn.nl" }] name = "nhflodata" readme = "README.md" requires-python = ">=3.14" -version = "1.2.0" dependencies = ["pyyaml>=6.0.1"] @@ -39,6 +39,9 @@ test = [ "yamllint", ] +[tool.hatch.version] +source = "vcs" + [tool.hatch.envs.default] installer = "uv" python = "3.14" From 949dbc5ececfa3bd4b3bd5dbceedddd82c6d6cb1 Mon Sep 17 00:00:00 2001 From: Bas des Tombe Date: Fri, 17 Jul 2026 15:08:20 +0200 Subject: [PATCH 2/3] Fetch tag history without data blobs in CI fetch-depth: 0 on this ~360 MB repo downloads every historical blob just to give hatch-vcs the tag topology; filter: blob:none keeps the version derivation correct while fetching only checkout-reachable blobs. --- .github/workflows/data-validation.yml | 1 + .github/workflows/lint.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/data-validation.yml b/.github/workflows/data-validation.yml index 1d0bea3..4fad100 100644 --- a/.github/workflows/data-validation.yml +++ b/.github/workflows/data-validation.yml @@ -18,6 +18,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 # hatch-vcs needs the tag history to derive the version + filter: blob:none # full history is only needed for tags; skip the heavy data blobs - name: Set up Python uses: actions/setup-python@v5 with: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 054c64d..f3fd1d8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,6 +23,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 # hatch-vcs needs the tag history to derive the version + filter: blob:none # full history is only needed for tags; skip the heavy data blobs - name: Set up Python uses: actions/setup-python@v5 with: From 288ca68875daa847008eb78d0c5da22f57624809 Mon Sep 17 00:00:00 2001 From: Bas des Tombe Date: Fri, 17 Jul 2026 18:21:33 +0200 Subject: [PATCH 3/3] Expose __version__ from the package Reads the installed distribution metadata (importlib.metadata), so it reports the same git-tag-derived version hatch-vcs builds into the package. --- src/nhflodata/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nhflodata/__init__.py b/src/nhflodata/__init__.py index 0323efb..c332c4a 100644 --- a/src/nhflodata/__init__.py +++ b/src/nhflodata/__init__.py @@ -1,4 +1,8 @@ """Utilities for working with NHFLO data.""" # ruff: noqa: F401 +from importlib.metadata import version + from nhflodata.get_paths import create_new_dataset, get_abs_data_path + +__version__ = version("nhflodata")