build: derive version from git tags via hatch-vcs#20
Merged
Conversation
Stop hand-editing ``project.version`` for every release. Hatch-vcs reads the version from the latest ``renderers-v*`` tag at build time, so: - Tagged commits get clean releases: ``renderers-v0.1.8`` → ``0.1.8``. - Untagged commits get unique PEP 440 dev versions like ``0.1.8.dev3+g4c877be4`` so any commit is uniquely installable (useful for downstream end-to-end testing without burning a real release). Workflow change: before: edit pyproject version → commit → tag → push → publish after: tag → push → publish Adds: - ``hatch-vcs`` to build-system requires - ``dynamic = ["version"]`` + ``[tool.hatch.version] source = "vcs"`` - ``tag_regex`` strips the ``renderers-v`` prefix (publish.yml release contract) - generates ``renderers/_version.py`` at build time; re-exported as ``renderers.__version__`` - ``.gitignore`` entry for the generated file Drops the now-trivial version-mismatch check in ``publish.yml`` (pyproject's version is derived from the same tag). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Move ``tag_regex`` from ``raw-options`` (setuptools-scm passthrough) to the top-level ``tag-pattern`` key — both work, but ``tag-pattern`` is the canonical hatch-vcs option per the project's README. Loosens the version-capture group to ``.+`` so we can tag pre-releases like ``renderers-v0.2.0rc1`` without re-touching the regex. Add ``fallback-version = "0.0.0"`` for the (rare) case of building from a context without VCS metadata, e.g. a downstream sdist consumer that doesn't ship ``.git``. Real builds resolve from the tag history. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stop hand-editing `project.version` for every release. hatch-vcs reads the version from the latest `renderers-v*` tag at build time, so:
Workflow change
Removes step 1–2 entirely. Version field becomes derived, never edited by hand.
What changes
Verified locally
```text
$ uv build
Successfully built dist/renderers-0.1.8.dev0+gf7a8a5635.d20260512.tar.gz
$ uv run python -c "import renderers; print(renderers.version)"
0.1.8.dev0+gf7a8a5635.d20260512
```
(The `.d20260512` suffix is setuptools-scm's dirty-tree marker; a clean tagged commit produces just `0.1.8`.)
Full test suite: 939 passed, 49 skipped, 1 xfailed.
Test plan