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
17 changed files with 366 additions and 16 deletions

View File

@@ -52,16 +52,20 @@ This behavior can be
### Python version files
The `.python-version` file can be used to create a default Python version request. uv searches for a
`.python-version` file in the working directory and each of its parents. Any of the request formats
described above can be used, though use of a version number is recommended for interoperability with
other tools.
`.python-version` file in the working directory and each of its parents. If none is found, uv will
check the user-level configuration directory. Any of the request formats described above can be
used, though use of a version number is recommended for interoperability with other tools.
A `.python-version` file can be created in the current directory with the
[`uv python pin`](../reference/cli.md/#uv-python-pin) command.
A global `.python-version` file can be created in the user configuration directory with the
[`uv python pin --global`](../reference/cli.md/#uv-python-pin) command.
Discovery of `.python-version` files can be disabled with `--no-config`.
uv will not search for `.python-version` files beyond project or workspace boundaries.
uv will not search for `.python-version` files beyond project or workspace boundaries (with the
exception of the user configuration directory).
## Installing a Python version