Commit Graph

5471 Commits

Author SHA1 Message Date
Charlie Marsh 7cdb2d08d9
Persist cache info when re-installing cached wheels (#15274)
## Summary

I noticed that these paths aren't returning the cache information, so if
you install through these paths, we actually don't write `uv_cache.json`
at all. I'm not sure how a user would actually end up here, because
assuming there are no bugs, we don't really ever use this path? The
install plan indexes the cached wheels and marks the wheel as installed,
which means it's typically a mistake if we're asking the
`DistributionDatabase` for a wheel that's already available in the
cache... But I did verify that if I _skip_ the install plan's cache
lookup, we write a wheel without `uv_cache.json`, so this is definitely
more correct.
2025-08-14 13:05:41 +01:00
github-actions[bot] c4e5984258
Sync latest Python releases (#15266)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-08-14 04:28:47 +00:00
Charlie Marsh c514e0eda9
Make 'v' prefix cyan in overlap warnings (#15259) 2025-08-13 22:41:28 +01:00
Zanie Blue 7e817bafde
Bump version to 0.8.10 (#15257) 2025-08-13 20:06:08 +00:00
Zanie Blue b8049eaa20
Move warnings for conflicting modules into preview (#15253) 2025-08-13 19:39:09 +00:00
Zanie Blue 2c54d3929c
Allow selection of pyodide interpreters with "pyodide" (#15256) 2025-08-13 19:08:55 +00:00
Ahmed Ilyas 88a7b2d864
Fix clippy warnings in downloads.rs (#15255)
## Summary

Fixes clippy warnings on main.

## Test Plan

`cargo clippy`
2025-08-13 12:21:03 -05:00
Hood Chatham c8d0bfba5c
Add support for installing pyodide Pythons (#14518)
- [x] Add tests

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-08-13 11:03:25 -05:00
Zanie Blue b38edb9b7d
Allow Python requests with missing segments (#14399)
This allows `PythonDownloadRequest` which is used for parsing general
install key requests to have missing segments, which unblocks requests
like `windows-aarch64` or `cpython-linux` (whereas before those would
require `any-any-windows-aarch64` and `cpython-any-linux` respectively).
We still require strict ordering of segments.

Previously, we only allowed missing segments at the end of the key.

This uses a state machine for parsing, which is quite a bit more
complicated.

I'm a little hesitant about the possibility that this regresses error
messages and the complexity of the implementation, but `uv run -p
aarch64` seems valuable following #13724. The alternative to this would
probably be to make these explicit in various places? e.g., expose
`--python-arch`, `--python-libc`, and `--python-os`? Or make
`--python-platform` (which already exists) accept a subset of the keys?

There is a possibility of regressions here, e.g., if something matches
this parser it will not fallback to the `PythonRequest::ExecutableName`
case and we've made this parser more permissive, but I think that should
be quite rare?
2025-08-13 11:03:09 -05:00
Zanie Blue 78c8c711fa
Refactor os, arch, and libc information into a shared `Platform` type (#15027)
Addresses this outstanding item from a previous review
https://github.com/astral-sh/uv/pull/13724#discussion_r2114867288

I'm interested in this now for consolidating some logic in #12731
2025-08-13 09:02:55 -05:00
samypr100 323aa8f332
chore(🧹): cleanup env var usage (#15247)
## Summary

Split the cleanup fixes from https://github.com/astral-sh/uv/pull/15196
into a separate PR for easier review.

This cleans up some minor env var usage / references throughout tests
and runtime code.

## Test Plan

Existing Tests. No functional changes.
2025-08-12 21:11:28 -05:00
Zanie Blue 68c0bf8a2c
Bump version to 0.8.9 (#15229) 2025-08-11 21:07:59 -05:00
Charlie Marsh dacc86ff03
Revert "Fix settings rendering for `extra-build-dependencies`" (#15228)
Reverts astral-sh/uv#15161
2025-08-11 19:37:12 -05:00
Charlie Marsh 9ba1ef1155
Fix settings rendering for `extra-build-dependencies` (#15161)
## Summary

It would be nice if this rendered as
`[tool.uv.extra-build-dependencies]` and `[extra-build-dependencies]`
(in `uv.toml`), but this is at least correct.

Closes https://github.com/astral-sh/uv/issues/15124.
2025-08-11 22:24:31 +01:00
Ubaid Shaikh 43341ad0a6
Filter date in GitHub release URLs for `python_install_no_cache` test (#15204)
## Summary

fixes https://github.com/astral-sh/uv/issues/15172

This change adds a regex filter to normalize dates in GitHub release
URLs within the `python_install_no_cache` test snapshot.

**Problem:**
The test was hardcoding the date `20250808` in the expected error
message URL:

```console
https://github.com/astral-sh/python-build-standalone/releases/download/20250808/cpython-3.12.[PATCH]-[DATE]-[PLATFORM].tar.gz
```

This creates a maintenance burden as the snapshot would need to be
updated whenever the underlying Python release date changes.

**Solution:**
Added a regex filter `r"releases/download/\d{8}/"` →
`"releases/download/[DATE]/"` to replace any 8-digit date in the GitHub
release URL path with a generic `[DATE]` placeholder.

**Result:**
The test is now resilient to new Python releases and won't require
snapshot updates when the underlying release date changes. The error
message now consistently shows:

```console
https://github.com/astral-sh/python-build-standalone/releases/download/[DATE]/cpython-3.12.[PATCH]-[DATE]-[PLATFORM].tar.gz
```

## Test Plan

`python_install` tests seem to pass  

```console
$ cargo test --package uv --test it -- python_install
   Compiling uv-cli v0.0.1 (/home/ubaid/projects/uv/crates/uv-cli)
   Compiling uv v0.8.8 (/home/ubaid/projects/uv/crates/uv)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 19.04s
     Running tests/it/main.rs (target/debug/deps/it-14d47eb0324a8a0a)

running 30 tests
test python_install::python_install_unknown ... ok
test network::python_install_io_error ... ok
test network::python_install_http_500 ... ok
test python_install::python_install_invalid_request ... ok
test python_install::python_install_broken_link ... ok
test python_install::python_install_preview_no_bin ... ok
test python_install::regression_cpython ... ok
test python_install::uninstall_last_patch ... ok
test python_install::install_no_transparent_upgrade_with_venv_patch_specification ... ok
test python_install::install_lower_patch_automatically ... ok
test python_install::uninstall_highest_patch ... ok
test python_install::install_transparent_patch_upgrade_venv_module ... ok
test python_install::python_install_default_from_env ... ok
test python_install::python_install ... ok
test python_install::python_reinstall_patch ... ok
test python_install::python_install_force ... ok
test python_install::install_transparent_patch_upgrade_uv_venv ... ok
test python_install::install_multiple_patches ... ok
test python_install::python_install_314 ... ok
test python_install::python_install_default ... ok
test python_install::python_install_automatic ... ok
test python_install::python_install_freethreaded ... ok
test python_install::python_install_preview_upgrade ... ok
test python_install::python_install_no_cache ... ok
test python_install::python_install_default_preview ... ok
test python_install::python_install_preview ... ok
test python_install::python_install_minor ... ok
test python_install::python_reinstall ... ok
test python_install::python_install_cached ... ok
test python_install::python_install_multiple_patch ... ok

test result: ok. 30 passed; 0 failed; 0 ignored; 0 measured; 2207 filtered out; finished in 23.34s
```
2025-08-11 16:15:52 -05:00
Charlie Marsh 40b894bb1d
Include build settings in cache key for registry source distribution lookups (#15225)
## Summary

Like #15030, but for source distributions built from a registry.
2025-08-11 22:14:27 +01:00
John Mumm 76b4ae40c6
Never create bin links on `uv python upgrade` if they don't already exist (#15192)
Fixes #15178
2025-08-11 15:36:03 -05:00
John Mumm 23245c63e9
Add `--reinstall` flag to `uv python upgrade` (#15194)
As described in #15179, there are cases where it can be useful to
reinstall the latest patch on upgrade if it is already installed. Using
this flag, you don't need to know ahead of time if you have the latest
patch already.

Closes #15179.
2025-08-11 15:20:04 -05:00
github-actions[bot] ed499d7453
Sync latest Python releases (#15186)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-08-09 00:43:10 +00:00
Zanie Blue 6c9544ed5f
Add test coverage for the `find_uv_bin` error message (#15185)
All of these went away as we fixed the bugs! it seems nice to retain a
snapshot of the error
2025-08-09 00:28:40 +00:00
Zanie Blue 9a54754b0a
Bump version to 0.8.8 (#15184) 2025-08-08 19:03:07 -05:00
Dustin Ngo 0924490456
fix: Use 3.9 compatible zip (#15177)
<!--
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

Uses a <3.10-compatible version of `zip` since the `strict` argument was
[added in 3.10](https://docs.python.org/3.10/library/functions.html#zip)

## Test Plan

I executed the `_matching_parents` function in a local 3.9 environment

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-08-08 18:45:13 -05:00
Zanie Blue 6b5d309d28
Add `find_uv_bin` test cases by Python version (#15181)
Regression coverage for https://github.com/astral-sh/uv/issues/15176
2025-08-08 18:36:59 -05:00
Zanie Blue 8a22572338
Bump version to 0.8.7 (#15173) 2025-08-08 14:42:23 -05:00
github-actions[bot] d1beb7f640
Sync latest Python releases (#15171)
Automated update for Python releases.

This picks up dynamically-linked tkinter/libtcl/libtk, which fixes #6893
and a host of similar issues.

Co-authored-by: Geoffrey Thomas <geofft@ldpreload.com>
2025-08-08 19:03:25 +00:00
Zanie Blue bdb4b061db
Include all site packages directories in ephemeral environment overlays (#15121)
Related to https://github.com/astral-sh/uv/issues/15113

The case in the linked issue is that we perhaps should not be allowing
`uv run --with` with system interpreters at all. I think we can consider
that, but the issue highlighted that `uv run --with` for a system
interpreter is broken if the base interpreter has custom site packages.
This generalizes beyond system interpreters so we should probably fix
our overlays.
2025-08-08 13:49:21 -05:00
Charlie Marsh f6a9b55eb7
Add `UV_DEV` and `UV_NO_DEV` environment variables (#15010)
## Summary

Closes https://github.com/astral-sh/uv/issues/15009.

Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-08-08 14:33:44 +00:00
Zanie Blue e18bfc6e9a
Do not update `uv.lock` when using `--isolated` (#15154)
A little spicy. We could consider this breaking, but I can't think of
what workflow it'd break and it matches the spirit of `--isolated`. This
was requested by @ssbarnea
2025-08-08 09:15:43 -05:00
samypr100 57df0146e2
Update Rust toolchain to 1.89 (#15157)
## Summary

Bumps Rust toolchain to 1.89, but not the MSRV.

Lifetime changes is related to a new lint rule explained in
https://blog.rust-lang.org/2025/08/07/Rust-1.89.0/#mismatched-lifetime-syntaxes-lint

## Test Plan

Existing Tests
2025-08-08 13:01:52 +00:00
Zanie Blue 8f71d239f8
Add support for `package`-level conflicts in workspaces (#14906)
Revives https://github.com/astral-sh/uv/pull/9130

Previously, we allowed scoping conflicting extras or groups to specific
packages, e.g. ,`{ package = "foo", extra = "bar" }` for a conflict in
`foo[bar]`. Now, we allow dropping the `extra` or `group` bit and using
`{ package = "foo" }` directly which declares a conflict with `foo`'s
production dependencies.

This means you can declare conflicts between workspace members, e.g.:

```
[tool.uv]
conflicts = [[{ package = "foo" }, { package = "bar" }]]
```

would not allow `foo` and `bar` to be installed at the same time.

Similarly, a conflict can be declared between a package and a group:

```
[tool.uv]
conflicts = [[{ package = "foo" }, { group = "lint" }]]
```

which would mean, e.g., that `--only-group lint` would be required for
the invocation.

As with our existing support for conflicting extras, there are
edge-cases here where the resolver will _not_ fail even if there are
conflicts that render a particular install target unusable. There's test
coverage for some of these. We'll still error at install-time when the
conflicting groups are selected. Due to the likelihood of bugs in this
feature, I've marked it as a preview feature.

I would not recommend reading the commits as there's some slop from not
wanting to rebase Andrew's branch.

---------

Co-authored-by: Andrew Gallant <andrew@astral.sh>
2025-08-08 07:44:58 -05:00
Zanie Blue a9302906ce
Search in the user scheme scripts directory last in `find_uv_bin` (#14191)
We should definitely not pick up user-level installations unless we
can't find uv anywhere else. Otherwise, e.g., we would find a uv
installed with `pipx install uv` before the one matching the uv module.
2025-08-08 11:46:32 +00:00
Charlie Marsh 9daadbfab0
Add R2 feature for malo tests (#15160)
Closes https://github.com/astral-sh/uv/issues/15158.
2025-08-08 06:26:18 -05:00
konsti 1843c90e74
Warn when two packages write to the same module (#13437)
We regularly get confusing bug reports where a package sometimes works
and sometimes doesn't and it's not clear to the user why. Ultimately, it
turns out that two packages contain the same module and there is a race
condition when installing the two packages. Usually, it's one of the
opencv-python distributions, but recently it's been z3, too. These error
are completely inscrutable to users.

* https://github.com/astral-sh/uv/issues/10708
* https://github.com/astral-sh/uv/issues/11806
* https://github.com/astral-sh/uv/issues/11659
* https://github.com/astral-sh/uv/issues/13435
* https://github.com/astral-sh/uv/issues/13550
* https://github.com/astral-sh/uv/issues/14030

We now warn for top-level modules (pattern: `<identifier>/__init__.py`)
that collide in a single installation, naming the offending wheels.
Checking for `__init__.py` excludes namespace packages.

Test script:

```
uv venv -q && cargo run -q --profile fast-build pip install --no-progress --link-mode clone opencv-python opencv-contrib-python --no-build --no-deps
uv venv -q && cargo run -q --profile fast-build pip install --no-progress --link-mode copy opencv-python opencv-contrib-python --no-build --no-deps
uv venv -q && cargo run -q --profile fast-build pip install --no-progress --link-mode hardlink opencv-python opencv-contrib-python --no-build --no-deps
uv venv -q && cargo run -q --profile fast-build pip install --no-progress --link-mode symlink opencv-python opencv-contrib-python --no-build --no-deps
```

We currently only catch conflicts in a single installation. Should we
prime the lock database with the site-packages contents, and would that
carry overhead?
2025-08-08 09:01:13 +00:00
Zanie Blue 8968d783de
Add support for `--prefix` and `--with` installations in `find_uv_bin` (#14184)
Follows #14182

Adds support for the case described at
https://github.com/astral-sh/uv/issues/10194#issuecomment-2993544346

This also happens to fix both `--with` requirement test cases, which
should close https://github.com/tox-dev/pre-commit-uv/issues/70
2025-08-07 16:48:07 -05:00
Zanie Blue 9425350478
Fix regression where `--require-hashes` applied to build dependencies in `uv pip install` (#15153)
Closes https://github.com/astral-sh/uv/issues/15146
2025-08-07 21:43:24 +00:00
Michael Šimáček e5eec05783
Ignore GraalPy devtag (#15013)
Allows [development builds of
GraalPy](https://github.com/graalvm/graal-languages-ea-builds) to work
with uv.

CC @timfel
2025-08-07 15:53:37 -05:00
Lars Grams d73edb019d
replace manual venv removal with remove_virtualenv (#15007)
<!--
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? -->
At some places the virtualenv directory was manually removed instead of
using `remove_virtualenv`.
I also adjusted the error type.
#14985 

## Test Plan

<!-- How was it tested? -->
2025-08-07 15:52:57 -05:00
Zanie Blue b1a036ccf5
Refactor `find_uv_bin` and add a better error message (#14182)
Follows https://github.com/astral-sh/uv/pull/14181

Two goals here

- Remove duplicated logic and make the search order clear
- Resolve user confusion around the searched directories; we previously
only displayed the last attempt, which we rarely expect to be relevant
2025-08-07 15:10:38 -05:00
Zanie Blue a7c4634243
Add a regression test for `--require-hashes` with unpinned build requirements (#15147)
Test case for https://github.com/astral-sh/uv/issues/15146
2025-08-07 20:04:18 +00:00
Zanie Blue ceb610c047
Update `find_uv_bin` to locate uv in the base prefix (#14181)
Closes https://github.com/astral-sh/uv/issues/10194
2025-08-07 13:40:57 -05:00
Charlie Marsh 329a6b446a
Bump version to v0.8.6 (#15137) 2025-08-07 16:17:14 +01:00
samypr100 abc68fc7c1
Consider pythonw when copying entrypoints in uv run (#15134)
## Summary

Follow up from
https://github.com/astral-sh/uv/pull/15068#discussion_r2258586926

It seems when copying entrypoints we're ignoring whether it was pythonw
vs not.

## Test Plan

Updated existing test.
2025-08-07 10:06:03 -05:00
Charlie Marsh 7f1eaf48c1
Harden ZIP streaming to reject repeated entries and other malformed ZIP files (#15136)
## Summary

uv will now reject ZIP files that meet any of the following conditions:

- Multiple local header entries exist for the same file with different
contents.
- A local header entry exists for a file that isn't included in the
end-of-central directory record.
- An entry exists in the end-of-central directory record that does not
have a corresponding local header.
- The ZIP file contains contents after the first end-of-central
directory record.
- The CRC32 doesn't match between the local file header and the
end-of-central directory record.
- The compressed size doesn't match between the local file header and
the end-of-central directory record.
- The uncompressed size doesn't match between the local file header and
the end-of-central directory record.
- The reported central directory offset (in the end-of-central-directory
header) does not match the actual offset.
- The reported ZIP64 end of central directory locator offset does not
match the actual offset.

We also validate the above for files with data descriptors, which we
previously ignored.

Wheels from the most recent releases of the top 15,000 packages on PyPI
have been confirmed to pass these checks, and PyPI will also reject ZIPs
under many of the same conditions (at upload time) in the future.

In rare cases, this validation can be disabled by setting
`UV_INSECURE_NO_ZIP_VALIDATION=1`. Any validations should be reported to
the uv issue tracker and to the upstream package maintainer.
2025-08-07 15:31:48 +01:00
github-actions[bot] 038bf56366
Sync latest Python releases (#15135)
Automated update for Python releases.

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
2025-08-07 13:59:02 +00:00
konsti 84d57f2ee9
Ensure symlink warning is shown (#15126)
Fixes #15115, see also https://github.com/clap-rs/clap/discussions/6092

<img width="1079" height="1030" alt="image"
src="https://github.com/user-attachments/assets/05b003a6-9ca0-4f2b-8a74-078aa155ce6d"
/>
2025-08-07 15:56:59 +02:00
Zanie Blue 278295ef02
Add test cases for `find_uv_bin` (#15110)
Adds test cases to unblock

- https://github.com/astral-sh/uv/pull/14181
- https://github.com/astral-sh/uv/pull/14182
- https://github.com/astral-sh/uv/pull/14184
- https://github.com/astral-sh/uv/pull/14184
- https://github.com/tox-dev/pre-commit-uv/issues/70

We use a package with a symlink to the Python module to get a mock
installation of uv without building (or packaging) the uv binary. This
lets us test real patterns like `uv pip install --prefix` without
encoding logic about where things are placed during those installs.

---------

Co-authored-by: konstin <konstin@mailbox.org>
2025-08-07 07:14:01 -05:00
Zanie Blue aec90f0a3c
Fix warnings when running tests with a subset of features (#15120)
We were getting dead code warnings on Windows tests because these were
not properly feature gated.
2025-08-07 01:28:26 +00:00
Charlie Marsh 3c1844ca4a
Add support for per-project build-time environment variables (#15095)
## Summary

E.g., you can now do:

```toml
[tool.uv.extra-build-variables]
flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" }
```
2025-08-06 18:01:55 -05:00
konsti 59558b13c1
Respect `UV_HTTP_RETRIES` in `uv publish` (#15106)
Previously, publish would always use the default retries, now it
respects `UV_HTTP_RETRIES`

Some awkward error handling to avoid pulling anyhow into uv-publish.
2025-08-06 17:59:17 +02:00
konsti 52771476f4
Support `UV_NO_EDITABLE` where `--no-editable` is supported (#15107)
Specifically, support `UV_NO_EDITABLE=1 uv export`. It's now also
supported in `uv add`, though it's default there anyway and the env var
exists only for completeness.

Fixes #15103
2025-08-06 13:06:49 +00:00