Commit graph

923 commits

Author SHA1 Message Date
Charlie Marsh
b14696ca7c
Show a dedicated PubGrub hint for --unsafe-best-match (#7645)
## Summary

Closes https://github.com/astral-sh/uv/issues/5510.
2024-09-23 19:02:19 +00:00
Luca Bruno
2c6d353711
Provide resolution hints in case of possible local name conflicts (#7505)
This enhances the hints generator in the resolver with some heuristic to
detect and warn in case of failures due to version mismatches on a local
package. Those may be the symptom of name conflict/shadowing with a
transitive dependency.

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

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-09-20 13:07:34 -05:00
Luca Bruno
248bef13bd
Compute resolver hints using the final reduced derivation tree (#7546)
This switches the no-solution formatter to use the final derivation tree
(simplified and reduced) when generating hints.
2024-09-19 16:06:55 +02:00
Andrew Gallant
1379b530f6 uv: migrate to rkyv 0.8
Recently, rkyv 0.8 was released. Its API is a fair bit simpler now for
higher level uses (like for us in `uv`) and results in us being able to
delete a fair bit of code. This also removes our last dependency on `syn
1.0`, and thus drops that dependency.

Performance (via testing on the `transformers` example) seems to remain
about the same, which is what was expected:

```
$ hyperfine -w5 -r100 'uv lock' 'uv-ag-rkyv-update lock'
Benchmark 1: uv lock
  Time (mean ± σ):      55.6 ms ±   6.4 ms    [User: 30.4 ms, System: 35.1 ms]
  Range (min … max):    43.0 ms …  73.1 ms    100 runs

Benchmark 2: uv-ag-rkyv-update lock
  Time (mean ± σ):      56.5 ms ±   7.2 ms    [User: 30.5 ms, System: 36.3 ms]
  Range (min … max):    39.1 ms …  71.5 ms    100 runs

Summary
  uv lock ran
    1.02 ± 0.18 times faster than uv-ag-rkyv-update lock
```

Closes #7415
2024-09-18 14:49:54 -04:00
Luca Bruno
67cfb4a9c0
Use a single buffer for hints on resolver errors (#7497)
This changes the structure of the hints generator in the resolver when
encountering solution errors, so that it re-uses a single output buffer
owned by the caller.
It avoids repeated allocations of a temporary buffer within each
recursive function call.
2024-09-18 16:16:22 +02:00
Charlie Marsh
fda227616c
Allow users to provide pre-defined metadata for resolution (#7442)
## Summary

This PR enables users to provide pre-defined static metadata for
dependencies. It's intended for situations in which the user depends on
a package that does _not_ declare static metadata (e.g., a
`setup.py`-only sdist), and that is expensive to build or even cannot be
built on some architectures. For example, you might have a Linux-only
dependency that can't be built on ARM -- but we need to build that
package in order to generate the lockfile. By providing static metadata,
the user can instruct uv to avoid building that package at all.

For example, to override all `anyio` versions:

```toml
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["anyio"]

[[tool.uv.dependency-metadata]]
name = "anyio"
requires-dist = ["iniconfig"]
```

Or, to override a specific version:

```toml
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["anyio"]

[[tool.uv.dependency-metadata]]
name = "anyio"
version = "3.7.0"
requires-dist = ["iniconfig"]
```

The current implementation uses `Metadata23` directly, so we adhere to
the exact schema expected internally and defined by the standards. Any
entries are treated similarly to overrides, in that we won't even look
for `anyio@3.7.0` metadata in the above example. (In a way, this also
enables #4422, since you could remove a dependency for a specific
package, though it's probably too unwieldy to use in practice, since
you'd need to redefine the _rest_ of the metadata, and do that for every
package that requires the package you want to omit.)

This is under-documented, since I want to get feedback on the core ideas
and names involved.

Closes https://github.com/astral-sh/uv/issues/7393.
2024-09-18 03:18:05 +00:00
Charlie Marsh
778da3350a
Add --no-editable support to uv sync and uv export (#7371)
## Summary

Closes https://github.com/astral-sh/uv/issues/5792.
2024-09-17 14:50:36 +00:00
Charlie Marsh
c87ce7aaf8
Run cargo upgrade (#7448)
Co-authored-by: konstin <konstin@mailbox.org>
2024-09-17 12:39:58 +02:00
Charlie Marsh
424ee439d6
Use consistent PyPI cache bucket (#7443)
## Summary

All the registry wheels were getting cached under
`index/b2a7eb67d4c26b82` rather than `pypi`, because we used
`IndexUrl::Url` rather than `IndexUrl::from`.
2024-09-16 23:33:32 +00:00
Charlie Marsh
5f2e536925
Add support for --only-dev to uv sync and uv export (#7367)
## Summary

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

Closes https://github.com/astral-sh/uv/issues/6472.
2024-09-16 20:06:20 +00:00
Charlie Marsh
54f171c80a
Use unambiguous relative paths in uv export (#7378) 2024-09-13 20:48:46 +00:00
Charlie Marsh
d52af0ccdd
Avoid installing transitive dev dependencies (#7318)
## Summary

This is arguably breaking, arguably a bug... Today, if project A depends
on project B, and you install A with dev dependencies enabled, you also
get B's dev dependencies. I think this is incorrect. Just like you
shouldn't be importing B's dependencies from A, you shouldn't be using
B's dev dependencies when developing on A.

Closes #7310.
2024-09-12 09:20:43 -04:00
Charlie Marsh
c124cda098
Add dedicated lock errors for wheel-only distributions (#7307) 2024-09-11 14:53:08 -05:00
Charlie Marsh
1a3ec9d04f
Avoid enforcing platform compatibility when validating lockfile (#7305)
## Summary

We have to call `to_dist` to get metadata while validating the lockfile,
but some of the distributions won't match the current platform -- and
that's fine!
2024-09-11 19:17:07 +00:00
Charlie Marsh
575eb65a20
Avoid treating .whl sources as source distributions (#7303)
## Summary

The error messages here are incorrect.

Closes https://github.com/astral-sh/uv/issues/7284.
2024-09-11 15:10:04 -04:00
Charlie Marsh
15792a3775
Apply --no-install options when constructing resolution (#7277)
## Summary

We need to apply the `--no-install` filters earlier, such that we don't
error if we only have a source distribution for a given package when
`--no-build` is provided but that package is _omitted_.

Closes #7247.
2024-09-11 14:31:24 -04:00
konsti
2b3890f2b4
Extract METADATA reading into a crate (#7231)
This is preparatory work for the upload functionality, which needs to
read the METADATA file and attach its parsed contents to the POST
request: We move finding the `.dist-info` from `install-wheel-rs` and
`uv-client` to a new `uv-metadata` crate, so it can be shared with the
publish crate.

I don't properly know if its the right place since the upload code isn't
ready, but i'm PR-ing it now because it already had merge conflicts.
2024-09-10 13:31:01 +00:00
Charlie Marsh
9a7262c360
Avoid batch prefetching for un-optimized registries (#7226)
## Summary

We now track the discovered `IndexCapabilities` for each `IndexUrl`. If
we learn that an index doesn't support range requests, we avoid doing
any batch prefetching.

Closes https://github.com/astral-sh/uv/issues/7221.
2024-09-09 15:46:19 -04:00
Charlie Marsh
dcbaa1f486
Avoid iteration for singleton selections (#7195)
## Summary

If we have a singleton `Range`, we don't need to iterate over the map of
available ranges; instead, we can just get the singleton directly.

Closes #6131.
2024-09-09 13:43:57 +00:00
Charlie Marsh
dafa3596c5
Avoid distribution clones in requirements.txt graph (#7210) 2024-09-09 13:31:13 +00:00
Charlie Marsh
b738b35910
Prune unreachable packages from --universal output (#7209)
## Summary

Closes https://github.com/astral-sh/uv/issues/7196.
2024-09-09 09:20:25 -04:00
Charlie Marsh
4466402214
DRY up exclusion checks in selector (#7194) 2024-09-08 17:42:41 +00:00
Andrew Gallant
f6bc701ac3 uv-resolver: use new simplify/complexify marker routines
This finally gets rid of our hack for working around "hidden"
state. We no longer do a roundtrip marker serialization and
deserialization just to avoid the hidden state.
2024-09-07 13:46:02 -04:00
Charlie Marsh
7d49fbc753
Skip metadata fetch for --no-deps and pip sync (#7127)
## Summary

I think a better tradeoff here is to skip fetching metadata, even though
we can't validate the extras.

It will help with situations like
https://github.com/astral-sh/uv/issues/5073#issuecomment-2334235588 in
which, otherwise, we have to download the wheels twice.
2024-09-06 21:26:28 -04:00
Amos Wenger
5e1b9b1964
chore: Remove dep on derivative (#7133)
(This is part of #5711)

## Summary

@BurntSushi and I spotted that the `derivative` crate is only used for
one enum in the entire codebase — however, it's a proc macro, and we pay
for the cost of (re)compiling it in many different contexts.

This replaces it with a private `Inner` core which uses the regular std
derive macros — inlining and optimizations should make this equivalent
to the other implementation, and not too hard to maintain hopefully
(versus a manual impl of `PartialEq` and `Hash` which have to be kept in
sync.)

## Test Plan

Trust CI?
2024-09-06 17:46:56 -04:00
Charlie Marsh
6ae005b0d0
Add --no-emit-project and friends to uv export (#7110)
## Summary

Like `uv sync`, you can omit the current project (`--no-emit-project`),
a specific package (`--no-emit-package`), or the entire workspace
(`--no-emit-workspace`).

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

Closes #6995.
2024-09-06 01:01:46 +00:00
Charlie Marsh
58b25b560c
Invalidate lockfile when member versions change (#7102)
## Summary

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

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-09-05 17:14:57 -05:00
Charlie Marsh
29f53c3c63
Support --no-build and --no-binary in uv sync et al (#7100)
## Summary

This option already existed, but `--no-binary` always errored.

Closes https://github.com/astral-sh/uv/issues/7099.
2024-09-05 21:45:42 +00:00
konsti
750e8b1e2f
Remove propagate_markers (#7076)
Follow-up to #6959 and #6961: Use the reachability computation instead
of `propagate_markers` everywhere.

With `marker_reachability`, we have a function that computes for each
node the markers under which it is (`requirements.txt`, no markers
provided on installation) or can be (`uv.lock`, depending on the markers
provided on installation) included in the installation. Put differently:
If the marker computed by `marker_reachability` is not fulfilled for the
current platform, the package is never required on the current platform.

We compute the markers for each package in the graph, this includes the
virtual extra packages and the base packages. Since we know that each
virtual extra package depends on its base package (`foo[bar]` implied
`foo`), we only retain the base package marker in the `requirements.txt`
graph.

In #6959/#6961 we were only using it for pruning packages in `uv.lock`,
now we're also using it for the markers in `requirements.txt`.

I think this closes #4645, CC @bluss.
2024-09-05 16:52:21 +00:00
konsti
d5eb6eb12c
Move reachability function (#7091)
Split out from #7076
2024-09-05 16:44:21 +00:00
Charlie Marsh
d91f7ddf5f
Don't include registry hashes for URL distributions (#7086)
The opposite _can_ be true.
2024-09-05 11:42:07 -04:00
Charlie Marsh
a20fecedaa
Strip fragments from direct source URLs in lockfile (#7061)
## Summary

In resolving https://github.com/astral-sh/uv/issues/7059, I noticed that
we left the fragment on the `source = { url = "..." }`.
2024-09-05 02:05:39 +00:00
Charlie Marsh
1f7a9a7407
Use distribution hash over registry hash (#7060)
## Summary

We need to prioritize hashes for the distribution over hashes for the
related packages.

I think this needs to be redone entirely though. I can see other issues
with the current approach.

Closes https://github.com/astral-sh/uv/issues/7059.
2024-09-05 01:58:21 +00:00
Charlie Marsh
1ccc15e7bb
Use correct ordering semantics for narrowing upper-bounded Python requirements (#7031)
## Summary

We need to use different ordering semantics for upper and lower Python
bounds.

Closes https://github.com/astral-sh/uv/issues/6911.
2024-09-04 15:57:14 +00:00
konsti
c9787f9fd8
Prune unreachable wheels from lockfile (#6961)
When a package is included under a platform-specific marker, we know
that wheels that mismatch this marker can never be installed, so we drop
them from the lockfile.
2024-09-04 11:08:37 +02:00
konsti
b9f2bd155a
Prune unreachable packages from lockfile (#6959)
In transformers, we have:

* `tensorflow-text`: `tensorflow-macos; python_full_version >= '3.13'
and platform_machine == 'arm64' and platform_system == 'Darwin'`
* `tensorflow-macos`: `tensorflow-cpu-aws; (python_full_version < '3.10'
and platform_machine == 'aarch64' and platform_system == 'Linux') or
(python_full_version >= '3.13' and platform_machine == 'aarch64' and
platform_system == 'Linux') or (python_full_version >= '3.13' and
platform_machine == 'arm64' and platform_system == 'Linux')`
* `tensorflow-macos`: `tensorflow-intel; python_full_version >= '3.13'
and platform_system == 'Windows'`

This means that `tensorflow-cpu-aws` and `tensorflow-intel` can never be
installed, and we can drop them from the lockfile.
2024-09-04 10:57:42 +02:00
Andrew Gallant
2aeb51eebb uv-resolver: update snapshot tests with new Debug repr for Dependency
A `Dependency` now has both "simplified" and "complexified" markers, so
just update the snapshots to match the new reality.
2024-09-03 18:41:15 -04:00
Andrew Gallant
4ff057e108 uv-resolver: refactor how we deal with requires-python
This commit refactors how deal with `requires-python` so that instead of
simplifying markers of dependencies inside the resolver, we do it at the
edges of our system. When writing markers to output, we simplify when
there's an obvious `requires-python` context. And when reading markers
as input, we complexity markers with the relevant `requires-python`
constraint.
2024-09-03 18:41:15 -04:00
Andrew Gallant
94a0a0f2ee uv-resolver: rejigger 'trace_resolution'
When I first wrote this routine, it was intended to only emit a trace
for the final "unioned" resolution. But we actually moved that semantic
operation to the construction of the resolution *graph*. So there is no
unioned `Resolution` any more.

But this is still useful to see. So I changed this to just emit a trace
of *every* resolution right before constructing the graph.

It might be nice to also emit a trace of the unioned graph too. Or
perhaps we should do that instead if this proves too noisy. (Although
this is only emitted at TRACE level.)
2024-09-03 18:41:15 -04:00
konsti
9e34c42cec
Move unreachable wheels check (#6957)
Prep for fixing #6512. No functional changes.
2024-09-03 07:48:54 +00:00
Charlie Marsh
ccdf2d793b
Add --no-hashes to uv export (#6954)
## Summary

Closes https://github.com/astral-sh/uv/issues/6944.
2024-09-02 22:12:29 -04:00
Charlie Marsh
f9c04581e6
Allow uv sync --package without copying member pyproject.toml (#6943)
## Summary

Closes https://github.com/astral-sh/uv/issues/6935.
2024-09-02 21:01:50 +00:00
Charlie Marsh
8eef1a2314
Use lower-bound semantics for all Python compatibility comparisons (#6882)
## Summary

Right now, we have slightly different `requires-python` semantics for
`-p 3.11` vs. `-p 3.11 --universal`, and slightly different (wrong)
semantics for how we compare against the _installed_ Python version
(which doesn't ignore upper bounds, but should).

This PR rips it all out and replaces it with consistent semantics across
`uv lock`, `uv pip compile -p 3.11`, and `uv pip compile -p 3.11
--universal`. We now always ignore upper bounds.

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

Closes https://github.com/astral-sh/uv/issues/5045.
2024-09-02 18:23:42 +00:00
Ed Morley
a5f1e1c765
Fix typos in docs, error messages and comments (#6910) 2024-09-01 11:37:43 +00:00
Charlie Marsh
3e647b139e
Fix is_disjoint check for supported environments (#6902) 2024-08-31 19:01:47 -04:00
konsti
00c98a82b0
Use from_range_bounds (#6879)
Not the most ergonomic api pubgrub has to offer, but better than rolling
our own.
2024-08-30 16:06:55 -04:00
Charlie Marsh
9f8ebca941
Error when user-provided environments are disjoint with Python (#6841) 2024-08-29 20:18:30 -04:00
Charlie Marsh
34d74501ac
Respect the user's upper-bound in requires-python (#6824)
## Summary

We now respect the user-provided upper-bound in for `requires-python`.
So, if the user has `requires-python = "==3.11.*"`, we won't explore
forks that have `python_version >= '3.12'`, for example.

However, we continue to _only_ compare the lower bounds when assessing
whether a dependency is compatible with a given Python range.

Closes https://github.com/astral-sh/uv/issues/6150.
2024-08-29 18:37:05 +00:00
Charlie Marsh
cbfc928a9c
Add uv export --format requirements.txt (#6778)
## Summary

The interface here is intentionally a bit more limited than `uv pip
compile`, because we don't want `requirements.txt` to be a system of
record -- it's just an export format. So, we don't write annotation
comments (i.e., which dependency is requested from which), we don't
allow writing extras, etc. It's just a flat list of requirements, with
their markers and hashes.

Closes #6007.

Closes #6668.

Closes #6670.
2024-08-29 17:46:42 +00:00
Charlie Marsh
c166e65ba6
Move lock.rs into its own module (#6775)
## Summary

Desperately need the ability to start splitting up code here.
2024-08-28 18:04:45 -04:00