Commit Graph

440 Commits

Author SHA1 Message Date
Zsolt Dollenstein ce4b9a410a Fetch CPython from an Astral mirror by default (#18207) 2026-03-03 07:02:09 -05:00
Zanie Blue f5b95ba548 Fix Python version selection for scripts with a requires-python conflicting with .python-version (#18097)
See https://github.com/astral-sh/uv/issues/17717#issuecomment-3886377795

Updates `ScriptPython::from_request` to match the implementation of
`WorkspacePython::from_request` and adds filtering such that if the
`.python-version` conflicts with the `requires-python`, we prefer the
latter.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-24 05:16:48 -06:00
Zanie Blue 463a78f707 Remove the unused Error::LinkExecutable.to field (#18065)
Fixes  https://github.com/astral-sh/uv/pull/18008/changes#r2813876103
2026-02-18 09:39:44 -06:00
konsti 23234a3c03 Remove duplicate paths in managed Python errors (#18008)
Fixes https://github.com/astral-sh/uv/issues/17988
2026-02-16 17:27:50 +00:00
cui 4ce3853c52 Do not match cpython 3.10 for cpython-3.1 (#17972)
<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->
bug fix, in find version 3.1 should not match 3.10

## Test Plan

<!-- How was it tested? -->

---------

Co-authored-by: konstin <konstin@mailbox.org>
Co-authored-by: Zanie Blue <contact@zanie.dev>
2026-02-12 17:46:40 +00:00
Zanie Blue 33a8132b87 Fix handling of --allow-existing with minor version links on Windows (#17978)
Closes #17963
2026-02-12 11:30:36 -06:00
Jonathan J. Helmus 6663f8899d Add CPython 3.15.0a6 (#17987)
Update available python versions to include CPython 3.15.0a6
Update scripts used to sync pbs releases to account for recent changes
in the repo and to support running on macOS.
2026-02-12 11:23:41 -06:00
William Woodruff 471137f5b2 Deprecate unexpected ZIP compression methods (#17946) 2026-02-10 12:46:30 -05:00
William Woodruff 3876553531 Revert "Warn on unexpected ZIP compression methods" (#17944)
Reverts astral-sh/uv#17885
2026-02-09 13:53:13 -05:00
William Woodruff 5c74d31eb8 Warn on unexpected ZIP compression methods (#17885)
## Summary

This adds warnings to both our steam and sync ZIP handling on ZIP
entries that aren't "well-known." For now, "well-known" means stored
(i.e. no compression), DEFLATE, or zstd.

In practice we have duplicated codepaths for this check: one for the
"sync" (pre-downloaded) path, and one for the streaming path.

See #16911 and #17467 for context.

## Test Plan

Will update snapshots if/when they change. I'll also add a ZIP test for
this.

(Upd: added some "futzed" wheels for the ZIP tests.)

---------

Signed-off-by: William Woodruff <william@astral.sh>
2026-02-09 12:53:15 -05:00
Zanie Blue d2ab2d0208 Stabilize Python upgrades (#17766)
Includes a few things...

- Drops preview warnings for use of `uv python upgrade` and `uv python
install --upgrade`
- Adds `--resolve-links` to `uv python find`, which I needed in test
cases to retain existing snapshots
- Fixes issues in our "Using environment ..." messages on Windows which
were incorrect
- Refactors `from_executable` for the `PythonMinorVersionLink` type
(https://github.com/astral-sh/uv/pull/17842/commits/28b2ed2525327d94fdf5372a29bbbc476d74680f)
to use the type system to prevent incorrect construction (for above)
- Removes special casing where we only upgrade links if they already
exist, which existed so preview wasn't needed on every invocation
- Fixes a bug with `PythonMinorVersionLink::exists` which returned
`true` even if the link pointed to the wrong Python installation leading
to discovery failures
2026-02-05 11:52:18 -06:00
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
Zanie Blue 3ba3fe355f Install Pyodide executables as pyodide instead of python (#17760)
Same as #17756 for pyodide
2026-02-05 11:52:18 -06:00
Zanie Blue e932c4a099 Install PyPy and GraalPy executables as pypy and graalpy instead of python (#17756)
Copy of https://github.com/astral-sh/uv/pull/14201 for
https://github.com/astral-sh/uv/pull/17661

Co-authored-by: Frazer McLean <frazer@frazermclean.co.uk>
2026-02-05 11:52:18 -06:00
github-actions[bot] 5d978e8bda Add CPython 3.14.3 and 3.13.12 (#17849)
Automated update for Python releases.

---------

Co-authored-by: jjhelmus <1050278+jjhelmus@users.noreply.github.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
2026-02-04 11:05:57 -06:00
Harsh Pratap Singh cd49736234 Ignore global Python pins when incompatible with requires-python (#15473)
<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

@zanieb in #14916 found an interesting bug. Global pin is the user
preference across projects, but if the project locally has a local pin,
it should be an authoritative constraint and end up with error. This
avoids blocking new projects that intentionally require a newer Python
version than the user’s global default. We still error on a local
`.python-version` inside the project to preserve explicit, repo-scoped
intent.

* Explicit `--python` → Always wins regardless of constraints
* Local `.python-version` → Project-scoped, errors on conflict
* Global `.python-version` → User preference, ignored if conflicts with
project. Global pins are suggestions that can be overridden by project
requirements
* Project `requires-python` → Fallback when no pins exist

Implementation :
* If a global `~/.config/uv/.python-version` conflicts with a project
`requires-python`, we ignore the pin and use the project requirement
* If a local project `.python-version` conflicts, we error, with
guidance to update the pin
* Explicit `--python` continues to override both

Now, global pins are suggestions that can be overridden by project
requirements, rather than hard constraints that block project setup.

## Test Plan

A new has been added in `sync_python_version()` along with manual
testing :
```
harshps22ugp@lab:~/projects/uv$ target/debug/uv python pin --global 3.10
Pinned `/home/harshps22ugp/.config/uv/.python-version` to `3.10`
harshps22ugp@lab:~/projects/uv$ mkdir -p /tmp/uv-global-pin && cd /tmp/uv-global-pin
harshps22ugp@lab:/tmp/uv-global-pin$ cat > pyproject.toml <<'EOF'
> [project]
> name = "project"
> version = "0.1.0"
> requires-python = ">=3.11"
> dependencies = ["anyio==3.7.0"]
> EOF
harshps22ugp@lab:/tmp/uv-global-pin$ /home/harshps22ugp/projects/uv/target/debug/uv sync
Using CPython 3.13.5
Creating virtual environment at: .venv
Resolved 4 packages in 276ms
Prepared 3 packages in 149ms
░░░░░░░░░░░░░░░░░░░░ [0/3] Installing wheels...                                                                                                               warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance.
         If the cache and target directories are on different filesystems, hardlinking may not be supported.
         If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning.
Installed 3 packages in 35ms
 + anyio==3.7.0
 + idna==3.10
 + sniffio==1.3.1
harshps22ugp@lab:/tmp/uv-global-pin$ . .venv/bin/activate
(project) harshps22ugp@lab:/tmp/uv-global-pin$ python -V
Python 3.13.5
(project) harshps22ugp@lab:/tmp/uv-global-pin$
```
No error was thrown!

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2026-02-03 16:00:50 -06:00
Zanie Blue f5fcf93deb Remove special casing for base and default conda environment names (#17758)
Under the `special-conda-env-names` preview feature, instead, just using
our path-based logic.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-01 12:09:48 +00:00
github-actions[bot] c377edcd50 Sync latest Python releases (#17726)
Pick up python-build-standalone 20260127 for OpenSSL 3.5.5.

Co-authored-by: geofft <74644+geofft@users.noreply.github.com>
2026-01-27 21:02:13 -05:00
Zanie Blue 4e13f082a8 Upgrade based on outdated build versions in uv python upgrade (#17653) 2026-01-26 15:15:30 -06:00
Tomasz Kramkowski 6e3ba2f03d Introduce PreviewFeature to clarify intent throughout the codebase (#17670)
## Summary

This PR replaces `bitflags` in favour of `enumflags2` (which we already
transitively depended on) so that `PreviewFeatures` can be replaced with
`PreviewFeature` which is an enum. This clarifies intent in cases where
we only care about one specific `PreviewFeature`.

To avoid a bunch of boilerplate changes, the `Preview` wrapper has been
kept and creation now involves a `&[PreviewFeature]` in all cases. The
alternative was to have everything which initialises a `Preview` use
`BitFlags` directly and possibly to remove `Preview` entirely but this
keeps things simpler and limits the changes throughout the rest of the
codebase solely to changes which deal with the name changes (ALL_CAPS to
PascalCase) and the impact on `--show-settings` which I don't believe we
care about stability of output for?

The changes to `--show-settings` could be avoided with some custom
`Debug` implementation but that seems excessive.

This PR will impact #16452. But the changes were inspired by trying to
remove the need for that particular PR to add more runtime type
checking.

## Test Plan

Existing tests were adjusted (I also fixed some missing cases). The test
for panicking in cases which are now prevented through the use of type
changes has been dropped. All the rest of the tests were ran, snapshot
changes reviewed and applied.
2026-01-23 17:19:23 +00:00
Zanie Blue 3e22637c93 Use #[expect(clippy::...)] throughout and drop unused supressions (#17537)
Co-authored-by: Claude <noreply@anthropic.com>
2026-01-20 21:52:06 +00:00
Tomasz Kramkowski f7d1215a98 Make uv pip compile attempt to download a specified --python-version if it can. (#17249)
## 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.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2026-01-16 14:01:56 +00:00
konsti 6db2c62906 Normalize test snapshots (#17486)
This reduces the churn when changing test snapshots, as insta updates
the quotes when the contents change. Instead, we decouple it by updating
the quotes in bulk here.

Created by:

```
cargo insta test --accept --force-update-snapshots
```
2026-01-15 17:50:10 +01:00
Luis Nell db7d1a2058 Add a hint to use a newer uv when a managed Python download is not found (#17461)
## Summary

Suggest using a newer uv version when a managed python installation request
fails with `NoDownloadFound`.

Before:

```
error: No interpreter found for Python ==3.14.* in managed installations or search path
```

After:

```
error: No interpreter found for Python ==3.14.* in managed installations or search path

hint: uv embeds available Python downloads and may require an update to install new versions. Consider retrying on a newer version of uv.
```

## Test Plan

Integration test added for this case.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2026-01-15 09:58:41 +00:00
github-actions[bot] 0c08cba0c4 Sync latest Python releases (#17480)
Automated update for Python releases.

Co-authored-by: jjhelmus <1050278+jjhelmus@users.noreply.github.com>
2026-01-15 04:21:14 +00:00
github-actions[bot] c6a02873fd Sync latest Python releases (#17445)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2026-01-13 22:01:12 +00:00
William Woodruff a27e0c850d Use Cow<str> for deserialization everywhere (#17330) 2026-01-05 17:57:35 -05:00
konsti 24cc4a789b Fix some Rust 1.92 clippy lints (#17324)
Saw this as a build failure in a CI job.

Excluding https://github.com/zkat/miette/pull/459
2026-01-05 11:11:43 +00:00
Zanie Blue 9949f0801f Respect UV_PYTHON_DOWNLOAD_MIRROR in uv python list (#16673)
Closes https://github.com/astral-sh/uv/issues/16671

Mostly authored by Claude
2025-12-18 11:29:48 -06:00
github-actions[bot] 1ddb646a74 Add CPython 3.15.0a3 (#17165)
Automated update for Python releases.

---------

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-12-18 13:15:04 +00:00
konsti e2a775d727 Use the same retry logic across uv (#17105)
We were using slightly different retry code in multiple places, this PR
unifies it.

Also fixes retry undercounting in publish if the retry middleware was
involved.

---------

Co-authored-by: Tomasz Kramkowski <tom@astral.sh>
2025-12-18 12:44:37 +00:00
konsti 9360ca7778 Refactor uv retrayble strategy to use a single code path (#17099)
Refactoring that allows uv's retryable strategy to return
`Some(Retryable::Fatal)`, also helpful for
https://github.com/astral-sh/uv/pull/16245
2025-12-18 11:10:47 +01:00
github-actions[bot] 81c99dd438 Sync latest Python releases (#17057)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-12-09 22:30:11 +00:00
github-actions[bot] 9635258867 Sync latest Python releases (#16943)
Automated update for Python releases.

---------

Co-authored-by: jjhelmus <1050278+jjhelmus@users.noreply.github.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-12-06 00:03:57 +00:00
konsti b73281d222 Error when built wheel is for the wrong platform (#16074)
Error when a built wheel is for the wrong platform. This can happen
especially when using `--python-platform` or `--python-version` with `uv
pip install`.

Fixes #16019
2025-12-05 16:04:53 +01:00
konsti 62bf92132b Add a 5 min default timeout for deadlocks (#16342)
When a process is running and another calls `uv cache clean` or `uv
cache prune` we currently deadlock - sometimes until the CI timeout
(https://github.com/astral-sh/setup-uv/issues/588). To avoid this, we
add a default 5 min timeout waiting for a lock. 5 min balances allowing
in-progress builds to finish, especially with larger native
dependencies, while also giving timely errors for deadlocks on (remote)
systems.

Commit 1 is a refactoring.

This branch also fixes a problem with the logging where acquired and
released resources currently mismatch:

```
DEBUG Acquired lock for `https://github.com/tqdm/tqdm`
DEBUG Using existing Git source `https://github.com/tqdm/tqdm`
DEBUG Released lock at `C:\Users\Konsti\AppData\Local\uv\cache\git-v0\locks\16bb813afef8edd2`
```
2025-12-04 14:59:04 +01:00
samypr100 ed63be5dab chore(🧹): const env var usage cleanup (#16950)
## Summary

* Updates existing references to use EnvVars where usage was missing.
* Adds missing entries to env var usages, e.g. new env var declarations
in uv-trampoline, tests, etc.
* Note: this doesn't affect trampoline sizes as the end result is the
same
* Fixes versioning of `UV_HIDE_BUILD_OUTPUT`.

## Test Plan

Existing Tests. Compiled the trampolines locally to verify zero changes
(size, binary).

## Question

Will this complicate the crates publishing release process? I'm not
certain yet if it will be an issue for uv-trampoline (non-workspace
member) to reference a uv workspace member from a bump & release
perspective wrt lock files. If so, I'll revert the uv-trampoline changes
but keep the others.
2025-12-02 22:16:46 -08:00
github-actions[bot] e799a088a5 Sync latest Python releases (#16792)
Automated update for Python releases.

---------

Co-authored-by: jjhelmus <1050278+jjhelmus@users.noreply.github.com>
Co-authored-by: Jonathan Helmus <jjhelmus@gmail.com>
2025-11-20 20:27:40 +00:00
Meitar Reihan b9826778b9 Support http/https URLs in uv python --python-downloads-json-url (#16542)
continuation PR based on #14687

---------

Co-authored-by: Geoffrey Thomas <geofft@ldpreload.com>
Co-authored-by: Aria Desires <aria.desires@gmail.com>
2025-11-14 17:51:24 -05:00
Meitar Reihan 7f4d8c67a8 Account for python_downloads_json_url on Pre-release Python version warnings (#16737)
Solves #16711
2025-11-14 15:12:35 -06:00
William Woodruff ae1edef9c0 Reject ambiguously parsed URLs (#16622)
Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-11-12 16:27:57 +00:00
liam 1b38b47a3f Warn on managed prerelease interpreters when a stable build is available (#16619)
Resolves https://github.com/astral-sh/uv/issues/16616

This PR detects managed prerelease interpreters during discovery and
warns when a matching stable build is available, wiring the new helper
into `PythonInstallation::find`, `find_best`, and `find_or_download`.
2025-11-12 07:45:31 -06:00
konsti 92c2bfcca0 Remove unnecessary DisplaySafeUrl::from (#16689)
For #16622
2025-11-11 19:12:20 +00:00
liam c826f2b042 Fix pixi environment detection by recognizing Conda prefixes with conda-meta/pixi (#16585)
Resolves https://github.com/astral-sh/uv/issues/16295

This PR updates the Conda base-environment heuristic to recognize
Pixi-managed environments by checking for the `conda-meta/pixi` marker
file. Pixi default environments now resolve as isolated child
environments instead of system installations, restoring the expected uv
pip behavior without the `--system` flag.
2025-11-09 22:16:17 -06:00
Pavel Logan Dikov caf49f845f Use .rcdata to store trampoline type + path to python binary (#15068)
`.rsrc` is the idiomatic way of storing metadata and non-code resources
in PE
binaries. This should make the resulting binaries more robust as they
are no longer
dependent on the exact location of a certain magic number.

Addresses: #15022

## Test Plan

Existing integration test for `uv-trampoline-builder` + addition to
ensure robustness
to code signing.

---------

Co-authored-by: samypr100 <3933065+samypr100@users.noreply.github.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-11-09 08:12:40 -06:00
github-actions[bot] 1b7faafd7a Sync latest Python releases (#16505)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-11-08 10:16:21 -06:00
Zanie Blue 60a811e715 Allow Python requests to include +gil to require a GIL-enabled interpreter (#16537)
Addresses
https://github.com/astral-sh/uv/pull/16142#issuecomment-3390586957

Nobody seems to have a good idea about how to spell this. "not
free-threaded" would be the most technically correct, but I think "gil"
will be more intuitive.
2025-11-03 13:35:52 -06:00
Charlie Marsh 82aa0d0ef5 Avoid pluralizing 'retry' for single value (#16535) 2025-10-31 10:28:51 -04:00
samypr100 7978122837 Update Rust toolchain to 1.91 and MSRV to 1.89 (#16531)
## Summary

Updates Rust Toolchain to
[1.91](https://blog.rust-lang.org/2025/10/30/Rust-1.91.0/) and bumps
MSRV to [1.89](https://blog.rust-lang.org/2025/08/07/Rust-1.89.0/) per
versioning policy. New clippy rule [implicit
clone](https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone)
resulted in some minor changes (some with improvements).

Updates trampoline to `nightly-2025-06-23` which is roughly 1.89~. The
trampoline binaries do not need to be regenerated as there should be no
changes.
2025-10-30 22:34:59 -05:00
liam 3fb3c9af03 Clarify system Python discovery logging order (#16463)
Resolves https://github.com/astral-sh/uv/issues/16453

When `--system` is used, the debug log now reports interpreter discovery
sources in the same order they are probed, prioritising the PATH ahead
of managed installs on every platform. I also added a few unit tests
that use `DiscoveryPreferences::sources`, ensuring the log strings stay
aligned with the actual discovery sequence for both System and
OnlySystem preferences.
2025-10-28 07:18:13 -05:00