Skip to content

Commit 455b742

Browse files
authored
Merge pull request #17 from DeepPSP/migrate/hatch-vcs
build: migrate to hatch-vcs for version management
2 parents c5024c6 + d31437e commit 455b742

5 files changed

Lines changed: 31 additions & 62 deletions

File tree

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525

2626
steps:
2727
- uses: actions/checkout@v7
28+
with:
29+
fetch-depth: 0 # Use full history so hatch-vcs/git describe can see all tags
30+
fetch-tags: true # Ensure tags are available for versioning
2831
- name: Set up Python
2932
uses: actions/setup-python@v7
3033
with:

.github/workflows/run-pytest.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-22.04
1616
strategy:
1717
matrix:
18-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
18+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1919

2020
steps:
2121
- uses: actions/checkout@v7
@@ -29,7 +29,6 @@ jobs:
2929
python -m pip install -r requirements.txt
3030
python -m pip install pytest pytest-xdist pytest-cov # Testing packages
3131
python -m pip uninstall pcg_springer_features --yes # Remove if already installed
32-
python setup.py install_egg_info # Workaround https://github.com/pypa/pip/issues/4537
3332
python -m pip install -e .[dev]
3433
python -m pip freeze
3534
- name: Test with pytest

pcg_springer_features/version.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
__version__ = "0.4"
1+
# This file is auto-generated by hatch-vcs, do not edit manually
2+
# The placeholder below is used in the working tree; when the package is
3+
# installed, try to obtain the real version from importlib.metadata and
4+
# fall back to the placeholder only if the distribution is not installed.
5+
try:
6+
from importlib import metadata as _metadata
7+
from importlib.metadata import PackageNotFoundError as _PackageNotFoundError
8+
except ImportError:
9+
_metadata = None
10+
_PackageNotFoundError = Exception
11+
12+
_DIST_NAME = "pcg-springer-features"
13+
14+
if _metadata is not None:
15+
try:
16+
__version__ = _metadata.version(_DIST_NAME)
17+
except _PackageNotFoundError:
18+
__version__ = "0.0.0" # placeholder, overwritten at build time
19+
else:
20+
__version__ = "0.0.0" # placeholder, overwritten at build time

pyproject.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["hatchling"]
2+
requires = ["hatchling", "hatch-vcs"]
33
build-backend = "hatchling.build"
44

55
[project]
@@ -8,7 +8,7 @@ dynamic = ["version"]
88
description = "Tools for Computation of Springer's Features from Phonocardiogram (PCG)."
99
readme = "README.md"
1010
license = { file = "LICENSE" }
11-
requires-python = ">=3.8"
11+
requires-python = ">=3.10"
1212
authors = [
1313
{ name = "DeepPSP", email = "wenh06@gmail.com" },
1414
]
@@ -50,7 +50,11 @@ test = [
5050
Homepage = "https://github.com/DeepPSP/pcg_springer_features"
5151

5252
[tool.hatch.version]
53-
path = "pcg_springer_features/version.py"
53+
source = "vcs"
54+
55+
[tool.hatch.build.hooks.vcs]
56+
version-file = "pcg_springer_features/version.py"
57+
template = "# auto-generated by hatch-vcs, do not edit manually\n__version__ = \"{version}\"\n"
5458

5559
[tool.hatch.build.targets.sdist]
5660
include = [

setup.py

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

0 commit comments

Comments
 (0)