Skip to content

Commit 95c9f51

Browse files
Merge pull request #600 from laughingman7743/feature/introduce-hatch-vcs
Introduce hatch-vcs for automatic version management
2 parents 134a94a + e9ebb31 commit 95c9f51

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ cover/
2323
docs/_build
2424
.mcp.json
2525
.serena
26+
_version.py

pyathena/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@
1010
from pyathena.connection import Connection, ConnectionCursor
1111
from pyathena.cursor import Cursor
1212

13-
__version__ = "3.17.1"
13+
try:
14+
from pyathena._version import __version__
15+
except ImportError:
16+
try:
17+
from importlib.metadata import version
18+
19+
__version__ = version("PyAthena")
20+
except Exception:
21+
__version__ = "unknown"
1422
user_agent_extra: str = f"PyAthena/{__version__}"
1523

1624
# Globals https://www.python.org/dev/peps/pep-0249/#globals

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ dev = [
6363
]
6464

6565
[build-system]
66-
requires = ["hatchling"]
66+
requires = ["hatchling", "hatch-vcs"]
6767
build-backend = "hatchling.build"
6868

6969
[tool.hatch.metadata]
@@ -82,7 +82,10 @@ only-include = [
8282
packages = ["pyathena"]
8383

8484
[tool.hatch.version]
85-
path = "pyathena/__init__.py"
85+
source = "vcs"
86+
87+
[tool.hatch.build.hooks.vcs]
88+
version-file = "pyathena/_version.py"
8689

8790
[tool.pytest.ini_options]
8891
norecursedirs = [

uv.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)