Commit Graph

4347 Commits

Author SHA1 Message Date
Charlie Marsh 47a31fc61c
Treat version mismatch errors as non-fatal in fast paths (#10860)
## Summary

I noticed that we're only handling `Error::WheelMetadataNameMismatch`
here; but `Error::WheelMetadataVersionMismatch` should also be treated
as non-fatal.
2025-01-22 10:13:24 -05:00
Charlie Marsh 028df07c19
Remove warnings for `--frozen` and `--locked` in `uv run --script` (#10840)
## Summary

We only show these if a lockfile is missing; and, if so, we guide the
user towards generating one.

Closes https://github.com/astral-sh/uv/issues/10839.
2025-01-22 08:19:28 -05:00
Mathieu Kniewallner dc637d0b7b
fix(cli): conflict `--locked` with `--upgrade` (#10836)
## Summary

Relates to #10273.

This doesn't solve what is highlighted in
https://github.com/astral-sh/uv/issues/10273#issuecomment-2569515066,
but I believe this is still an improvement for users not setting
`upgrade = true` in `[tool.uv]`.

## Test Plan

Ran commands locally:

```shell
$ cargo run --quiet -- lock --locked --upgrade
error: the argument '--check' cannot be used with '--upgrade'

Usage: uv lock --check

For more information, try '--help'.
```
2025-01-21 21:10:19 -06:00
Charlie Marsh a7166fff8a
Add `--refresh` to `uv venv` (#10834)
## Summary

I was surprised that this didn't exist.
2025-01-21 19:35:33 -05:00
Zanie Blue d952a97f1c
Improve uvx error message when uv is missing (#9745)
from https://github.com/astral-sh/uv/issues/9742

```
❯ cargo run -q --bin uvx
Provide a command to run with `uvx <command>`.

The following tools are installed:

- ansible-core v2.17.5
- black v24.10.0
- rooster-blue v0.0.0

See `uvx --help` for more information.
❯ rm target/debug/uv
❯ cargo run -q --bin uvx
error: Could not find the `uv` binary at /Users/zb/workspace/uv/target/debug/uv
```
2025-01-21 23:06:56 +00:00
Mathieu Kniewallner 1479f52be7
feat: add `--no-default-groups` flag (#10618)
## Summary

Closes #10592.

## Test Plan

Snapshot tests.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2025-01-21 18:03:17 -05:00
Charlie Marsh 4574ced370
Bump version to v0.5.22 (#10829) 2025-01-21 17:03:55 -05:00
Sede Soukossi d49be0a7f9
fix(#10717): Omit stdout and stderr sections when empty in errors (#10746)
## Summary

This change closes #10717 

## Test Plan

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

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2025-01-21 21:45:29 +00:00
Zanie Blue b543881b1b
Show non-critical Python discovery errors if no other interpreter is found (#10716)
Previously, these errors would only be visible in the debug logs as
"Skipping bad interpreter ..." which can lead us to making some
ridiculous claims like "There is no virtual environment" or "Python is
not installed" when really we just failed to query the interpreter for
some reason.

We show the first error, sort of arbitrarily — but I think it matches
user expectation, i.e., this would be the first Python on your PATH.

Related to #10713
2025-01-21 21:11:55 +00:00
Charlie Marsh a62b891e6a
Add fast-path for recursive extras in dynamic validation (#10823)
## Summary

Closes https://github.com/astral-sh/uv/issues/10816.
2025-01-21 16:01:20 -05:00
Charlie Marsh 9dd1217e1d
Remove clones from `PubGrubDependency::from_requirement` (#10821) 2025-01-21 15:32:34 -05:00
Charlie Marsh c497501246
Update PyTorch fixtures (#10822) 2025-01-21 15:32:25 -05:00
Charlie Marsh 61bc818b4d
Extract extra-flattening routine from source tree resolver (#10820)
## Summary

I needed this for https://github.com/astral-sh/uv/pull/10794, but it
makes sense as a standalone change, since it's much more testable. We
can also reuse this in at least one more place.
2025-01-21 19:52:55 +00:00
Charlie Marsh 78639187e8
Remove the `FullCommit` variant from `GitReference` (#10803)
## Summary

It's not quite correct for this to be on `GitReference`. It's not a
variant that can be created by users, or by us.
2025-01-21 19:26:58 +00:00
Charlie Marsh 29226b074b
Skip GitHub fast path when full commit is already known (#10800)
## Summary

If we have a `GitReference::FullCommit`, we don't need to go to GitHub
to resolve the SHA. We already have it!
2025-01-21 19:17:51 +00:00
Andrew Gallant 9552c0a8db
uv-resolver: include conflict markers in fork markers (#10818)
When support for conflicting extras/groups was initially added, I
stopped short of including the conflict markers in uv's "fork markers"
in the lock file. That is, the fork markers are markers that indicate
the different splits uv took during resolution, which we record, I
believe, to avoid spurious updates to the lock file as a result of
using them as preferences.

One interesting result of omitting the conflict markers from the fork
markers is that sometimes this would result in duplicate markers. In
response, I wrote a function that stripped off the conflict markers and
deduplicated the remainder. My thinking at the time was that it wasn't
clear whether we needed to keep conflict markers around.

It looks like #10783 demonstrates a case where we do, seemingly, need
them. Namely, it's a case where after stripping conflict markers, you
don't end up with duplicate markers, but you do end up with overlapping
markers. Overlapping fork markers are bad juju for the same reason that
overlapping resolver forks are bad juju: you can end up with multiple
versions of the same package in the same environment.

I don't know how to fix overlapping markers without just including the
conflict markers. So that's what this PR does. Because of this, there
will be some churn in lock files, but this only applies to projects that
define conflicting extras.

This PR includes a regression test from #10783. I also manually tried
the original reproduction in #10772 (where adding `numpy<2` caused `uv
sync` to fail), and things worked.

Fixes #10772, Fixes #10783
2025-01-21 14:04:31 -05:00
Zanie Blue 399086d28f
Disable the distutils setuptools shim during interpreter query (#10819)
Addresses
https://github.com/astral-sh/uv/issues/4204#issuecomment-2604983670

Original context in https://github.com/astral-sh/uv/issues/2302
2025-01-21 18:34:13 +00:00
Charlie Marsh 96e3ed5603
Replace `pybabel` with a dedicated executable package (#10726)
## Summary

Replacing the large `pybabel` in tests with
[`executable-application`](https://pypi.org/project/executable-application/)
(1.7 KB).

We may want a separate test package with an executable that _does_ match
the name? This one intentionally does _not_. It would make it much
easier for us to rewrite the other tests in bulk, since we can do a
find-and-replace on `black`, etc.

Closes https://github.com/astral-sh/uv/issues/10646.
2025-01-21 12:26:26 -05:00
Zanie Blue 581a82d370
Install Python via uv in Windows CI (#10657)
Python 3.8 is a GHA cache miss now, so it is actually like 30-45s. uv
may be faster
2025-01-21 09:02:14 -06:00
Charlie Marsh 9799048f92
Omit variant when detecting compatible Python installs (#10722)
## Summary

Closes https://github.com/astral-sh/uv/issues/10586.
2025-01-21 09:01:18 -06:00
Charlie Marsh 5c7fba86e1
Deduplicate `GitSha` and `GitOid` types (#10802)
## Summary

I think this split is leftover from using `libgit2`. I kept `Oid` since
that seems to be the official terminology.
2025-01-21 09:15:11 -05:00
Charlie Marsh 44d2bfeb65
Remove allocation in Git SHA truncation (#10801) 2025-01-21 01:53:12 +00:00
Charlie Marsh 154fd6bd23
Make `GitOid` a crate-public type (#10799) 2025-01-21 01:41:35 +00:00
Charlie Marsh eabcc94cbc
Remove `Serde` derives from Git reference type (#10798) 2025-01-21 01:35:56 +00:00
Charlie Marsh 4354c0c9b7
Add fallback to build backend when `Requires-Dist` mismatches (#10797)
## Summary

This is a smaller alternative to #10794. If the `Requires-Dist` that we
extract statically doesn't match the lockfile metadata, we now go back
to the distribution database to double-check. Checking the
`Requires-Dist` is itself very cheap, so in the worst case, we're just
paying the same cost as prior to this optimization.

Closes https://github.com/astral-sh/uv/issues/10776.
2025-01-21 00:45:56 +00:00
Charlie Marsh 45911693c4
Remove short commit variant (#10795)
## Summary

This is never constructed.
2025-01-20 18:35:47 -05:00
Charlie Marsh 8e13eb5bb6
Validate metadata under GitHub fast path (#10796)
## Summary

This is leading to a failing test (when not rate-limited).
2025-01-20 18:30:23 -05:00
Charlie Marsh e5e882889c
Add a test for recursive extras with dynamic metadata (#10792)
## Summary

See: https://github.com/astral-sh/uv/issues/10776.
2025-01-20 17:57:00 -05:00
Charlie Marsh 0e538730dd
Move `RequiresDist` into its own module (#10791) 2025-01-20 17:28:19 -05:00
Charlie Marsh 07e1e85c5d
Avoid deserialization error for paths above the root (#10789)
## Summary

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

## Test Plan

Copied over this lockfile:

```toml
version = 1
requires-python = ">=3.12"
resolution-markers = [
    "sys_platform == 'win32'",
    "sys_platform != 'win32'",
]

[[package]]
name = "pyasn1"
version = "0.6.1"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "01f1a642459aae6ee7b159a6c4c018/pyasn1-0.6.1.tar.gz", hash = "sha256:6f580d2bdd84365380830acf45550f2511469f673cb4a5ae3857a3170128b034", size = 145322 }
wheels = [
    { url = "d6a797abb18c925cab503dd37f8214/pyasn1-0.6.1-py3-none-any.whl", hash = "sha256:0d632f46f2ba09143da3a8afe9e33fb6f92fa2320ab7e886e2d0f7672af84629", size = 83135 },
]

[[package]]
name = "pyasn1-modules"
version = "0.4.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
    { name = "pyasn1" },
]
sdist = { url = "6afbf0d507a72057e9c23797a737c9/pyasn1_modules-0.4.1.tar.gz", hash = "sha256:c28e2dbf9c06ad61c71a075c7e0f9fd0f1b0bb2d2ad4377f240d33ac2ab60a7c", size = 310028 }
wheels = [
    { url = "bc88a6711982eaa35a0a47c8032bdc/pyasn1_modules-0.4.1-py3-none-any.whl", hash = "sha256:49bfa96b45a292b711e986f222502c1c9a5e1f4e568fc30e2574a6c7d07838fd", size = 181537 },
]

[[package]]
name = "python-ldap"
version = "3.4.4"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
    "sys_platform != 'win32'",
]
dependencies = [
    { name = "pyasn1", marker = "sys_platform != 'win32'" },
    { name = "pyasn1-modules", marker = "sys_platform != 'win32'" },
]
sdist = { url = "1eeb4025dc4955b72db5ce7a4dbfbd/python-ldap-3.4.4.tar.gz", hash = "sha256:7edb0accec4e037797705f3a05cbf36a9fde50d08c8f67f2aef99a2628fab828", size = 377889 }

[[package]]
name = "python-ldap"
version = "3.4.4"
source = { path = "../../../uti/Python/python_ldap-3.4.4-cp312-cp312-win_amd64.whl" }
resolution-markers = [
    "sys_platform == 'win32'",
]
dependencies = [
    { name = "pyasn1", marker = "sys_platform == 'win32'" },
    { name = "pyasn1-modules", marker = "sys_platform == 'win32'" },
]
wheels = [
    { filename = "python_ldap-3.4.4-cp312-cp312-win_amd64.whl", hash = "sha256:94d2ca2b3ced81c9d89aa5c79d4965d03053e1ffdcfae73e9fac85d25b692e85" },
]

[package.metadata]
requires-dist = [
    { name = "pyasn1", specifier = ">=0.3.7" },
    { name = "pyasn1-modules", specifier = ">=0.1.5" },
]

[[package]]
name = "uv-test"
version = "1.0"
source = { virtual = "." }
dependencies = [
    { name = "python-ldap", version = "3.4.4", source = { registry = "https://pypi.org/simple" }, marker = "sys_platform != 'win32'" },
    { name = "python-ldap", version = "3.4.4", source = { path = "../../../uti/Python/python_ldap-3.4.4-cp312-cp312-win_amd64.whl" }, marker = "sys_platform == 'win32'" },
]

[package.metadata]
requires-dist = [
    { name = "python-ldap", marker = "sys_platform != 'win32'" },
    { name = "python-ldap", marker = "sys_platform == 'win32'", path = "../../../../../../../../../../../../uti/Python/python_ldap-3.4.4-cp312-cp312-win_amd64.whl" },
]
```

Verified that `cargo run sync --frozen` installs `python-ldap` from
PyPI, without erroring.
2025-01-20 16:36:18 -05:00
Charlie Marsh 6b4c8a906c
Remove unused verbatim method (#10788) 2025-01-20 20:43:16 +00:00
Charlie Marsh 25982929c2
Include version and contact information in GitHub User Agent (#10785)
## Summary

See: https://github.com/astral-sh/uv/pull/10765#discussion_r1922016112
2025-01-20 14:30:04 -05:00
Charlie Marsh 5ee4cf6ff5
Fetch `pyproject.toml` from GitHub API (#10765)
## Summary

When resolving Git metadata, we may be able to fetch the metadata from
GitHub directly in some cases. This is _way_ faster, since we don't need
to perform many Git operations and, in particular, don't need to clone
the repo.

This only works in the following cases:

- The Git repository is public. Otherwise, I believe you need an access
token, which we don't have.
- The `pyproject.toml` has static metadata.
- The `pyproject.toml` has no `tool.uv.sources`. Otherwise, we need to
lower them... And, if there are any paths or workspace sources, that
requires an install path (i.e., we need the content on-disk).
- The project is in the repo root. If it's in a subdirectory, it could
be a workspace member. And if it's a workspace member, there could be
sources defined in the workspace root. But we can't know without
fetching the workspace root -- and we need the workspace in order to
find the root...

Closes #10568.
2025-01-20 17:50:39 +00:00
Charlie Marsh b2d06f01cc
Add tag incompatibility hints to sync failures (#10739)
## Summary

These are very similar to (and computed in the same way as) the hints we
should during a failed resolution, but for install-time.

Closes #10635.

## Test Plan

As an example, when installing PyTorch on macOS with Python 3.13 (wheels
exist for Linux):

```
error: Distribution `torch==2.5.1 @ registry+https://pypi.org/simple` can't be installed because it doesn't have a source distribution or wheel for the current platform

hint: You're on macOS (`macosx_14_0_arm64`), but `torch` (v2.5.1) only has wheels for the following platform: `manylinux1_x86_64`
```
2025-01-20 12:46:46 -05:00
Zanie Blue 4f31b44eac
Improve log when distutils is missing (#10713)
See https://github.com/astral-sh/uv/issues/4204 for motivation

This doesn't really reach the user experience I'd expect — i.e., we end
up saying a virtual environment "does not exist" which is a little
silly. However, I think improving the error messaging on interpreter
queries in general should be solved separately. I did one small
"general" change in
89e11d0222
— otherwise we don't show the message at all.

---------

Co-authored-by: konsti <konstin@mailbox.org>
2025-01-20 17:29:29 +00:00
Charlie Marsh 8b6383ebe8
Avoid respecting preferences from other indexes (#10782)
## Summary

The fix I shipped in https://github.com/astral-sh/uv/pull/10690
regressed an important case. If we solve a PyPI branch before a PyTorch
branch, we'll end up respecting the preference, and choosing `2.2.2`
instead of `2.2.2+cpu`.

This PR goes back to ignoring preferences that don't map to the current
index. However, to solve https://github.com/astral-sh/uv/issues/10383,
we need to special-case `requirements.txt`, which can't provide explicit
indexes. So, if a preference comes from `requirements.txt`, we still
respect it.

Closes https://github.com/astral-sh/uv/issues/10772.
2025-01-20 12:23:00 -05:00
Charlie Marsh 9e6e1e56fd
Add a GitHub repository struct to `uv-git` (#10768)
## Summary

This is useful for https://github.com/astral-sh/uv/pull/10765, but we
already have one usage today, so carving it out into a standalone PR.
2025-01-20 14:39:05 +00:00
konsti b40fa912e0
Ignore lockfile in ecosystem tests (#10775) 2025-01-20 10:34:46 +00:00
Charlie Marsh c0bde88f6c
Remove TOCTOU errors in Git clone (#10758)
## Summary

We should try to remove, then fail gracefully, rather than checking
existence.
2025-01-19 20:31:15 -05:00
Charlie Marsh 23e892011c
Remove URL conversions in Git path (#10757)
## Summary

We convert from `Url` to `&str` back to `Url`.
2025-01-19 23:00:42 +00:00
Charlie Marsh 5e5cb8797d
Remove unused Git resolver methods (#10754) 2025-01-19 17:02:53 +00:00
Charlie Marsh c306e46e1d
Remove trailing commas before brackets (#10740) 2025-01-18 19:56:46 +00:00
Charlie Marsh ae366ccd0e
Remove unnecessary clone on package name (#10741) 2025-01-18 19:45:19 +00:00
Charlie Marsh 35aec8863e
Use colors for lock errors (#10736)
## Summary

These now better match the errors we show when failing to resolve.
2025-01-18 18:50:20 +00:00
Charlie Marsh 3fe4e7168b
Use short-form for platform tag checks (#10737) 2025-01-18 18:22:09 +00:00
Charlie Marsh 1bfa7230fc
Correct documentation for wheel tag hints (#10735)
These were copy-pasted by accident.
2025-01-18 18:13:21 +00:00
Charlie Marsh ddff891397
Use iterators rather than eagerly collecting tags (#10734) 2025-01-18 13:11:48 -05:00
Charlie Marsh 4f807473d3
Avoid using NumPy, Pandas, etc. in tool tests (#10725)
## Summary

Closes https://github.com/astral-sh/uv/issues/10645.
2025-01-17 18:20:26 -05:00
Charlie Marsh 3478c068bb
Bump version to v0.5.21 (#10723) 2025-01-17 20:53:36 +00:00
Charlie Marsh a7f67e877c
Avoid attempting to patch macOS dylib for non-macOS installs (#10721)
## Summary

For example, `cargo run python install
cpython-3.12.8-linux-x86_64_v3-gnu` (on macOS) shouldn't attempt to
patch the dylib. At present, it leads to this warning:

```
warning: Failed to patch the install name of the dynamic library for /Users/crmarsh/.local/share/uv/python/cpython-3.12.8-linux-x86_64_v3-gnu/bin/python3.12. This may cause issues when building Python native extensions.
Underlying error: Failed to update the install name of the Python dynamic library located at `/Users/crmarsh/.local/share/uv/python/cpython-3.12.8-linux-x86_64_v3-gnu/lib/libpython3.12.dylib`
```
2025-01-17 19:21:32 +00:00