-
Notifications
You must be signed in to change notification settings - Fork 605
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
Add uv python pin
#4950
Add uv python pin
#4950
Conversation
2f4fddc
to
821ded2
Compare
c1c1d8a
to
492465d
Compare
8a4d2f1
to
72c3bef
Compare
Is |
I believe some tools will parse it, yes, but I'm not sure which. For most uses, we'll be writing a simple version. It may be fair to say if you go outside that it'll only be supported by us. We could also consider only supporting writing simple versions until we have |
I'll do some research, but this might just be a caveat in the documentation? |
A brief Google search makes it look like just pyenv. |
Mise also parses it and Rye does too IIRC. |
So what are you thinking? What does mise do if it's not in the format it expects? |
I'm not certain, I can test it out. |
Actually, it looks like mise uses |
It looks like if Rye doesn't recognize it, it just gets ignored. |
It just uses this: /// Return the [`PythonVersionRequest`] from a `.python-version` file.
fn read_python_version(contents: &str) -> Option<PythonVersionRequest> {
// Skip empty lines and comments.
let ver = contents.lines().find(|line| {
let trimmed = line.trim();
!(trimmed.is_empty() || trimmed.starts_with('#'))
})?;
// Parse the version.
let ver = ver.parse().ok()?;
Some(ver)
} |
Thanks for checking! I think I'd prefer to support the full syntax of Python requests we support (e.g., it makes sense to allow pinning to |
8e0be49
to
d25e756
Compare
Adds a
uv python pin
command to write to a.python-version
file.We support all of our Python version request formats. We also support a
--resolved
flag to pin to a specific interpreter instead of the provided version. We canonicalize the request with #4949, it's not just printed verbatim. We always attempt to find the interpreter so we can warn if it's not available. With--resolved
, if we can't find the interpreter we fail. If no arguments are provided, we'll attempt to display the current pin.In the future:
Requires-Python
metadata if apyproject.toml
is presentuv.python-version
field ifpyproject.toml
oruv.toml
are present