CALUNGA-283 - Add combined venv fallback for cross-package import testing#294
CALUNGA-283 - Add combined venv fallback for cross-package import testing#294smatula wants to merge 1 commit into
Conversation
Some wheels fail to import individually because they depend on sibling packages at import time (e.g. sphinxcontrib needs sphinx/docutils). This adds a combined venv fallback that re-tests all importable wheels in a single shared environment when individual testing has failures. The fallback uses tiered installs to handle multiple versions of the same package, with post-install version verification to prevent false positives when pip resolves a different version via dependency resolution. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reviewer's GuideAdds a two-phase wheel import test: phase 1 runs existing per-wheel venv tests while tracking importable wheels and failures; phase 2 introduces a combined-venv fallback that re-tests importable wheels together using tiered installs to handle multiple versions and verifies installed versions, with separate combined-venv reporting and updated final result messaging. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The wheel filename parsing for package name and version (splitting on
-and doing customsort_key) is fairly ad‑hoc and may mis-handle PEP 440 edge cases (e.g. local versions, pre/post releases); consider usingpackaging.version.Versionandpackaging.utils.canonicalize_name(or a small helper) to make tier grouping and version comparison more robust. - The logic that derives
PKG_NAMEfrom the wheel filename (name.split('-')[0].lower().replace('_','-')) assumes the distribution name has no dashes in it; if this runs against wheels with multiple-segments in the name, the combined venv verification could target the wrong package, so it might be safer to reuse the same name parsing helper you use for tiering or a PEP 427/440-aware parser.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The wheel filename parsing for package name and version (splitting on `-` and doing custom `sort_key`) is fairly ad‑hoc and may mis-handle PEP 440 edge cases (e.g. local versions, pre/post releases); consider using `packaging.version.Version` and `packaging.utils.canonicalize_name` (or a small helper) to make tier grouping and version comparison more robust.
- The logic that derives `PKG_NAME` from the wheel filename (`name.split('-')[0].lower().replace('_','-')`) assumes the distribution name has no dashes in it; if this runs against wheels with multiple `-` segments in the name, the combined venv verification could target the wrong package, so it might be safer to reuse the same name parsing helper you use for tiering or a PEP 427/440-aware parser.
## Individual Comments
### Comment 1
<location path="tasks/install-and-import-wheels.yaml" line_range="581-583" />
<code_context>
+ # actually installed. If pip resolved a different version
+ # (e.g. via dependency resolution), carry over the individual
+ # phase result instead of testing the wrong version.
+ EXPECTED_VER=$(python3.12 -c "from pathlib import PurePosixPath; print(PurePosixPath('${WHEEL}').name.split('-')[1])")
+ PKG_NAME=$(python3.12 -c "from pathlib import PurePosixPath; print(PurePosixPath('${WHEEL}').name.split('-')[0].lower().replace('_', '-'))")
+ INSTALLED_VER=$(/tmp/test-venv-combined/bin/python -c "
+ from importlib.metadata import version
+ try:
</code_context>
<issue_to_address>
**issue (bug_risk):** Expected vs installed version comparison inherits the same split('-')[1] fragility and may mis-detect mismatches.
`EXPECTED_VER` is derived with `PurePosixPath(...).name.split('-')[1]`, which assumes a `name-version-...` pattern with no dashes in `name`. For projects whose names contain dashes, this will compute the wrong expected version and incorrectly report a mismatch, triggering unnecessary fallbacks.
Consider introducing a small helper that parses wheel filenames according to the wheel spec (extracting normalized project name and version), and reuse it both here and in the tier-building logic to avoid this class of bugs.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| EXPECTED_VER=$(python3.12 -c "from pathlib import PurePosixPath; print(PurePosixPath('${WHEEL}').name.split('-')[1])") | ||
| PKG_NAME=$(python3.12 -c "from pathlib import PurePosixPath; print(PurePosixPath('${WHEEL}').name.split('-')[0].lower().replace('_', '-'))") | ||
| INSTALLED_VER=$(/tmp/test-venv-combined/bin/python -c " |
There was a problem hiding this comment.
issue (bug_risk): Expected vs installed version comparison inherits the same split('-')[1] fragility and may mis-detect mismatches.
EXPECTED_VER is derived with PurePosixPath(...).name.split('-')[1], which assumes a name-version-... pattern with no dashes in name. For projects whose names contain dashes, this will compute the wrong expected version and incorrectly report a mismatch, triggering unnecessary fallbacks.
Consider introducing a small helper that parses wheel filenames according to the wheel spec (extracting normalized project name and version), and reuse it both here and in the tier-building logic to avoid this class of bugs.
|
/lgtm |
Some wheels fail to import individually because they depend on sibling packages at import time (e.g. sphinxcontrib needs sphinx/docutils). This adds a combined venv fallback that re-tests all importable wheels in a single shared environment when individual testing has failures.
The fallback uses tiered installs to handle multiple versions of the same package, with post-install version verification to prevent false positives when pip resolves a different version via dependency resolution.
Summary by Sourcery
Add a combined virtualenv fallback path to re-run wheel import tests when individual per-wheel venv testing reports failures.
Enhancements:
Tests: