fix(packaging): read __version__ from installed metadata and pin documented install to Python 3.12 - #255
Conversation
WalkthroughCLI installation documentation and drift tests now specify Python 3.12. Runtime version reporting reads installed distribution metadata with a source fallback. Dev wheel stamping updates only ChangesVersion and installation updates
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1⚔️ Resolve merge conflicts 💡
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/release/set_dev_wheel_version.py`:
- Around line 81-84: Enforce the canonical `nemo-switchyard` distribution name
in the release version-update flow around `update_pyproject`: reject any
`--package-name` value that differs from `nemo-switchyard` before performing
runtime version lookups or file updates. Preserve the existing behavior for the
canonical name and cover the rejection path in the relevant tests.
In `@switchyard/__init__.py`:
- Around line 205-208: Add an explicit str annotation for the public module
attribute __version__ before the try block, while preserving its existing
assignments from _metadata.version and the fallback value in both exception
branches.
In `@tests/test_version_package_name.py`:
- Around line 45-53: Add a pytest test alongside
test_dunder_version_matches_installed_metadata that uses pytest-mock to patch
switchyard._metadata.version to raise PackageNotFoundError, reloads switchyard,
and asserts __version__ equals "0.0.0+unknown". Remove the no-cover exemption
from the source-tree fallback in switchyard.__init__.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 8dc82152-2e86-4d5e-bc77-47ca2a18473c
📒 Files selected for processing (9)
README.mddocs/cli_reference.mddocs/getting_started.mdscripts/release/set_dev_wheel_version.pyswitchyard/__init__.pytests/getting_started/test_getting_started.pytests/readme/test_readme.pytests/test_dev_wheel_versioning.pytests/test_version_package_name.py
💤 Files with no reviewable changes (1)
- tests/test_dev_wheel_versioning.py
bc6acec to
d013070
Compare
|
6f10bb8 to
4abf21a
Compare
…mented install to Python 3.12 Signed-off-by: Elyas Mehtabuddin <emehtabuddin@nvidia.com>
4abf21a to
8fb26d3
Compare
The package reports two different versions:
switchyard/__init__.pycontains its own version literal, while wheel metadata reads theversion from
pyproject.toml. A release update can change one copy and leave the other behind.The documented tool install has a separate packaging problem:
uv tool install "nemo-switchyard[cli,server]"When the default interpreter is Python 3.11, uv rejects the install:
Fix
switchyard.__version__now reads the installednemo-switchyardmetadata. When no installedmetadata exists, it returns
0.0.0+unknowninstead of an unrelated release number.The dev-wheel helper now writes only
pyproject.toml. It rejects any distribution name otherthan
nemo-switchyardbefore changing the file, because runtime version readers use that publicdistribution name. The README and installation guides now select Python 3.12 explicitly.
Evidence
Clean installs on Python 3.12 and 3.14 report the same value from both readers:
An invalid release-helper name returns exit code 2 before
pyproject.tomlchanges:No performance behavior changes in this PR.
How tested
uv run pytest tests/test_dev_wheel_versioning.py tests/test_version_package_name.py -vThe tests cover installed metadata, missing metadata, the canonical dev-wheel name, and rejection
of another package name without changing
pyproject.toml. The clean-package import check also ranwith Python 3.12 and Python 3.14.
Compatibility
switchyard.__version__remains a string. Official release and dev-wheel builds still usenemo-switchyard; passing another name to the internal release helper now returns an error.