380 Commits

Author SHA1 Message Date
Zanie Blue
1512e07a2e Split configuration options out of uv-types (#2924)
Needed to prevent circular dependencies in my toolchain work (#2931). I
think this is probably a reasonable change as we move towards persistent
configuration too?

Unfortunately `BuildIsolation` needs to be in `uv-types` to avoid
circular dependencies still. We might be able to resolve that in the
future.
2024-04-09 11:35:53 -05:00
Charlie Marsh
a4f5a7d233 Bump version to v0.1.30 (#2934) 2024-04-09 12:06:11 -04:00
Zanie Blue
f42013214a Restore lockfile (#2914)
Accidentally reverted the lockfile in
538c88130e

Closes #2912 
Closes #2910 
Closes #2913
2024-04-08 21:25:33 +00:00
Zanie Blue
538c88130e Group pyo3 dependency updates (#2889)
Seems needed for https://github.com/astral-sh/uv/pull/2879
2024-04-08 16:06:55 -05:00
Zanie Blue
bdeab55193 Add extract support for zstd (#2861)
We need this to extract toolchain downloads
2024-04-08 15:34:08 -05:00
renovate[bot]
47333c985b Update Rust crate tokio to v1.37.0 (#2886) 2024-04-08 09:35:00 -04:00
Zanie Blue
b181907ad2 Fix linehaul tests (#2891)
Cleans up the assertions a bit. I looked into snapshot tests per #2564
but it didn't seem worth it for cross-platform tests.

Closes #2564 
Closes https://github.com/astral-sh/uv/pull/2878
2024-04-07 23:42:19 -05:00
renovate[bot]
61e06bb2c3 Update Rust crate rayon to v1.10.0 (#2880) 2024-04-07 22:54:40 -05:00
renovate[bot]
a866cb2f32 Update Rust crate insta to v1.38.0 (#2877) 2024-04-07 22:54:16 -05:00
renovate[bot]
f0c83a4ded Update Rust crate base64 to 0.22.0 (#2874) 2024-04-08 03:02:35 +00:00
renovate[bot]
f5334a4914 Update Rust crate which to v6.0.1 (#2873) 2024-04-07 22:38:15 -04:00
renovate[bot]
74371ede8d Update Rust crate tokio-stream to v0.1.15 (#2872) 2024-04-07 22:37:59 -04:00
renovate[bot]
a4bbe6602f Update Rust crate serde_json to v1.0.115 (#2871) 2024-04-07 22:37:51 -04:00
renovate[bot]
56555b9911 Update Rust crate indexmap to v2.2.6 (#2868) 2024-04-07 22:37:39 -04:00
renovate[bot]
78d64bfc86 Update Rust crate axoupdater to v0.3.6 (#2866) 2024-04-08 02:29:03 +00:00
renovate[bot]
14ef0e044c Update Rust crate regex to v1.10.4 (#2870) 2024-04-08 02:28:47 +00:00
renovate[bot]
8e7f9b18c5 Update Rust crate git2 to v0.18.3 (#2867) 2024-04-08 02:28:21 +00:00
renovate[bot]
d34c90150d Update Rust crate async-compression to v0.4.8 (#2865) 2024-04-08 02:28:04 +00:00
Charlie Marsh
00934044aa Backtrack on distributions with invalid metadata (#2834)
## Summary

Closes https://github.com/astral-sh/uv/issues/2821.
2024-04-05 18:00:48 -04:00
Charlie Marsh
365cb16fd6 Bump version to v0.1.29 (#2825) 2024-04-04 15:50:52 -04:00
Charlie Marsh
dc2c289dff Upgrade rs-async-zip to support data descriptors (#2809)
## Summary

Upgrading `rs-async-zip` enables us to support data descriptors in
streaming. This both greatly improves performance for indexes that use
data descriptors _and_ ensures that we support them in a few other
places (e.g., zipped source distributions created in Finder).

Closes #2808.
2024-04-04 01:31:40 +00:00
Charlie Marsh
34341bd6e9 Allow package lookups across multiple indexes via explicit opt-in (#2815)
## Summary

This partially revives https://github.com/astral-sh/uv/pull/2135 (with
some modifications) to enable users to opt-in to looking for packages
across multiple indexes.

The behavior is such that, in version selection, we take _any_
compatible version from a "higher-priority" index over the compatible
versions of a "lower-priority" index, even if that means we might accept
an "older" version.

Closes https://github.com/astral-sh/uv/issues/2775.
2024-04-03 23:23:37 +00:00
Zanie Blue
0046a0d596 Bump version to 0.1.28 (#2785) 2024-04-02 21:39:35 +00:00
Charlie Marsh
f60e7495ca Bump version to v0.1.27 (#2758) 2024-04-01 14:54:50 -04:00
renovate[bot]
9df6e33b85 Update Rust crate clap to v4.5.4 (#2754) 2024-04-01 09:12:52 +01:00
renovate[bot]
35aa80c149 Update Rust crate chrono to v0.4.37 (#2753) 2024-04-01 08:27:11 +01:00
renovate[bot]
0c13eaabe0 Update Rust crate cargo-util to v0.2.10 (#2748) 2024-04-01 02:14:30 +00:00
renovate[bot]
ca2a6bb728 Update Rust crate async-trait to v0.1.79 (#2747) 2024-04-01 02:13:23 +00:00
Charlie Marsh
6d5b5ae9a2 Use distinct Constraints and Overrides types more widely (#2741)
## Summary

No functional changes.
2024-03-31 13:46:37 -04:00
Zanie Blue
e1878c8359 Consider installed packages during resolution (#2596)
Previously, we did not consider installed distributions as candidates
while performing resolution. Here, we update the resolver to use
installed distributions that satisfy requirements instead of pulling new
distributions from the registry.

The implementation details are as follows:

- We now provide `SitePackages` to the `CandidateSelector`
- If an installed distribution satisfies the requirement, we prefer it
over remote distributions
- We do not want to allow installed distributions in some cases, i.e.,
upgrade and reinstall
- We address this by introducing an `Exclusions` type which tracks
installed packages to ignore during selection
- There's a new `ResolvedDist` wrapper with `Installed(InstalledDist)`
and `Installable(Dist)` variants
- This lets us pass already installed distributions throughout the
resolver

The user-facing behavior is thoroughly covered in the tests, but
briefly:

- Installing a package that depends on an already-installed package
prefers the local version over the index
- Installing a package with a name that matches an already-installed URL
package does not reinstall from the index
- Reinstalling (--reinstall) a package by name _will_ pull from the
index even if an already-installed URL package is present
- To reinstall the URL package, you must specify the URL in the request

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

Addresses:

- https://github.com/astral-sh/uv/issues/1476
- https://github.com/astral-sh/uv/issues/1856
- https://github.com/astral-sh/uv/issues/2093
- https://github.com/astral-sh/uv/issues/2282
- https://github.com/astral-sh/uv/issues/2383
- https://github.com/astral-sh/uv/issues/2560

## Test plan

- [x] Reproduction at `charlesnicholson/uv-pep420-bug` passes
- [x] Unit test for editable package
([#1476](https://github.com/astral-sh/uv/issues/1476))
- [x] Unit test for previously installed package with empty registry
- [x] Unit test for local non-editable package
- [x] Unit test for new version available locally but not in registry
([#2093](https://github.com/astral-sh/uv/issues/2093))
- ~[ ] Unit test for wheel not available in registry but already
installed locally
([#2282](https://github.com/astral-sh/uv/issues/2282))~ (seems
complicated and not worthwhile)
- [x] Unit test for install from URL dependency then with matching
version ([#2383](https://github.com/astral-sh/uv/issues/2383))
- [x] Unit test for install of new package that depends on installed
package does not change version
([#2560](https://github.com/astral-sh/uv/issues/2560))
- [x] Unit test that `pip compile` does _not_ consider installed
packages
2024-03-28 13:49:17 -05:00
Zanie Blue
ffa1b01176 Bump version to 0.1.26 (#2713) 2024-03-28 12:55:36 -05:00
Zanie Blue
4e59bfd16e Bump version to 0.1.25 (#2709)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-03-28 10:17:52 -05:00
Charlie Marsh
4b69ad4281 Remove some unused dependencies (#2698) 2024-03-27 17:50:55 -04:00
Charlie Marsh
8c7a6038fd Update Rust to v1.77 (#2591) 2024-03-27 14:41:27 +00:00
Charlie Marsh
365c292525 Read package metadata from pyproject.toml when statically defined (#2676)
## Summary

Now that we're resolving metadata more aggressively for local sources,
it's worth doing this. We now pull metadata from the `pyproject.toml`
directly if it's statically-defined.

Closes https://github.com/astral-sh/uv/issues/2629.
2024-03-27 14:34:18 +00:00
Charlie Marsh
ffd78d0821 Add an in-memory cache for Git references (#2682)
## Summary

Ensures that, even if we try to resolve the same Git reference twice
within an invocation, it always returns a (cached) consistent result.

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

## Test Plan

```
❯ cargo run pip install git+https://github.com/pallets/flask.git --reinstall --no-cache
   Compiling uv-distribution v0.0.1 (/Users/crmarsh/workspace/uv/crates/uv-distribution)
   Compiling uv-resolver v0.0.1 (/Users/crmarsh/workspace/uv/crates/uv-resolver)
   Compiling uv-installer v0.0.1 (/Users/crmarsh/workspace/uv/crates/uv-installer)
   Compiling uv-dispatch v0.0.1 (/Users/crmarsh/workspace/uv/crates/uv-dispatch)
   Compiling uv-requirements v0.1.0 (/Users/crmarsh/workspace/uv/crates/uv-requirements)
   Compiling uv v0.1.24 (/Users/crmarsh/workspace/uv/crates/uv)
    Finished dev [unoptimized + debuginfo] target(s) in 3.95s
     Running `target/debug/uv pip install 'git+https://github.com/pallets/flask.git' --reinstall --no-cache`
 Updated https://github.com/pallets/flask.git (b90a4f1)
Resolved 7 packages in 280ms
   Built flask @ git+https://github.com/pallets/flask.git@b90a4f1f4a370e92054b9cc9db0efcb864f87ebe                                                                                                                                            Downloaded 7 packages in 212ms
Installed 7 packages in 9ms
```
2024-03-27 01:39:01 +00:00
Charlie Marsh
32d8ee8ba3 Add --no-binary and --only-binary support to requirements.txt (#2680)
## Summary

Closes https://github.com/astral-sh/uv/issues/1461.
2024-03-27 01:12:29 +00:00
Zanie Blue
0b08ba1e67 Rename uv-traits and split into separate modules (#2674)
This is driving me a little crazy and is becoming a larger problem in
#2596 where I need to move more types (like `Upgrade` and `Reinstall`)
into this crate. Anything that's shared across our core resolver,
install, and build crates needs to be defined in this crate to avoid
cyclic dependencies. We've outgrown it being a single file with some
shared traits.

There are no behavioral changes here.
2024-03-26 15:39:43 -05:00
Charlie Marsh
39769d82a0 Fall back to PEP 517 hooks for non-compliant PEP 621 metadata (#2662)
If you pass a `pyproject.toml` that use Hatch's context formatting API,
we currently fail because the dependencies aren't valid under PEP 508.
This PR makes the static metadata parsing a little more relaxed, so that
we appropriately fall back to PEP 517 there.
2024-03-26 02:28:39 +00:00
Charlie Marsh
71428f7d74 Use PEP 517 to extract non-static pyproject.toml metadata (#2633)
## Summary

When a user passes a `pyproject.toml` to `pip compile` (e.g., `uv pip
compile pyproject.toml`), we extract the requirements from the
`pyproject.toml` directly. However... that isn't always possible (as
seen in the linked issues). When it's _not_, we instead need to run the
PEP 517 build hooks to identify the metadata.

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

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

## Test Plan

`cargo test`
2024-03-25 20:27:41 +00:00
Charlie Marsh
f3753347e0 Add rustc-hash to uv crate (#2660)
## Summary

This is required as of https://github.com/astral-sh/uv/pull/2589, but
isn't a direct dependency. I'm not sure how that PR passed CI exactly.
2024-03-25 20:21:43 +00:00
konsti
33bde826a0 Update pubgrub to use a dependency provider (#2648)
With https://github.com/pubgrub-rs/pubgrub/pull/190, pubgrub attaches
all types to a dependency provider to reduce the number of generics. We
need a dummy dependency provider now to emulate this. On the plus side,
pep440_rs drops its pubgrub dependency.
2024-03-25 15:51:31 +01:00
Hans Baker
a632d2485b Don't error on multiple matching index URLs (#2627)
## Summary

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

## Test Plan

```
cargo run -- pip install -r dev-requirements.txt -r requirements.txt
```
where both requirements files have same `--index-url`
2024-03-22 23:37:02 +00:00
Zanie Blue
a5cae02922 Bump version to 0.1.24 (#2621) 2024-03-22 14:58:10 -05:00
konsti
48bd02b8a8 Update miette v7, pubgrub and small Cargo.toml cleanup (#2610)
I was going through the output of `cargo tree --duplicate -p uv`, not
much success except these small cleanups.
2024-03-22 10:42:48 +00:00
konsti
375b33ff0c Remove unused deps with cargo machete (#2609) 2024-03-22 10:01:17 +00:00
Charlie Marsh
0ea51d43f5 Add progress reporting for named requirement resolution (#2605) 2024-03-22 04:01:10 +00:00
Charlie Marsh
31743f2bd8 Use PEP 517 build hooks to resolve unnamed requirements (#2604) 2024-03-22 03:20:40 +00:00
Charlie Marsh
5d7d7dce24 Enable PEP 517 builds for unnamed requirements (#2600)
## Summary

This PR enables the source distribution database to be used with unnamed
requirements (i.e., URLs without a package name). The (significant)
upside here is that we can now use PEP 517 hooks to resolve unnamed
requirement metadata _and_ reuse any computation in the cache.

The changes to `crates/uv-distribution/src/source/mod.rs` are quite
extensive, but mostly mechanical. The core idea is that we introduce a
new `BuildableSource` abstraction, which can either be a distribution,
or an unnamed URL:

```rust
/// A reference to a source that can be built into a built distribution.
///
/// This can either be a distribution (e.g., a package on a registry) or a direct URL.
///
/// Distributions can _also_ point to URLs in lieu of a registry; however, the primary distinction
/// here is that a distribution will always include a package name, while a URL will not.
#[derive(Debug, Clone, Copy)]
pub enum BuildableSource<'a> {
    Dist(&'a SourceDist),
    Url(SourceUrl<'a>),
}
```

All the methods on the source distribution database now accept
`BuildableSource`. `BuildableSource` has a `name()` method, but it
returns `Option<&PackageName>`, and everything is required to work with
and without a package name.

The main drawback of this approach (which isn't a terrible one) is that
we can no longer include the package name in the cache. (We do continue
to use the package name for registry-based distributions, since those
always have a name.). The package name was included in the cache route
for two reasons: (1) it's nice for debugging; and (2) we use it to power
`uv cache clean flask`, to identify the entries that are relevant for
Flask.

To solve this, I changed the `uv cache clean` code to look one level
deeper. So, when we want to determine whether to remove the cache entry
for a given URL, we now look into the directory to see if there are any
wheels that match the package name. This isn't as nice, but it does work
(and we have test coverage for it -- all passing).

I also considered removing the package name from the cache routes for
non-registry _wheels_, for consistency... But, it would require a cache
bump, and it didn't feel important enough to merit that.
2024-03-21 22:46:39 -04:00
Charlie Marsh
63a8bc2b8f Bump axoupdater to v0.3.3 to fix Windows self-updates (#2598)
Closes #2585.
2024-03-21 16:58:57 -04:00