Add --rename-dep option to rename dependencies in wheels#3
Open
Add --rename-dep option to rename dependencies in wheels#3
Conversation
When renaming a package that depends on another package that also needs renaming, the new --rename-dep option updates both the METADATA (Requires-Dist) and Python import statements. Example: spare-tire rename mydep-1.0.0.whl mydep_v1 spare-tire rename mypkg-1.0.0.whl mypkg_v1 --rename-dep mydep=mydep_v1 This enables installing packages with conflicting dependencies by renaming the entire dependency tree of the older version. Changes: - Add rename_deps parameter to rename_wheel() function - Update _update_metadata() to rewrite Requires-Dist lines - Add --rename-dep CLI option (can be used multiple times) - Add test fixtures demonstrating conflicting dependency resolution - Update documentation in README.md and AGENTS.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Enhance import rewriting to also update module attribute access patterns like `zarr.open()` and `zarr.__version__` when renaming dependencies. Add real-world integration test that: - Downloads zarr v2 from PyPI and renames to zarr_v2 - Creates test packages using different zarr versions - Verifies both zarr v2 and v3 can coexist in the same environment - Confirms both can read the same Zarr format 2 data 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add section showing how to use --rename-dep to install conflicting zarr versions (v2 and v3) in the same environment. Also add README to the zarr-compat test fixture with usage instructions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update rename_wheel_from_bytes to support rename_deps parameter (needed for proxy server to support dependency renaming) - Add TestDependencyRenaming class with 4 pytest tests: - test_rename_deps_updates_metadata - test_rename_deps_updates_imports - test_rename_multiple_deps - test_rename_deps_with_extras 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Summary
Add the ability to rename dependencies when renaming a wheel, enabling installation of packages with conflicting dependency trees.
New Features
--rename-depCLI option: Rename dependencies in the wheel's METADATA and Python imports--python-versionoption for download: Specify target Python version when downloading wheels (useful withuvx)Module attribute rewriting: Import rewriting now handles
pkg.attrpatterns (e.g.,zarr.open()→zarr_v2.open())rename_wheel_from_bytessupport: The bytes-based API now supportsrename_depsfor proxy server useUse Case: Conflicting Dependencies
When two versions of a package require incompatible versions of the same dependency:
Now both work in the same Python session:
Testing
tests/fixtures/conflicting-deps/): Synthetic test with mypkg/mydeptests/fixtures/zarr-compat/): Real-world test downloading zarr v2 from PyPI, renaming to zarr_v2, and verifying both zarr v2 and v3 can read the same Zarr format 2 dataRun the zarr test:
Files Changed
src/spare_tire/rename.py- Addrename_depsparameter to both rename functions, enhance import rewritingsrc/spare_tire/download.py- Addpython_versionparametersrc/spare_tire/cli.py- Add--rename-depand--python-versionoptionstests/test_integration.py- AddTestDependencyRenamingclass with 4 testsREADME.md- Document new features with examplesAGENTS.md- Update function signaturestests/fixtures/conflicting-deps/- Synthetic dependency conflict testtests/fixtures/zarr-compat/- Real zarr v2/v3 compatibility test