fix: read __version__ from package metadata + bump to 0.1.0rc2#41
Merged
Conversation
codegraph.__version__ was hardcoded to "0.0.1" and drifted from the actual
published wheel — 0.1.0rc1 on TestPyPI exposed the gap during the dry-run
smoke (`from codegraph import __version__` returned "0.0.1" while the
installed package metadata correctly said 0.1.0rc1).
Switches __init__.py to read from importlib.metadata.version("polycodegraph")
so the in-Python version attribute auto-syncs with pyproject.toml forever.
Falls back to "0.0.0+local" only in the corner case of a source checkout
without any install (real dev workflows use `pip install -e .` which
registers the package metadata).
Also adds a regression test (test_version_matches_package_metadata) that
locks the auto-sync in place — re-hardcoding the version will now fail CI
immediately.
Bumps pyproject 0.1.0rc1 → 0.1.0rc2 to land this fix in a fresh TestPyPI
dry-run before the real v0.1.0 publish.
codegraph PR reviewDiff vs main · severity ≤
|
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Caught during the v0.1.0rc1 TestPyPI smoke: `from codegraph import version`
returned `"0.0.1"` while the installed wheel was `0.1.0rc1`. The hardcoded
string in `codegraph/init.py` had drifted from pyproject — and would
have drifted again on every future bump.
Replaces the hardcoded literal with `importlib.metadata.version("polycodegraph")`,
so the in-Python attribute auto-syncs with pyproject.toml forever.
Changes
to `"0.0.0+local"` only in the (unusual) case of a source checkout with
no install — every `pip install` / `pip install -e .` path registers
metadata.
locks the auto-sync in. If someone re-hardcodes the version, CI fails
immediately with a clear message.
the fix on TestPyPI before the v0.1.0 final tag.
Local verification
```
$ python -c "from codegraph import version; print(version)"
0.1.0rc2
$ ruff check codegraph tests
All checks passed!
$ pytest -q
596 passed in 9.69s
```
What's next after merge