Commit Graph

452 Commits

Author SHA1 Message Date
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
github-actions[bot] 41cd3d1926
Sync latest Python releases (#16486)
Automated update for Python releases.

Co-authored-by: jjhelmus <1050278+jjhelmus@users.noreply.github.com>
2025-10-29 10:10:49 -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
Zanie Blue 1fbc1c7ff4
Check for matching Python implementation during `uv python upgrade` (#16420)
Closes https://github.com/astral-sh/uv/issues/16416
2025-10-23 10:48:34 -05:00
github-actions[bot] 00bf80bfda
Upgrade GraalPy to 25.0.1 (#16401)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-10-23 15:16:37 +00:00
Andrei Berenda 51e8da2d1c
Move parsing http retries to EnvironmentOptions (#16284)
## Summary
- Move  parsing `UV_HTTP_RETRIES` to `EnvironmentOptions`

Relates https://github.com/astral-sh/uv/issues/14720

## Test Plan

- Tests with existing tests
2025-10-21 11:14:37 +02:00
github-actions[bot] ed65c2482c
Sync latest Python releases (#16246)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-10-21 00:41:53 +00:00
konsti 52cc3c8b94
Add missing `UV_TEST_NO_HTTP_RETRY_DELAY` check and better logging (#16313)
The `install_http_retries` test goes from 15s to 0.3s. Additionally, we
log the retry delay.
2025-10-15 20:45:21 +02:00
Zanie Blue d1413a60d8
Add CPython 3.15.0a1 and 3.13.9 (#16304) 2025-10-14 18:05:44 -05:00
github-actions[bot] d54a5bb5cb
Sync latest Python releases (#16229)
Add python-build-standalone 20251010 for CPython 3.12.12, 3.11.14, 3.10.19 and 3.9.24.

Co-authored-by: Geoffrey Thomas <geofft@ldpreload.com>
2025-10-10 13:35:37 -04:00
Skyler Hawthorne ea5a09215b
fix recompiling every time in uv-python (#16214)
Cargo is currently recompiling uv-python on every invocation because the
minified JSON output file is getting a mod time newer than the last run.
Instead, set the mod time of the output file to the same as the input
file.
2025-10-09 16:10:08 -05:00
Zanie Blue 84d6a913ac Ignore pre-release Python versions when a patch version is requested (#16210)
I think this is ostensively breaking, though I think the impact would be
small given this will go out in 0.9.1 and should only affect people
using pre-release Python versions.

When `3.14.0` is requested (opposed to `3.14`), we treat this as a
request for a final / stable version and ignore pre-releases.

I think this is a fairly clean way to allow users to explicitly request
the stable version.

Closes https://github.com/astral-sh/uv/issues/16175
Follows #16208
2025-10-09 12:24:42 -05:00
Zanie Blue fb7d5361b0 Fix handling of Python requests with pre-releases in ranges 2025-10-09 12:24:42 -05:00
Zanie Blue 1051709792
Treat deleted Windows registry keys as equivalent to missing ones (#16194)
I noticed this flaked in a snapshot.

We may want to encode this in a helper at some point.
2025-10-08 12:24:36 -05:00
github-actions[bot] 4c4fce4284
Sync latest Python releases (#16169)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-10-08 04:26:32 +00:00
Zanie Blue df0a12d461
Fix `uv python upgrade` replacement of installed binaries on pre-release to stable (#16159) 2025-10-07 20:29:42 +00:00
Zanie Blue 3a507e69b2
Ban pre-release versions in `uv python upgrade` requests (#16160) 2025-10-07 15:07:09 -05:00
github-actions[bot] 37b3557dab
Sync latest Python releases (#16157)
Pick up python-build-standalone tag 20251007 to add 3.14.0 final
and 3.13.8, and adjust tests.

Also, fix matching version requests with prereleases: `uvx
python@3.14.0rc3` should not be satisfied by 3.14.0 final.

Co-authored-by: Geoffrey Thomas <geofft@ldpreload.com>
2025-10-07 19:07:18 +00:00
Skyler Hawthorne 9214855109
fix compile error on missing uv-python metadata (#16154)
The `uv-python` crate reads the checked-in download metadata to write
out a minified version to be statically included into the binary.

Sometimes, the resulting `download-metadata-minified.json` can go
missing, such as when `uv` is installed via `cargo` as a git source, and
there is an update; `cargo` will do a hard reset on the git repo it
stores in the cache, causing it to be deleted. In these instances, the
`uv-python` crate does not currently re-run its build script, because as
it happens, there was no change to the `download-metadata.json` since it
was last compiled. This causes a build error like:

```
            Updating git repository `https://github.com/astral-sh/uv`
          Installing uv v0.8.24 (https://github.com/astral-sh/uv?tag=0.8.24#252f8873)
            Updating crates.io index
           Compiling uv-version v0.8.24 (/home/skhawtho/.cargo/git/checkouts/uv-c9e40703e19509a8/252f887/crates/uv-version)
           Compiling uv-git v0.0.1 (/home/skhawtho/.cargo/git/checkouts/uv-c9e40703e19509a8/252f887/crates/uv-git)
           Compiling uv-build-backend v0.1.0 (/home/skhawtho/.cargo/git/checkouts/uv-c9e40703e19509a8/252f887/crates/uv-build-backend)
           Compiling uv-configuration v0.0.1 (/home/skhawtho/.cargo/git/checkouts/uv-c9e40703e19509a8/252f887/crates/uv-configuration)
           Compiling uv-client v0.0.1 (/home/skhawtho/.cargo/git/checkouts/uv-c9e40703e19509a8/252f887/crates/uv-client)
           Compiling uv-extract v0.0.1 (/home/skhawtho/.cargo/git/checkouts/uv-c9e40703e19509a8/252f887/crates/uv-extract)
           Compiling uv-workspace v0.0.1 (/home/skhawtho/.cargo/git/checkouts/uv-c9e40703e19509a8/252f887/crates/uv-workspace)
           Compiling uv-python v0.0.1 (/home/skhawtho/.cargo/git/checkouts/uv-c9e40703e19509a8/252f887/crates/uv-python)
           Compiling uv-requirements-txt v0.0.1 (/home/skhawtho/.cargo/git/checkouts/uv-c9e40703e19509a8/252f887/crates/uv-requirements-txt)
           Compiling uv-bin-install v0.0.1 (/home/skhawtho/.cargo/git/checkouts/uv-c9e40703e19509a8/252f887/crates/uv-bin-install)
           Compiling uv-publish v0.1.0 (/home/skhawtho/.cargo/git/checkouts/uv-c9e40703e19509a8/252f887/crates/uv-publish)
        error: couldn't read `crates/uv-python/src/download-metadata-minified.json`: No such file or directory (os error 2)
           --> crates/uv-python/src/downloads.rs:795:45
            |
        795 | const BUILTIN_PYTHON_DOWNLOADS_JSON: &str = include_str!("download-metadata-minified.json");
            |                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        error: could not compile `uv-python` (lib) due to 1 previous error
        error: failed to compile `uv v0.8.24 (https://github.com/astral-sh/uv?tag=0.8.24#252f8873)`, intermediate artifacts can be found at `/home/skhawtho/.cache/cargo`.
        To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
```

This fixes the issue by also adding a `rerun-if-changed` on the
resulting minified JSON file.

Separately, this revision also changes the output directory of the
minified file to the build script's output directory via the `OUT_DIR`
environment variable, so as not to pollute the source code.
2025-10-07 12:33:04 -05:00
Zanie Blue 83f738074d
Allow use of free-threaded variants in Python 3.14+ without explicit opt-in (#16142)
Closes https://github.com/astral-sh/uv/issues/15739
Closes #12445
2025-10-07 11:24:05 -05:00
Zanie Blue 241ad88051
Confirm that the directory name is a valid Python install key during managed check (#16080)
Closes https://github.com/astral-sh/uv/issues/16077

```
❯ UV_PYTHON_INSTALL_DIR=/opt uv python list --no-managed-python
cpython-3.9.6-macos-aarch64-none    /usr/bin/python3
❯ alias uv=$(pwd)/target/debug/uv
❯ UV_PYTHON_INSTALL_DIR=/opt uv python list --no-managed-python
cpython-3.13.3-macos-aarch64-none     /opt/homebrew/bin/python3.13 -> ../Cellar/python@3.13/3.13.3/bin/python3.13
cpython-3.13.3-macos-aarch64-none     /opt/homebrew/bin/python3 -> ../Cellar/python@3.13/3.13.3/bin/python3
cpython-3.12.10-macos-aarch64-none    /opt/homebrew/bin/python3.12 -> ../Cellar/python@3.12/3.12.10/bin/python3.12
cpython-3.11.12-macos-aarch64-none    /opt/homebrew/bin/python3.11 -> ../Cellar/python@3.11/3.11.12/bin/python3.11
cpython-3.9.6-macos-aarch64-none      /usr/bin/python3
pypy-3.10.14-macos-aarch64-none       /opt/homebrew/bin/pypy3 -> ../Cellar/pypy3.10/7.3.17_1/bin/pypy3
```

Prevents false positives when the `UV_PYTHON_INSTALL_DIR` is a prefix of
some other path with Python installations
2025-10-03 19:36:08 +00:00
github-actions[bot] 268f1325ba
Upgrade Pyodide to 0.28.3 (#15999)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-09-23 09:57:15 -05:00
Zsolt Dollenstein 46bf420eae
Allow upgrading prerelease versions of the same minor Python version (#15959)
Turns out if the minor versions matched we returned false from
`is_upgrade_of` instead of continuing to compare prerelease versions.

Closes #15955.

Note: test cases were initially generated by Claude - I tried making
them shorter.

## Test plan

```
❯ cargo run -- -v python upgrade 3.14
[...]
DEBUG Inspecting existing executable at `/Users/zsol/.local/bin/python3.14`
DEBUG Replacing existing executable for `cpython-3.14.0rc2-macos-aarch64-none` at `/Users/zsol/.local/bin/python3.14` with executable for `cpython-3.14.0rc3-macos-aarch64-none` since it is an upgrade
DEBUG Updated executable at `/Users/zsol/.local/bin/python3.14` to cpython-3.14.0rc3-macos-aarch64-none
Installed Python 3.14.0rc3 in 5.04s
 + cpython-3.14.0rc3-macos-aarch64-none (python3.14)
[...]
❯ uvx python3.14 -V
Python 3.14.0rc3
```
2025-09-22 16:59:48 +00:00
github-actions[bot] 3979c59726
Sync latest Python releases (#15958)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-09-20 02:25:21 +00:00
github-actions[bot] 974a83b676
Sync latest Python releases (#15940)
Add Python 3.13.0rc3 (and some comments in .python-version).

Co-authored-by: Geoffrey Thomas <geofft@ldpreload.com>
2025-09-19 18:13:33 +00:00
Zanie Blue e23da5b315
Use `EnvVars` for Conda variables in tests (#15930) 2025-09-18 07:52:23 -05:00
Zanie Blue fa53a62f0b
Always treat conda environments named `base` and `root` as base environments (#15682)
Extends https://github.com/astral-sh/uv/pull/15679

I'm not sure if we want to do this. It is probably _generally_ true, but
I think I'd rather remove the special casing entirely? I think the main
case for this is that it could help prevent regressions from #15679 and
we can remove it in a breaking release?
2025-09-17 17:32:14 +00:00
Zanie Blue d5012c66bd
Add handling for unnamed conda environments in base environment detection (#15681)
While investigating https://github.com/astral-sh/uv/pull/15679, I
created an unnamed conda environment and noticed this quality which
allows us to detect that it's not the base environment.
2025-09-17 11:34:23 -05:00
Charlie Marsh dea1700945
Avoid ANSI codes in debug! messages (#15843)
## Summary

I spent time trying to figure out how to support this but came up empty.
It _seems_ like maybe the `DefaultFields` implementation in
`tracing-subscriber` uses debug formatting for fields...? So if you have
a string with ANSI codes, they end up printing as unformatted values? I
even reverted all our custom formatting in `logging.rs` and saw the same
thing.

Closes https://github.com/astral-sh/uv/issues/15840.
2025-09-17 14:30:43 +00:00
Zanie Blue d805d4a370
Use `_CONDA_ROOT` to detect conda base environments (#15680)
While investigating https://github.com/astral-sh/uv/pull/15679, I
noticed this variable was available in the environment and seems like a
nice additional heuristic.
2025-09-17 11:17:06 +00:00
Zanie Blue ee5f155f7e
Invert the logic for determining if a path is a base conda environment (#15679)
Closes https://github.com/astral-sh/uv/issues/15604

The previous logic does not match the discussion in the original issue
about this feature, nor does it match the comment for the function. I'm
confused because I know this logic is working for some people? I'm
consequently a little wary of making this change. I'm following up with
some additional changes that should ensure this is robust, e.g., #15680
2025-09-17 06:04:29 -05:00
github-actions[bot] 9ec7971b4a
Add GraalPy 25.0.0 with support for Python 3.12 (#15900)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-09-17 02:54:31 +00:00
Zanie Blue 8f3583a6e6
Allow selection of debug build interpreters (#11520)
Extends the `PythonVariant` logic to support interpreters with the debug
flag enabled.
2025-09-12 13:32:22 +00:00
David Peter 0d174b79e2
Ignore pre-release versions in `uv init --script` (#15747)
## Summary

Ignore managed pre-release versions of Python for purposes of creating a
`requires-python` constraint when running `uv init --script`. This makes
the behavior consistent with `uv init` for normal projects.

## Test Plan

Added a regression test that makes sure that the constraint is
`requires-python = ">=3.13"`, even though a pre-release version of 3.14
is installed.
2025-09-10 14:35:29 -05:00
konsti cd49e1d11f
Use the `windows` crate facade consistently (#15737)
The initial motivation for this change was that we were using both the
`windows`, the `window_sys` and the `windows_core` crate in various
places. These crates have slightly unconventional versioning scheme
where there is a large workspace with the same version in general, but
only some crates get breaking releases when a new breaking release
happens, the others stay on the previous breaking version. The `windows`
crate is a shim for all three of them, with a single version. This
simplifies handling the versions.

Using `windows` over `windows_sys` has the advantage of a higher level
error interface, we now get a `Result` for all windows API calls instead
of C-style int-returns and get-last-error calls. This makes the
uv-keyring crate more resilient.

We keep using the `windows_registry` crate, which provides a higher
level interface to windows registry access.
2025-09-09 15:07:14 +00:00
Zanie Blue e136a51f3d
Skip Python interpreters that cannot be queried with permission errors (#15685)
Closes https://github.com/astral-sh/uv/issues/15651
2025-09-05 09:03:41 -05:00
github-actions[bot] 4162005df8
Sync latest Python releases (#15670)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-09-03 20:04:55 -05:00
github-actions[bot] 8fcd88d2d4
Sync latest Python releases (#15631)
Update to python-build-standalone 20250902 mostly for SQLite 3.50.4/CVE-2025-6965.
2025-09-02 18:43:17 +00:00
github-actions[bot] 35ce8e1dae
Sync latest Python releases (#15578)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-09-02 14:24:39 +00:00
konsti 22f80ca00d
Retry streaming Python and bin download errors (#15567)
When there is an error during the streaming download and unpack for
Python interpreter and bin installs, we would previously fail, causing a
lot of CI flakes on GitHub Actions.

The problem was that the error is not one of the extended IO errors we
were previously handling, but a regular reqwest error, nested below
layers of errors of other crates processing the stream, including some
IO errors. We now handle nested reqwest errors, too.

This surfaced another problem: Our manual retry loop couldn't inform the
retry middleware that it already performed the limit of retries, and
that the middleware should not retry anymore. While too many retries are
more a problem for debugging than for the user, this causes confusing
error output. To work around this, we disable the retries in the client
and handle all retry errors in our loop.

Fixes https://github.com/astral-sh/uv/issues/14171

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2025-08-31 15:07:22 +00:00
github-actions[bot] f461438611
Add managed Python distributions for aarch64-musl (#15574)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-08-28 15:44:51 -05:00
github-actions[bot] 75741082f7
Update Pyodide build number to 0.28.2 (#15523)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-08-26 00:58:20 +00:00
Charlie Marsh b723129c7c
Clear discovered interpreters when creating virtual environment (#15522)
## Summary

Closes https://github.com/astral-sh/uv/issues/15518.
2025-08-25 20:24:24 -04:00
Zanie Blue 9b8d6989d4
Allow pinning managed Python versions to specific build versions (#15314)
Allows pinning the Python build version via environment variables, e.g.,
`UV_PYTHON_CPYTHON_BUILD=...`. Each variable is implementation specific,
because they use different versioning schemes.

Updates the Python download metadata to include a `build` string, so we
can filter downloads by the pin. Writes the build version to a file in
the managed install, e.g., `cpython-3.10.18-macos-aarch64-none/BUILD`,
so we can filter installed versions by the pin.

Some important follow-up here:

- Include the build version in not found errors (when pinned)
- Automatically use a remote list of Python downloads to satisfy build
versions not present in the latest embedded download metadata

Some less important follow-ups to consider:

- Allow using ranges for build version pins
2025-08-25 16:25:05 -05:00
Charlie Marsh ac84f5aedc
Move preview features into a dedicated crate (#15482)
## Summary

This is causing some cyclic dependencies issues for me, because these
can be used in virtually _any_ crate (like `uv-install-wheel`), which
then means that all of `uv-configuration` becomes a dependency, etc. I
think this should be a leaf crate so that we can safely depend on it
anywhere.
2025-08-24 09:55:30 -04:00
konsti 25bedeadea
Stop leaking strings in Python downloads (#15418)
We should not unnecessarily leak memory. Instead, we follow the general
patterns and use `Cow` for strings that can be from either a static or a
dynamic source.
2025-08-21 17:54:39 +02:00