Refactor find_uv_bin and add a better error message#14182
Merged
Conversation
db356ab to
6956f7e
Compare
6956f7e to
88146e8
Compare
37cc3c0 to
ef649ba
Compare
zanieb
added a commit
that referenced
this pull request
Aug 7, 2025
Adds test cases to unblock - #14181 - #14182 - #14184 - #14184 - tox-dev/pre-commit-uv#70 We use a package with a symlink to the Python module to get a mock installation of uv without building (or packaging) the uv binary. This lets us test real patterns like `uv pip install --prefix` without encoding logic about where things are placed during those installs. --------- Co-authored-by: konstin <konstin@mailbox.org>
ef649ba to
82d52db
Compare
82d52db to
7d5595f
Compare
e875b9d to
16ce3d6
Compare
31fc441 to
2bd9a39
Compare
zanieb
commented
Aug 7, 2025
Comment on lines
+603
to
+624
| // Add filtering for the bin directory of the base interpreter path | ||
| let bin_dir = if cfg!(windows) { | ||
| // On Windows, the Python executable is in the root, not the bin directory | ||
| executable | ||
| .canonicalize() | ||
| .unwrap() | ||
| .parent() | ||
| .unwrap() | ||
| .join("Scripts") | ||
| } else { | ||
| executable | ||
| .canonicalize() | ||
| .unwrap() | ||
| .parent() | ||
| .unwrap() | ||
| .to_path_buf() | ||
| }; | ||
| filters.extend( | ||
| Self::path_patterns(bin_dir) | ||
| .into_iter() | ||
| .map(|pattern| (pattern.to_string(), format!("[PYTHON-BIN-{version}]"))), | ||
| ); |
Member
Author
There was a problem hiding this comment.
This is new, the rest is just moved up to ensure it comes first in the filter order.
woodruffw
approved these changes
Aug 7, 2025
zanieb
added a commit
that referenced
this pull request
Aug 7, 2025
#14184) Follows #14182 Adds support for the case described at #10194 (comment) This also happens to fix both `--with` requirement test cases, which should close tox-dev/pre-commit-uv#70
konstin
reviewed
Aug 8, 2025
| raise FileNotFoundError(path) | ||
| raise UvNotFound( | ||
| f"Could not find the uv binary in any of the following locations:\n" | ||
| f"{os.linesep.join(f' - {target}' for target in seen)}\n" |
Member
There was a problem hiding this comment.
Why are we using both os.linesep and \n in the same message?
Member
Author
There was a problem hiding this comment.
Confused this isn't rendered in the snapshots?
Member
Author
There was a problem hiding this comment.
Oh, that's just a trailing newline. This was just easier than writing a literal \n inside the f-string? Do you want me to use linesep everywhere?
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.
Follows #14181
Two goals here