Switch to setuptools_scm for dynamic versioning#16
Merged
Conversation
Version is now read from the latest git tag reachable from HEAD at build time. Tagged commits get a clean version (v0.2.6 -> "0.2.6"); commits past a tag get a dev suffix like "0.2.7.dev3+g1234567". Removes the static `version = "..."` line and the [tool.tbump] config section. Deletes .github/workflows/release.yml — its only job was to sed the version into pyproject after a release was published and push that back to main, which is unnecessary once the tag is the source of truth. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Replaces the static
version = "..."line inpyproject.tomlwith adynamic = ["version"]declaration backed bysetuptools_scm. The version is now read from the latest git tag reachable fromHEADat build time. Tagged commits get a clean version (v0.2.6→"0.2.6"); commits past a tag get adevsuffix.What changes
pyproject.toml: addsetuptools-scm>=8tobuild-system.requires, replaceversion = "0.2.6"withdynamic = ["version"], add[tool.setuptools_scm]table. Removes the[tool.tbump]config block (tbump's only remaining role was tagging, whichgit tagalready covers)..github/workflows/release.yml: deleted. Its only job was to sed the version into pyproject after a release was published and push the bump back to main, which is unnecessary once the tag is the source of truth.Why
Fixes the issue we hit on v0.2.6 where the release-time auto-bump landed on
mainafter the tag was placed, sopip install git+...@v0.2.6resolved metadata of0.2.5. With dynamic versioning the tag is the version — there's no separate line to keep in sync, no force-push of tags needed.Industry context
Standard pattern for pip-installable Python libraries (pip, setuptools, pytest, numpy, scipy, scikit-learn, sphinx, click, attrs, pydantic).
Release flow after this
git tag -a vX.Y.Z -m "vX.Y.Z"on the commit you want to releasegit push --tagsgh release create vX.Y.Z --notes "..."pip install git+...@vX.Y.Zwill report the matching version.Follow-up
After this merges, the existing
v0.2.6tag still points at a pre-setuptools_scm commit, so it'll still install as0.2.5. Either re-tagv0.2.6at the post-merge commit, or cut a freshv0.2.7from the merged state.Paired with sibling PRs on
Jepson2k/waldoctl#1andJepson2k/pinokin#4.PR description written by Claude on the author's behalf.