Repository navigation
build: embed source git commit in built package - #1140
Open
smflorentino wants to merge 4 commits into
Open
smflorentino wants to merge 4 commits into
smflorentino wants to merge 4 commits into
Conversation
Add a hatchling custom build hook (hatch_build.py) that generates a git-ignored _version.py at build time, following the setuptools-scm / hatch-vcs convention: __version__ and __commit_id__ (aliases version, commit_id). The file ships in both the sdist and the wheel, so an installed package can report the exact commit it was built from. The commit is HEAD of the checkout (only when the project is tracked by it); when building a wheel from an sdist the commit recorded in the sdist is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add hatchling as a dev dependency instead of exempting it from mypy, and bound the build backend to the same range (hatchling>=1.32,<2) so the version mypy checks against matches the one that runs the hook. Give BuildHookInterface its BuilderConfig type argument, which mypy now requires. uv.lock regenerated with uv 0.12, which also bumps the lockfile format revision (3 -> 5); no existing package versions change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hook works on any recent hatchling (checked 1.18 through 1.32), isolated builds always fetch the latest, and uv.lock already pins the dev version, so the bounds added nothing. build-system requires is back to its original form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
mjnovice
approved these changes
Oct 8, 2026
This branch has not been deployed
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.



hatchlingas a dev dependency, so there is no difference between dev box and CI.🤖 Generated with Claude Code