diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 45c769f..b2b8b15 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,9 @@ jobs: - name: Checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5.0.2 with: - fetch-depth: 1 + # Full history + tags so hatch-vcs can resolve the package version + # during `uv sync` (the editable install runs the version hook). + fetch-depth: 0 persist-credentials: false - name: Install a specific version of uv diff --git a/.gitignore b/.gitignore index ba975f8..a6ca88a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ __pycache__/ *.so # Distribution / packaging +packages/datacube-benchmark/src/datacube_benchmark/_version.py .Python env/ .venv/ diff --git a/packages/datacube-benchmark/pyproject.toml b/packages/datacube-benchmark/pyproject.toml index a18acbf..f946662 100644 --- a/packages/datacube-benchmark/pyproject.toml +++ b/packages/datacube-benchmark/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "datacube-benchmark" -version = "0.1.0" +dynamic = ["version"] description = "Utilities to benchmark datacubes with various formats, compressions, and chunking schemes." readme = "README.md" authors = [ @@ -31,9 +31,17 @@ dependencies = [ datacube-benchmark = "datacube_benchmark:main" [build-system] -requires = ["hatchling"] +requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" +[tool.hatch.version] +source = "vcs" +# The package lives in a workspace subdirectory; point setuptools-scm at the repo root. +raw-options = { root = "../.." } + +[tool.hatch.build.hooks.vcs] +version-file = "src/datacube_benchmark/_version.py" + [tool.numpydoc_validation] # See https://numpydoc.readthedocs.io/en/latest/validation.html#built-in-validation-checks for list of checks checks = [ diff --git a/packages/datacube-benchmark/src/datacube_benchmark/__init__.py b/packages/datacube-benchmark/src/datacube_benchmark/__init__.py index 49e32b7..dbb5b55 100644 --- a/packages/datacube-benchmark/src/datacube_benchmark/__init__.py +++ b/packages/datacube-benchmark/src/datacube_benchmark/__init__.py @@ -11,7 +11,13 @@ import numpy as np +try: + from ._version import __version__ +except ImportError: # pragma: no cover - _version.py is generated at build time + __version__ = "0.0.0+unknown" + __all__ = [ + "__version__", "Config", "create_empty_dataarray", "create_zarr_store",