From fa56c8a550120344fd2090e2606ff89b91da00ee Mon Sep 17 00:00:00 2001 From: carlosgjs Date: Thu, 4 May 2023 15:25:19 -0700 Subject: [PATCH] Generate version from git tags (#98) * Generate version from git tags * use no-local-version * Update .gitignore * export generated version * fetch tags * Use fetch-depth instead --- .github/workflows/release.yaml | 3 ++- .gitignore | 3 +++ pyproject.toml | 10 ++++++++-- src/noisepy/seis/__init__.py | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 71adaf50..655852b6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -17,7 +17,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - + with: + fetch-depth: 0 # Fetch all history for all branches and tags. - name: Set up Python uses: actions/setup-python@v4.5.0 with: diff --git a/.gitignore b/.gitignore index f0abb5f2..8546ee07 100644 --- a/.gitignore +++ b/.gitignore @@ -161,3 +161,6 @@ cython_debug/ # Cache location for inventory (used by FDSNChannelCatalog) noisepy_cache/ + +# Version file generated at build time +src/noisepy/seis/_version.py diff --git a/pyproject.toml b/pyproject.toml index ffa8d0f0..f100f9dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["hatchling"] +requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" [project] @@ -49,7 +49,13 @@ dependencies = [ Homepage = "https://github.com/mdenolle/NoisePy" [tool.hatch.version] -path = "src/noisepy/seis/__init__.py" +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "src/noisepy/seis/_version.py" + +[tool.hatch.version.raw-options] +local_scheme = "no-local-version" [tool.hatch.build.targets.sdist] include = [ diff --git a/src/noisepy/seis/__init__.py b/src/noisepy/seis/__init__.py index 2b4144f5..2b95385f 100644 --- a/src/noisepy/seis/__init__.py +++ b/src/noisepy/seis/__init__.py @@ -1,11 +1,11 @@ # no-qa F401 import logging +from ._version import __version__ # noqa: F401 from .S0A_download_ASDF_MPI import download # noqa: F401 from .S1_fft_cc_MPI import cross_correlate # noqa: F401 from .S2_stacking import stack # noqa: F401 -__version__ = "0.5.13" """ NoisePy is a Python package designed for fast and easy computation of ambient noise cross-correlation functions. It provides additional functionality for noise monitoring and surface wave dispersion analysis.