Skip to content

Commit ed19271

Browse files
committed
Add dynamic versioning to palace-util and palace-opds
Both packages now declare `dynamic = ["version"]` and source the version from a committed `_version.py` stub via hatchling's regex version source. The stub carries a dev placeholder (0.0.0.dev0) so local / developer builds succeed out-of-box; the PyPI publish workflow overwrites `_version.py` with the dunamai-computed release version right before `uv build` to get the real version into the wheel metadata. `_version.py` also carries `__commit__` and `__branch__` (None on dev, populated in CI) to match the shape of palace-manager's `_version.py` — useful for `import palace.util; palace.util.__commit__` style runtime lookup. Each package's `__init__.py` re-exports the three attributes; since `_version.py` is committed, no try/except fallback is needed (palace-manager keeps its try/except only because its `_version.py` is generated at Docker build time and never committed). palace-manager's own versioning is unchanged; it's not yet PyPI-publishable for unrelated reasons.
1 parent 11171c1 commit ed19271

7 files changed

Lines changed: 24 additions & 4 deletions

File tree

packages/palace-opds/pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ dependencies = [
1111
"uritemplate==4.2.0",
1212
]
1313
description = "Pydantic models for OPDS 2.0, RWPM, ODL, LCP, and Palace Project extensions."
14+
dynamic = ["version"]
1415
license = "Apache-2.0"
1516
name = "palace-opds"
1617
readme = "README.md"
1718
requires-python = ">=3.12,<4"
18-
version = "0"
1919

2020
[project.urls]
2121
Homepage = "https://thepalaceproject.org"
@@ -24,6 +24,11 @@ Repository = "https://github.com/ThePalaceProject/circulation"
2424
[tool.hatch.build.targets.wheel]
2525
packages = ["src/palace"]
2626

27+
[tool.hatch.version]
28+
path = "src/palace/opds/_version.py"
29+
pattern = '__version__: str = "(?P<version>[^"]+)"'
30+
source = "regex"
31+
2732
[tool.isort]
2833
combine_as_imports = true
2934
known_first_party = ["palace.opds"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from palace.opds._version import __branch__, __commit__, __version__
2+
3+
__all__ = ["__branch__", "__commit__", "__version__"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__version__: str = "0.0.0.dev0"
2+
__commit__: str | None = None
3+
__branch__: str | None = None

packages/palace-util/pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ dependencies = [
88
"python-dateutil>=2.8,<3",
99
]
1010
description = "Shared utilities for Palace Project packages."
11+
dynamic = ["version"]
1112
license = "Apache-2.0"
1213
name = "palace-util"
1314
readme = "README.md"
1415
requires-python = ">=3.12,<4"
15-
version = "0"
1616

1717
[project.urls]
1818
Homepage = "https://thepalaceproject.org"
@@ -21,6 +21,11 @@ Repository = "https://github.com/ThePalaceProject/circulation"
2121
[tool.hatch.build.targets.wheel]
2222
packages = ["src/palace"]
2323

24+
[tool.hatch.version]
25+
path = "src/palace/util/_version.py"
26+
pattern = '__version__: str = "(?P<version>[^"]+)"'
27+
source = "regex"
28+
2429
[tool.isort]
2530
combine_as_imports = true
2631
known_first_party = ["palace.util"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from palace.util._version import __branch__, __commit__, __version__
2+
3+
__all__ = ["__branch__", "__commit__", "__version__"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__version__: str = "0.0.0.dev0"
2+
__commit__: str | None = None
3+
__branch__: str | None = None

uv.lock

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

0 commit comments

Comments
 (0)