Preserve relative structure of transitive editables in uv pip compile#19151
Open
Aditya-PS-05 wants to merge 3 commits intoastral-sh:mainfrom
Open
Preserve relative structure of transitive editables in uv pip compile#19151Aditya-PS-05 wants to merge 3 commits intoastral-sh:mainfrom
uv pip compile#19151Aditya-PS-05 wants to merge 3 commits intoastral-sh:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect path emission for transitive editable dependencies in uv pip compile by re-anchoring relative editable paths to the output requirements file location (or working directory when emitting to stdout), preventing “Distribution not found” errors for compiled requirements.
Changes:
- Compute an “output anchor” directory for
uv pip compileoutput (output file’s directory when-ois used; otherwise the working directory). - Pass that anchor through the requirements.txt rendering pipeline to rewrite transitive editable paths based on the resolved absolute source tree.
- Add a regression test covering transitive editable path rewriting; update an existing snapshot to reflect the new anchoring behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
crates/uv/src/commands/pip/compile.rs |
Establishes and threads an output anchor directory into requirements/lock emission. |
crates/uv-resolver/src/resolution/display.rs |
Plumbs an optional anchor into requirements.txt graph display. |
crates/uv-resolver/src/resolution/requirements_txt.rs |
Rewrites editable path emission relative to the output anchor for transitive editables. |
crates/uv/tests/it/pip_compile.rs |
Adds a regression test for transitive editable relative paths and updates a snapshot expectation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
Couple of observations, neither blocking:
|
Contributor
Author
Thanks and it's done. |
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.
closes #19091
Issue: When a project that depends on a local package, and that package that depends on another local package (written in
[tool.uv.sources]). When we runuv pip compile, the transitive editable's path gets dumped intorequirements.txtexactly as it was written in the innerpyproject.tomlbut path is relative to the inner package, not to wherever we're writing therequirements.txt. So we end up with arequirements.txtthat has the wrong path and uv intall errors up with "Distribution not found."Fix: Instead of just copying the path string from the source, we take the abs path that uv already resolved internally, and convert it back into a relative path but this time relative to the dir the
requirements.txtis being written into. That way the path actually makes sense from the requirements file's point of view. I also made sure to leave absolute file URLs and env-var paths alone, since those are intentional and shouldn't be rewritten.