fix: derive __version__ from package metadata#81
Merged
Conversation
codegraph/__init__.py hardcoded __version__ separately from pyproject.toml, so the 0.5.0 release shipped with a 0.4.6 banner (only pyproject was bumped, and the release workflow checks the tag against pyproject only). Read the version from importlib.metadata so pyproject.toml is the single source of truth and the two can never drift again; fall back to a source sentinel when no installed metadata is present.
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.
codegraph/__init__.pyhardcoded__version__separately frompyproject.toml. The 0.5.0 bump only touched pyproject (and the release workflow only verifies the tag against pyproject), so published 0.5.0 self-reports as0.4.6in itscgh --version/ banner.Fix: read the version from
importlib.metadata.version("cgh")so pyproject.toml is the single source of truth and the two can never drift again. Falls back to0.0.0+sourcewhen run from a tree with no installed metadata.Verified:
uv run python -c "import codegraph; print(codegraph.__version__)"->0.5.0. This needs a patch release (0.5.1) to correct the banner on PyPI.