Skip to content

Single-source the package version (closes #10) - #15

Merged
adrida merged 1 commit into
adrida:mainfrom
ilanoh:chore/single-source-version
Jun 9, 2026
Merged

adrida merged 1 commit into
adrida:mainfrom
ilanoh:chore/single-source-version

Conversation

@ilanoh

@ilanoh ilanoh commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

The version was duplicated in pyproject.toml and src/tracer/__init__.py and had to be bumped together by hand, which (per the issue) already let the code, tags and PyPI drift apart once.

Change

Make src/tracer/__init__.py's __version__ the single source of truth via hatchling's dynamic version, exactly as suggested in the issue:

[project]
dynamic = ["version"]

[tool.hatch.version]
path = "src/tracer/__init__.py"

(dropped the hardcoded [project] version = "..." line).

Optional hardening (included)

Added a step to the release workflow that fails the publish if the pushed vX.Y.Z tag does not match __version__, so a mismatched tag can never ship to PyPI.

Acceptance criteria

  • Version defined in exactly one place (src/tracer/__init__.py)
  • python -c "import tracer; print(tracer.__version__)" matches the built wheel metadata (both 0.1.3)
  • pip install -e . and python -m build both succeed
  • Tag guard verified locally: passes on a matching tag, blocks on a mismatch

Closes #10.

The version was duplicated in pyproject.toml and src/tracer/__init__.py and
had to be bumped together by hand, which already let code, tags and PyPI
drift apart once.

Make __init__.py the single source of truth via hatchling's dynamic version:
- drop the hardcoded [project] version, add dynamic = ["version"]
- add [tool.hatch.version] path = "src/tracer/__init__.py"

Harden the release workflow with a step that fails the publish if the pushed
vX.Y.Z tag does not match __version__, so a mismatched tag can never ship.

Verified: pip install -e . and python -m build both succeed, the built wheel
metadata reports 0.1.3, and tracer.__version__ matches.
@adrida
adrida merged commit d71c5e2 into adrida:main Jun 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single-source the package version (pyproject + __init__ drift risk)

2 participants