uv
uv copied to clipboard
Add `uv python upgrade` and support transparent patch upgrades in virtual environments
In uv, if you install the latest managed patch version, virtual environments that were created with a minor version like 3.13 will not automatically upgrade to that patch. Currently, you’d have to manually update each virtual environment. Upgrading to a new patch version should be a smooth experience for users, ideally with virtual environments transparently upgrading.
This PR adds a new uv python upgrade subcommand. This can be used to upgrade an installed and managed python-build-standalone Python to the latest patch version:
uv python upgrade 3.12
If the minor version is omitted, uv will upgrade all (managed python-build-standalone) minor versions that are currently installed.
Transparent upgrades also apply when a newer patch is installed via a command like uv python install 3.10.17.
Transparent upgrades are accomplished using minor version symlink directories (or junctions on Windows). On Windows, a trampoline is used to simulate the full symlink.
A potential downside of the transparent upgrade approach is that breaking patch upgrades would break all transparently upgraded virtual environments. This is a rare situation, but it can be avoided altogether by pinning projects to a patch version. Upgrading does not remove the older patch versions, so pinning continues to work.
Transparent upgrades are supported for virtual environments created
- with
uv venv - with
uv run python -m venv(as long as the Python being run is managed andpython-build-standalone) - within virtual environments created in any of these ways
Virtual environments created by an earlier version of uv will continue to work as before but will not be transparently upgradeable without being recreated.
This PR includes tests for numerous scenarios using both uv python upgrade and uv python install.
This PR does not currently support transparent upgrades for the bin directory symlink created by uv python install --preview.