Add support for global uv python pin (#12115)

These changes add support for

```
uv python pin 3.12 --global 
```

This adds the specified version to a `.python-version` file in the
user-level config directory. uv will now use the user-level version as a
fallback if no version is found in the project directory or its
ancestors.

Closes #4972
This commit is contained in:
John Mumm 2025-03-13 13:48:37 +01:00 committed by GitHub
parent b4eabf9a61
commit 797f1fbac0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 366 additions and 16 deletions

View file

@ -4676,6 +4676,19 @@ pub struct PythonPinArgs {
/// `requires-python` constraint.
#[arg(long, alias = "no-workspace")]
pub no_project: bool,
/// Update the global Python version pin.
///
/// Writes the pinned Python version to a `.python-version` file in the uv user configuration
/// directory: `XDG_CONFIG_HOME/uv` on Linux/macOS and `%APPDATA%/uv` on Windows.
///
/// When a local Python version pin is not found in the working directory or an ancestor
/// directory, this version will be used instead.
///
/// Unlike local version pins, this version is used as the default for commands that mutate
/// global state, like `uv tool install`.
#[arg(long)]
pub global: bool,
}
#[derive(Args)]