Add support for --upgrade in uv python install#16676
Conversation
46ab81a to
8231be2
Compare
8231be2 to
1adb859
Compare
1adb859 to
8196e5c
Compare
CodSpeed Performance ReportMerging #16676 will not alter performanceComparing Summary
|
| .with_managed_python_dirs(); | ||
|
|
||
| // Provide `--upgrade` as an `install` option without any versions | ||
| uv_snapshot!(context.filters(), context.python_install().arg("--upgrade"), @r" |
There was a problem hiding this comment.
Upgrade without an explicit version has a quirk: When pinning a patch version in .python_versions, it errors. I expect that some users will do uv python install --upgrade by default because they want to have the latest patch version, and will get confused by this too, especially when they don't realize that there's a .python_versions.
$ uv python install --upgrade
error: `uv python install --upgrade` only accepts minor versions, got: 3.14.0
There's a workflow that's between uv python install and uv python upgrade: I want to install Python at the version that the project requires, upgraded to the latest patch version if not already at that, unless the project pins a patch version. Trying to emulate that with uv python install --upgrade can lead to the error above.
There was a problem hiding this comment.
Ah thanks. I'll look into that.
There was a problem hiding this comment.
I think it might just need to be a hint when the request comes from a .python-version file?
There was a problem hiding this comment.
I think we can do even better, but I'll plan to do that in a follow-up.
| "There are no installed versions to upgrade" | ||
| )?; | ||
| } | ||
| PythonUpgrade::Enabled(PythonUpgradeSource::Install) => { |
There was a problem hiding this comment.
Review note: This is reachable by creating an empty .python_versions file (unlike the branch above, which by default looks at installed Pythons)
| ----- stderr ----- | ||
| Installed Python 3.14.0 in [TIME] | ||
| + cpython-3.14.0-[PLATFORM] (python3.14) | ||
| "); |
There was a problem hiding this comment.
Another quirk: The output log for plain without any pin is the same with and without upgrade. I'd have expected something like "latest patch version Python 3.14.0 is already installed".
$ uv python install
Python is already installed. Use `uv python install <request>` to install another version.
$ uv python install --upgrade
Python is already installed. Use `uv python install <request>` to install another version.
Similar to what an explicit request tells you:
$ uv python install --upgrade 3.14
Python 3.14 is already on the latest supported patch release
It's pre-existing, but it would also be nice if uv python install and uv python install --upgrade 3.14 would tell me the version that is installed that they consider latest.
There was a problem hiding this comment.
I think I might expect this to error asking for a request? but you're right the message should change if we don't.
There was a problem hiding this comment.
Banning uv python install --upgrade without a python input from anywhere sounds good to me.
8196e5c to
7b05e36
Compare
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.9.9` -> `0.9.10` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>astral-sh/uv (astral-sh/uv)</summary> ### [`v0.9.10`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0910) [Compare Source](astral-sh/uv@0.9.9...0.9.10) Released on 2025-11-17. ##### Enhancements - Add support for `SSL_CERT_DIR` ([#​16473](astral-sh/uv#16473)) - Enforce UTF‑8-encoded license files during `uv build` ([#​16699](astral-sh/uv#16699)) - Error when a `project.license-files` glob matches nothing ([#​16697](astral-sh/uv#16697)) - `pip install --target` (and `sync`) install Python if necessary ([#​16694](astral-sh/uv#16694)) - Account for `python_downloads_json_url` in pre-release Python version warnings ([#​16737](astral-sh/uv#16737)) - Support HTTP/HTTPS URLs in `uv python --python-downloads-json-url` ([#​16542](astral-sh/uv#16542)) ##### Preview features - Add support for `--upgrade` in `uv python install` ([#​16676](astral-sh/uv#16676)) - Fix handling of `python install --default` for pre-release Python versions ([#​16706](astral-sh/uv#16706)) - Add `uv workspace list` to list workspace members ([#​16691](astral-sh/uv#16691)) ##### Bug fixes - Don't check file URLs for ambiguously parsed credentials ([#​16759](astral-sh/uv#16759)) ##### Documentation - Add a "storage" reference document ([#​15954](astral-sh/uv#15954)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNzMuMSIsInVwZGF0ZWRJblZlciI6IjQxLjE3My4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
This allows us to suggest
uv python install --upgrade 3.14as the canonical way to get the latest patch version of a given Python regardless of whether it is installed already. Currently, you can douv python upgrade 3.14and it will install it, but I'd like to remove that behavior as I find it very surprising.