Skip to content

Comments

Add support for --upgrade in uv python install#16676

Merged
zanieb merged 2 commits intomainfrom
zb/install-upgrade
Nov 13, 2025
Merged

Add support for --upgrade in uv python install#16676
zanieb merged 2 commits intomainfrom
zb/install-upgrade

Conversation

@zanieb
Copy link
Member

@zanieb zanieb commented Nov 10, 2025

This allows us to suggest uv python install --upgrade 3.14 as the canonical way to get the latest patch version of a given Python regardless of whether it is installed already. Currently, you can do uv python upgrade 3.14 and it will install it, but I'd like to remove that behavior as I find it very surprising.

@zanieb zanieb added the cli Related to the command line interface label Nov 10, 2025
@zanieb zanieb force-pushed the zb/install-upgrade branch from 46ab81a to 8231be2 Compare November 10, 2025 23:40
@zanieb zanieb temporarily deployed to uv-test-registries November 10, 2025 23:42 — with GitHub Actions Inactive
@zanieb zanieb force-pushed the zb/install-upgrade branch from 8231be2 to 1adb859 Compare November 11, 2025 00:20
@zanieb zanieb temporarily deployed to uv-test-registries November 11, 2025 00:22 — with GitHub Actions Inactive
@zanieb zanieb force-pushed the zb/install-upgrade branch from 1adb859 to 8196e5c Compare November 11, 2025 17:15
@zanieb zanieb temporarily deployed to uv-test-registries November 11, 2025 17:17 — with GitHub Actions Inactive
@zanieb zanieb marked this pull request as ready for review November 11, 2025 17:19
@zanieb zanieb added the preview Experimental behavior label Nov 11, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 11, 2025

CodSpeed Performance Report

Merging #16676 will not alter performance

Comparing zb/install-upgrade (7b05e36) with main (e28dc62)

Summary

✅ 6 untouched

@zanieb zanieb requested a review from konstin November 12, 2025 13:55
.with_managed_python_dirs();

// Provide `--upgrade` as an `install` option without any versions
uv_snapshot!(context.filters(), context.python_install().arg("--upgrade"), @r"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks. I'll look into that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might just need to be a hint when the request comes from a .python-version file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A hint would do it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I might expect this to error asking for a request? but you're right the message should change if we don't.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Banning uv python install --upgrade without a python input from anywhere sounds good to me.

@zanieb zanieb force-pushed the zb/install-upgrade branch from 8196e5c to 7b05e36 Compare November 13, 2025 14:32
@zanieb zanieb temporarily deployed to uv-test-registries November 13, 2025 14:36 — with GitHub Actions Inactive
@zanieb zanieb merged commit f5ce5b4 into main Nov 13, 2025
100 checks passed
@zanieb zanieb deleted the zb/install-upgrade branch November 13, 2025 15:55
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Nov 18, 2025
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` ([#&#8203;16473](astral-sh/uv#16473))
- Enforce UTF‑8-encoded license files during `uv build` ([#&#8203;16699](astral-sh/uv#16699))
- Error when a `project.license-files` glob matches nothing ([#&#8203;16697](astral-sh/uv#16697))
- `pip install --target` (and `sync`) install Python if necessary ([#&#8203;16694](astral-sh/uv#16694))
- Account for `python_downloads_json_url` in pre-release Python version warnings ([#&#8203;16737](astral-sh/uv#16737))
- Support HTTP/HTTPS URLs in `uv python --python-downloads-json-url` ([#&#8203;16542](astral-sh/uv#16542))

##### Preview features

- Add support for `--upgrade` in `uv python install` ([#&#8203;16676](astral-sh/uv#16676))
- Fix handling of `python install --default` for pre-release Python versions ([#&#8203;16706](astral-sh/uv#16706))
- Add `uv workspace list` to list workspace members ([#&#8203;16691](astral-sh/uv#16691))

##### Bug fixes

- Don't check file URLs for ambiguously parsed credentials ([#&#8203;16759](astral-sh/uv#16759))

##### Documentation

- Add a "storage" reference document ([#&#8203;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=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to the command line interface preview Experimental behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants