Files
uv/crates/uv-python
Zanie Blue 4ae86f9b0a Respect global Python version pins in uv tool run and uv tool install (#14112)
Closes #12921

For `uv tool run`, we'll just use the global Python version for all
invocations without an explicit alternative request (i.e., via the
`--python` flag).

For `uv tool install`, it's a bit more complicated:

- If the tool is not installed, we'll use the global Python version
- If the tool is already installed, we won't change the Python version
unless `--reinstall` or `--python` is used
- If the tool was installed with `--python`, we won't use the global
Python version, unless the tool is uninstalled first

The behavior can be demonstrated as follows

```
$ uv python pin --global 3.12
$ uv tool install flask  # uses 3.12
$ uv tool install flask  # no-op
$ uv python pin --global 3.13
$ uv tool install flask  # no-op
$ uv tool install flask --reinstall  # uses 3.13
$ uv tool install flask -p 3.12 # uses 3.12
$ uv tool install flask  # no-op
$ uv tool install flask --reinstall # uses 3.12
```

This is a little more complicated than always reinstalling when the
global Python version pin changes, but I think it's probably more
intuitive when actually using the tool. We briefly touched on this when
adding global version pins at
https://github.com/astral-sh/uv/pull/12115#discussion_r1992222278

Minor note: I need to do a self-review of this implementation, as it's a
little awkward to encode this behavior in the existing logic.
2026-02-05 11:52:18 -06:00
..
2025-12-04 10:18:41 +01:00
2026-02-04 21:18:04 +00:00
2026-02-04 21:18:04 +00:00

uv-python

This crate is an internal component of uv. The Rust API exposed here is unstable and will have frequent breaking changes.

This version (0.0.19) is a component of uv 0.9.30. The source can be found here.

See uv's crate versioning policy for details on versioning.