-
Notifications
You must be signed in to change notification settings - Fork 760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search for all python3.x
in PATH
#5148
Conversation
Search for all `python3.x` minor versions, skipping those we already know we can use. For example. let's say `python` and `python3` are Python 3.10. When a user requests `>= 3.11`, we still need to find a `python3.12` in PATH. Fixes #4709
crates/uv-python/src/discovery.rs
Outdated
// Filter out interpreter we already know have a too low minor version. | ||
let minor = path | ||
.file_name() | ||
.and_then(|filename| filename.to_str()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's silly we can't use capture groups for this but the which
api is too locked down for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we should just not use which
and we should iterate over the executables in the directory manually. A regex feels heavier than it needs to be. Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an implementation i used to have (without which
it's much better than the current one), but it failed because which
doesn't expose Checker
so we'd have to vendor that code from them to check whether we can use a specific file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with vendoring that code if you are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added is_executable
Thanks for tackling this one! |
Should we be using a regex at all now? Or can we just use some simple string parsing? |
I find the regex easier to follow along |
I worry a bit about performance since this isn't included in any benchmarks, but trust your intuition on it. |
I'm confident that the regex is fast. Andrew has done great performance work there :) |
@BurntSushi notorious for writing slow code hehe |
In terms of perf, this is also including regex compilation, which is definitely not known for being fast. This might actually be a case where I don't mean to suggest anything should change though. I wouldn't be surprised if the perf difference was marginal. |
Search for all
python3.x
minor versions in PATH, skipping those we already know we can use.For example, let's say
python
andpython3
are Python 3.10. When a user requests>= 3.11
, we still need to find apython3.12
in PATH. We do so with a regex matcher.Fixes #4709