Skip to content

Make uv pip compile attempt to download a specified --python-version if it can.#17249

Merged
EliteTK merged 18 commits intomainfrom
tk/pip-compile-missing-py-4
Jan 16, 2026
Merged

Make uv pip compile attempt to download a specified --python-version if it can.#17249
EliteTK merged 18 commits intomainfrom
tk/pip-compile-missing-py-4

Conversation

@EliteTK
Copy link
Contributor

@EliteTK EliteTK commented Dec 29, 2025

Summary

Addresses #16709. Now specifying a simple version with --python or specifying a version using --python-version will result in the specified version getting downloaded with a fallback to the previous behaviour if the download fails for some transient reason or if downloads are disabled.

The behaviour of how --python gets treated as --python-version, if a "simple version" is specified, is kept. This means that --python 3.7 turns into a soft requirement. This seems at odds with how other similar parts of UV work, but there seem to be quite a few tests which test for this specific behaviour and I think this is best saved for a separate issue.

Test Plan

I added a test case which would previously fall back to the default interpreter and warn about it.

@EliteTK EliteTK added the enhancement New feature or improvement to existing functionality label Dec 29, 2025
@EliteTK EliteTK temporarily deployed to uv-test-registries December 29, 2025 13:01 — with GitHub Actions Inactive
@EliteTK EliteTK requested a review from zanieb December 29, 2025 13:05
@EliteTK EliteTK temporarily deployed to uv-test-publish January 14, 2026 16:15 — with GitHub Actions Inactive
@EliteTK EliteTK temporarily deployed to uv-test-registries January 14, 2026 16:15 — with GitHub Actions Inactive
@EliteTK
Copy link
Contributor Author

EliteTK commented Jan 14, 2026

Heh... I just realised, what about if there's no default python version? We should probably also attempt to download in that final case too...

Most likely the reason will cause this one to fail too and handling the
alternative case could add a delay (e.g. if it's a network failure
which ends with retries and a timeout).
@zanieb
Copy link
Member

zanieb commented Jan 14, 2026

Yeah that makes sense

@EliteTK EliteTK temporarily deployed to uv-test-publish January 14, 2026 19:53 — with GitHub Actions Inactive
@EliteTK EliteTK temporarily deployed to uv-test-publish January 14, 2026 20:59 — with GitHub Actions Inactive
@EliteTK
Copy link
Contributor Author

EliteTK commented Jan 14, 2026

Okay, I've refactored it all a little bit. Maybe the refactoring should have come first... Not sure.

Let me know what you think.

@EliteTK EliteTK requested a review from zanieb January 14, 2026 21:09
@EliteTK
Copy link
Contributor Author

EliteTK commented Jan 15, 2026

Should probably do something similar to #17461 too...

@zanieb
Copy link
Member

zanieb commented Jan 15, 2026

I wouldn't increase the scope here :)

----- stdout -----

----- stderr -----
warning: A managed Python download is available for Python 3.10, but an error occurred when attempting to download it: Failed to download https://github.com/astral-sh/python-build-standalone/releases/download/[FILE-PATH]
Copy link
Member

Choose a reason for hiding this comment

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

The attached error is worthless. I think we need to render the chain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I was curious about your opinion on this. I'll render the chain. Do you know off the top of your head if we do that somewhere else already? (I know how to do it, the anyhow docs have a good example (even if this isn't an anyhow error))

Copy link
Member

Choose a reason for hiding this comment

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

uv-warnings::write_error_chain

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

I'm not too sure about this formatting...

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't you be creating a fake top-level error so it's all one chain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't think of that... But the bold would be gone, it would look different to the warning below.

Still... Probably a neater look overall. Will sort it tomorrow.

Copy link
Member

Choose a reason for hiding this comment

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

I think that sounds like a bug in the warning chain print? Should it be bolding the first error in warnings for parity?

@EliteTK EliteTK temporarily deployed to uv-test-publish January 15, 2026 18:26 — with GitHub Actions Inactive
@EliteTK EliteTK force-pushed the tk/pip-compile-missing-py-4 branch from b0133d4 to 9e29d97 Compare January 15, 2026 18:31
@EliteTK EliteTK temporarily deployed to uv-test-publish January 16, 2026 13:39 — with GitHub Actions Inactive
@EliteTK EliteTK force-pushed the tk/pip-compile-missing-py-4 branch from 4e110e9 to 8ac4906 Compare January 16, 2026 13:50
@EliteTK EliteTK enabled auto-merge (squash) January 16, 2026 13:53
@EliteTK EliteTK merged commit f7d1215 into main Jan 16, 2026
52 checks passed
@EliteTK EliteTK deleted the tk/pip-compile-missing-py-4 branch January 16, 2026 14:01
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jan 27, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.9.26` → `0.9.27` |

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.27`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0927)

[Compare Source](astral-sh/uv@0.9.26...0.9.27)

Released on 2026-01-26.

##### Python

- Upgrade Pyodide to 0.29.2 ([#&#8203;17652](astral-sh/uv#17652))
- Upgrade to GraalPy 25.0.2 ([#&#8203;17634](astral-sh/uv#17634))

##### Enhancements

- Add `-t` shortform for `--target` to `uv pip` subcommands ([#&#8203;17501](astral-sh/uv#17501))
- Add support for ROCm 7.0 and 7.1 accelerator backends ([#&#8203;17681](astral-sh/uv#17681))
- Further improve free-threading ABI incompatibility errors ([#&#8203;17491](astral-sh/uv#17491))
- Implement `uv pip freeze --exclude` flag ([#&#8203;17045](astral-sh/uv#17045))
- Improve warnings for `--system` and `--no-system` in `uv venv` ([#&#8203;17647](astral-sh/uv#17647))
- Make `uv pip compile` attempt to download a specified `--python-version` if it can. ([#&#8203;17249](astral-sh/uv#17249))
- Support Trusted Publishing with pyx ([#&#8203;17438](astral-sh/uv#17438))
- Fix JSON schema for `exclude-newer-package` ([#&#8203;17665](astral-sh/uv#17665))

##### Preview features

- Better detection for conflicting packages ([#&#8203;17623](astral-sh/uv#17623))
- Upgrade based on outdated build versions in `uv python upgrade` ([#&#8203;17653](astral-sh/uv#17653))

##### Bug fixes

- Change chocolatey system test to ensure uv uses the right python ([#&#8203;17533](astral-sh/uv#17533))
- Fix infinite loop when `SSL_CERT_FILE` is a directory ([#&#8203;17503](astral-sh/uv#17503))

##### Documentation

- Add cargo-xwin to the CONTRIBUTING guide ([#&#8203;17507](astral-sh/uv#17507))
- Fix typo in the documentation of UV\_PUBLISH\_INDEX ([#&#8203;17672](astral-sh/uv#17672))
- Move MSRV to platform support section ([#&#8203;17534](astral-sh/uv#17534))
- Update the testing instructions in the CONTRIBUTING guide ([#&#8203;17528](astral-sh/uv#17528))
- Use `--locked` to install `cargo-xwin` in guide ([#&#8203;17530](astral-sh/uv#17530))
- Warn about PyPy being unmaintained ([#&#8203;17643](astral-sh/uv#17643))
- docs: Correct gitlab-ci.yml to .gitlab-ci.yml ([#&#8203;17682](astral-sh/uv#17682))

##### Other changes

- Update MSRV to 1.91 ([#&#8203;17677](astral-sh/uv#17677))

</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:eyJjcmVhdGVkSW5WZXIiOiI0Mi45Mi40IiwidXBkYXRlZEluVmVyIjoiNDIuOTIuNCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6OnBhdGNoIl19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants