Commit Graph

1446 Commits

Author SHA1 Message Date
Charlie Marsh 3e04fdb8ae
Allow quotes around command-line options in `requirement.txt files` (#11644)
## Summary

Closes #11592.
2025-02-20 12:13:09 -08:00
konsti f9b638a296
Use install concurrency for bytecode compilation too (#11615)
Instead of always using all available threads for bytecode compilation,
respect `UV_CONCURRENT_INSTALLS`, so the parallelism is configurable
instead of hardcoded. We reuse the install limit since bytecode
compilation only runs after install.
2025-02-20 12:23:40 +01:00
Zanie Blue 6d3614eece
Bump version to 0.6.2 (#11630) 2025-02-19 13:11:11 -06:00
konsti 29c2be3e97
Eagerly reject unsupported Git schemes (#11514)
Initially, we were limiting Git schemes to HTTPS and SSH as only
supported schemes. We lost this validation in #3429. This incidentally
allowed file schemes, which apparently work with Git out of the box.

A caveat for this is that in tool.uv.sources, we parse the git field
always as URL. This caused a problem with #11425: repo = { git =
'c:\path\to\repo', rev = "xxxxx" } was parsed as a URL where c: is the
scheme, causing a bad error message down the line.

This PR:

* Puts Git URL validation back in place. It bans everything but HTTPS,
SSH, and file URLs. This could be a breaking change, if users were using
a git transport protocol were not aware of, even though never
intentionally supported.
* Allows file: URL in Git: This seems to be supported by Git and we were
supporting it albeit unintentionally, so it's reasonable to continue to
support it.
* It does not allow relative paths in the git field in tool.uv.sources.
Absolute file URLs are supported, whether we want relative file URLs for
Git too should be discussed separately.

Closes #3429: We reject the input with a proper error message, while
hinting the user towards file:. If there's still desire for relative
path support, we can keep it open.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2025-02-18 02:14:06 +00:00
Zanie Blue c91ee82a82
Bump version to 0.6.1 (#11580) 2025-02-17 11:57:47 -06:00
konsti 90e9287dd8
Warn for builds in non-build and workspace root pyproject.toml (#11394)
When running `uv pip install .` in a directory with a pyproject.toml
that does not configure a build, we will invoke setuptools and get a
wheel we can't parse (https://github.com/astral-sh/uv/issues/11344).
This PR adds warnings around these setups.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2025-02-17 15:57:18 +00:00
konsti 248da23f6d
Split uv-git and uv-git-types (#11448)
We want to build `uv-build` without depending on the network crates. In
preparation for that, we split uv-git into uv-git and uv-git-types,
where only uv-git depends on reqwest, so that uv-build can use
uv-git-types.
2025-02-17 10:37:55 +01:00
renovate[bot] e21f793a1f
Update Rust crate clap to v4.5.29 (#11564) 2025-02-16 22:04:13 -05:00
renovate[bot] 39b28b210c
Update Rust crate tempfile to v3.17.0 (#11570) 2025-02-16 21:49:47 -05:00
renovate[bot] 040ee26531
Update Rust crate smallvec to v1.14.0 (#11569) 2025-02-16 21:49:34 -05:00
renovate[bot] fbed410c53
Update Rust crate jiff to 0.2.0 (#11568) 2025-02-16 21:49:21 -05:00
renovate[bot] 8c6792ebe0
Update Rust crate codspeed-criterion-compat to v2.8.0 (#11567) 2025-02-16 21:49:14 -05:00
renovate[bot] 4a8fc5df91
Update Rust crate toml_edit to v0.22.24 (#11565) 2025-02-16 21:49:03 -05:00
Zanie Blue 591f38c25e
Bump version to v0.6.0 (#11496)
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2025-02-14 11:55:54 -06:00
Charlie Marsh 4d5041dc00 Use files instead of junctions on Windows (#11269)
Instead of using junctions, we can just write files that contain (as the
file contents) the target path. This requires a little more finesse in
that, as readers, we need to know where to expect these. But it also
means we get to avoid junctions, which have led to a variety of
confusing behaviors. Further, `replace_symlink` should now be on atomic
on Windows.

Closes #11263.
2025-02-13 16:17:49 -06:00
Charlie Marsh ceb22fcfe5
Support `--active` for PEP 723 script environments (#11433)
## Summary

See: https://github.com/astral-sh/uv/pull/11361#discussion_r1948851085
2025-02-13 13:40:21 -06:00
Zanie Blue e38ac4900d
Bump version to 0.5.31 (#11459) 2025-02-12 14:45:22 -06:00
Charlie Marsh 1cd9c37151
Use stable environments for remote and stdin scripts (#11364)
## Summary

This is a follow-on to #11347 to use a stable directory for remote and
stdin scripts. The annoying piece here was figuring out what to use as
the cache key. For remote scripts, I'm using the URL; for stdin scripts,
there isn't any identifying information, so I'm just using a hash of the
metadata.
2025-02-12 00:54:46 +00:00
Charlie Marsh ca49495e4b
Bump version to v0.5.30 (#11405) 2025-02-10 21:42:31 +00:00
renovate[bot] cbb94e40b3
Update Rust crate mailparse to 0.16.0 (#11375) 2025-02-10 02:40:08 +00:00
renovate[bot] 9f7b344b88
Update Rust crate rustc-hash to v2.1.1 (#11369) 2025-02-10 02:21:03 +00:00
renovate[bot] eb19d471f4
Update Rust crate data-encoding to v2.8.0 (#11374) 2025-02-10 02:16:51 +00:00
renovate[bot] 534b1a3bc9
Update Rust crate which to v7.0.2 (#11372) 2025-02-10 01:46:29 +00:00
renovate[bot] f7649bcfcb
Update Rust crate toml to v0.8.20 (#11371) 2025-02-10 01:43:14 +00:00
renovate[bot] d4b357d40b
Update Rust crate target-lexicon to v0.13.2 (#11370) 2025-02-10 01:40:28 +00:00
renovate[bot] dbdeaf28ee
Update Rust crate clap to v4.5.28 (#11368) 2025-02-09 20:33:16 -05:00
renovate[bot] 9db3034b5d
Update Rust crate bytecheck to v0.8.1 (#11367) 2025-02-09 20:33:08 -05:00
renovate[bot] 3d8b01a10e
Update Rust crate boxcar to v0.2.9 (#11366) 2025-02-09 20:33:01 -05:00
Charlie Marsh 1b2125712e
Upgrade `astral-tokio-tar` to v0.5.1 (#11359)
## Summary

Pulling in https://github.com/astral-sh/tokio-tar/pull/40.

Closes https://github.com/astral-sh/uv/issues/2235.
2025-02-09 14:14:47 -05:00
Zanie Blue ca73c47543
Bump version to 0.5.29 (#11267) 2025-02-05 19:59:29 -05:00
Charlie Marsh c0f6406c76
Migrate to published `astral-tokio-tar` crate (#11260)
We now publish this to `crates.io`:
https://crates.io/crates/astral-tokio-tar
2025-02-05 15:43:33 -05:00
Jo 6f8d9b85d8
Remove `cachedir` dependency (#11240)
## Summary

Vendor the `HEADER` constant too so we can eliminate the dependency on
`cachedir`.
2025-02-05 08:54:02 -05:00
Charlie Marsh fea00dcdd5
Bump version to v0.5.28 (#11228) 2025-02-04 20:28:43 -05:00
konsti ac1004284a
Fix hardlinks in tar unpacking (#11221)
In https://github.com/astral-sh/tokio-tar/pull/2, we accidentally
changed the `target_base` from the target base to the parent of the
file. This would cause hardlink unpacking to fail.

Example: A hardlink at `hardlinked-0.1.0/pyproject.toml` pointing to
`hardlinked-0.1.0/pyproject.toml.real` would try pointing to
`hardlinked-0.1.0/hardlinked-0.1.0/pyproject.toml.real` instead and fail
the unpacking.

The actual fix is in astral-tokio-tar, on the uv side there are only tests.

Fixes #11213
2025-02-04 17:38:22 +00:00
Zanie Blue 73e9928d40
Bump version to 0.5.27 (#11201) 2025-02-03 16:55:36 -06:00
Zanie Blue dd7cd2e86a
Remove warnings for missing lower bounds (#11195)
These are noisy relative to the effect they have on the user. It seems
better to prioritize hints on poor resolutions. Notably, it seems hard
to make these "not noisy" ref #11091.

Does not include the "lowest" resolution mode, in which lower bounds are
critical.
2025-02-03 16:03:31 -06:00
Charlie Marsh 85461c2c90
Avoid setting permissions during tar extraction (#11191)
## Summary

As in our zip operation (and like pip), we want to explicitly avoid
setting permissions during unpacking -- apart from setting the
executable bit.

This depends on https://github.com/astral-sh/tokio-tar/pull/8.

Closes https://github.com/astral-sh/uv/issues/11188.
2025-02-03 19:29:11 +00:00
Charlie Marsh 7b43baf251
Use Astral-maintained `tokio-tar` fork (#11174)
## Summary

I shipped one security fix here along with several significant
performance improvements for large TAR files:

- https://github.com/astral-sh/tokio-tar/pull/2
- https://github.com/astral-sh/tokio-tar/pull/4
- https://github.com/astral-sh/tokio-tar/pull/5

I also PR'd the security fix to `edera-dev`
(https://github.com/edera-dev/tokio-tar/pull/4).
2025-02-03 17:51:35 +00:00
konsti f7c3f30a16
Update pubgrub to set-based outdated priority tracking (#11169)
Looks like the set based prioritize tracking from
https://github.com/pubgrub-rs/pubgrub/pull/313 is a slight speedup.

I assume the changed derivation tree in the error snapshot is due to
out-of-sync virtual package priorities, while the main package priority
defining the solution remains stable.

```
$ hyperfine --warmup 2 "./uv-main pip compile --no-progress scripts/requirements/airflow.in --universal" "./uv-branch pip compile --no-progress scripts/requirements/airflow.in --universal"
  Benchmark 1: ./uv-main pip compile --no-progress scripts/requirements/airflow.in --universal
    Time (mean ± σ):     115.0 ms ±   4.8 ms    [User: 131.0 ms, System: 113.6 ms]
    Range (min … max):   108.1 ms … 125.8 ms    25 runs

  Benchmark 2: ./uv-branch pip compile --no-progress scripts/requirements/airflow.in --universal
    Time (mean ± σ):     105.4 ms ±   2.6 ms    [User: 118.5 ms, System: 113.5 ms]
    Range (min … max):   101.1 ms … 111.9 ms    28 runs

  Summary
    ./uv-branch pip compile --no-progress scripts/requirements/airflow.in --universal ran
      1.09 ± 0.05 times faster than ./uv-main pip compile --no-progress scripts/requirements/airflow.in --universal
```
2025-02-03 13:08:51 +01:00
renovate[bot] 4a88cdd6ee
Update Rust crate syn to v2.0.98 (#11172) 2025-02-02 20:47:35 -05:00
renovate[bot] d3dd91c78c
Update Rust crate jiff to v0.1.29 (#11171) 2025-02-02 20:33:43 -05:00
renovate[bot] 6f1578fa59
Update Rust crate async-trait to v0.1.86 (#11170) 2025-02-03 01:16:19 +00:00
renovate[bot] b0e9781da4
Update Rust crate miette to v7.5.0 (#9568) 2025-02-01 04:06:15 +00:00
Charlie Marsh 8adf4a8977
Migrate from `urlencoding` to `percent-encoding` (#11144)
## Summary

This lets us drop a dependency entirely. `percent-encoding` is used by
`url` and so is already in the graph, whereas `urlencoding` isn't used
by anything else.
2025-01-31 16:29:46 -05:00
Charlie Marsh 027db656aa
Run `cargo update` (#11146)
## Summary

Renovate only captures first-party dependencies, so it's good to run
this from time to time.
2025-01-31 16:07:36 -05:00
Charlie Marsh 26f84e5699
Percent-decode URLs in canonical comparisons (#11088)
## Summary

This PR adds an additional normalization step to `CanonicalUrl` whereby
we now percent-decode the path, to ensure that (e.g.)
`torch-2.5.1%2Bcpu.cxx11.abi-cp39-cp39-linux_x86_64.whl` and
`torch-2.5.1+cpu.cxx11.abi-cp39-cp39-linux_x86_64.whl` are considered
equal. Further, when generating the "reinstall" report, we use the
canonical URL rather than the verbatim URL.

In making this change, I also learned that we don't apply any of the
normalization passes to `file://` URLs. I inadvertently removed it in
93d606aba2,
since setting the password or URL on ` file://` URL errors -- but now
suppress those errors anyway.

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

## Test Plan

- Downloaded a [PyTorch
wheel](https://download.pytorch.org/whl/cpu-cxx11-abi/torch-2.5.1%2Bcpu.cxx11.abi-cp39-cp39-linux_x86_64.whl)
- `python3.9 -m pip install
torch-2.5.1+cpu.cxx11.abi-cp39-cp39-linux_x86_64.whl --platform
linux_x86_64 --target foo --no-deps`
- `cargo run pip install
torch-2.5.1+cpu.cxx11.abi-cp39-cp39-linux_x86_64.whl --python-platform
linux --python-version 3.9 --target foo --no-deps`
- Verified that the package had the `~` symbol for the reinstall.
2025-01-31 15:45:48 -05:00
Zanie Blue 5ef3d51390
Bump version to 0.5.26 (#11119) 2025-01-30 15:37:00 -06:00
Zanie Blue 9c07c3fc5b
Bump version to 0.5.25 (#11042) 2025-01-28 15:40:43 -06:00
renovate[bot] b1706ad8be
Update Rust crate rustix to v0.38.44 (#10974) 2025-01-26 22:23:02 -05:00
renovate[bot] bcbc35c844
Update Rust crate fs-err to v3.1.0 (#10976) 2025-01-27 02:49:02 +00:00
renovate[bot] fb545130eb
Update Rust crate rkyv to v0.8.10 (#10973) 2025-01-27 02:23:24 +00:00
renovate[bot] a1ce4aac59
Update Rust crate jiff to v0.1.27 (#10972) 2025-01-26 21:21:01 -05:00
renovate[bot] f1f0730bc9
Update Rust crate insta to v1.42.1 (#10971) 2025-01-26 21:20:54 -05:00
renovate[bot] 20c0385bb3
Update Rust crate clap to v4.5.27 (#10970) 2025-01-26 21:20:47 -05:00
Zanie Blue 42fae925c4
Bump version to 0.5.24 (#10922) 2025-01-23 17:26:59 -06:00
Charlie Marsh ba42467f1b
Bump version to v0.5.23 (#10879) 2025-01-23 00:26:10 +00:00
Charlie Marsh 1372c4e6de
Include `commit_id` and `requested_revision` in `direct_url.json` (#10862)
## Summary

Closes #3014.

Closes #10846.
2025-01-22 12:16:49 -05:00
Charlie Marsh 4574ced370
Bump version to v0.5.22 (#10829) 2025-01-21 17:03:55 -05: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
renovate[bot] 53dfac5529
Update Rust crate similar to v2.7.0 (#10769) 2025-01-20 02:06:08 +00:00
renovate[bot] 5845b9a691
Update Rust crate indexmap to v2.7.1 (#10767) 2025-01-20 01:53:58 +00:00
renovate[bot] a449072e6d
Update Rust crate data-encoding to v2.7.0 (#10764) 2025-01-20 01:46:39 +00:00
renovate[bot] 5a7545ae35
Update Rust crate jiff to v0.1.24 (#10759) 2025-01-19 20:44:52 -05:00
renovate[bot] 05fcc50758
Update Rust crate test-log to v0.2.17 (#10761) 2025-01-19 20:42:55 -05:00
renovate[bot] 2ae3f69fd9
Update Rust crate bitflags to v2.8.0 (#10763) 2025-01-20 01:41:34 +00:00
renovate[bot] 0ff9c250ec
Update Rust crate serde_json to v1.0.137 (#10760) 2025-01-19 20:35:14 -05:00
Charlie Marsh 3478c068bb
Bump version to v0.5.21 (#10723) 2025-01-17 20:53:36 +00:00
Charlie Marsh bc8002e26e
Avoid narrowing `requires-python` marker with disjunctions (#10704)
## Summary

A bug in `requires_python` (which infers the Python requirement from a
marker) was leading us to break an invariant around the relationship
between the marker environment and the Python requirement. This, in
turn, was leading us to drop parts of the environment space when
solving.

Specifically, in the linked example, we generated a fork for
`python_full_version < '3.10' or platform_python_implementation !=
'CPython'`, which was later split into `python_full_version == '3.8.*'`
and `python_full_version == '3.9.*'`, losing the
`platform_python_implementation != 'CPython'` portion.

Closes https://github.com/astral-sh/uv/issues/10669.
2025-01-17 16:25:32 +00:00
Charlie Marsh 1c17662b37
Bump version to v0.5.20 (#10659) 2025-01-15 23:18:06 +00:00
Zanie Blue a7f13e0e0b
Bump version to 0.5.19 (#10643) 2025-01-15 20:56:43 +00:00
Charlie Marsh d20a48a5b4
Use `memchr` for wheel parsing (#10620)
## Summary

Before:

```
wheelname_parsing/numpy-compatible
                        time:   [106.90 ns 107.86 ns 108.86 ns]
                        thrpt:  [402.97 MiB/s 406.71 MiB/s 410.39 MiB/s]
                 change:
                        time:   [-4.5360% -3.7694% -2.9179%] (p = 0.00 < 0.05)
                        thrpt:  [+3.0056% +3.9170% +4.7515%]
                        Performance has improved.
wheelname_parsing/flyte-short-incompatible
                        time:   [81.439 ns 82.209 ns 83.015 ns]
                        thrpt:  [390.59 MiB/s 394.42 MiB/s 398.15 MiB/s]
                 change:
                        time:   [+6.2344% +7.5385% +8.8928%] (p = 0.00 < 0.05)
                        thrpt:  [-8.1666% -7.0101% -5.8685%]
                        Performance has regressed.
wheelname_parsing/flyte-short-compatible
                        time:   [78.909 ns 79.456 ns 80.031 ns]
                        thrpt:  [357.49 MiB/s 360.08 MiB/s 362.57 MiB/s]
                 change:
                        time:   [+3.2653% +4.1733% +5.1062%] (p = 0.00 < 0.05)
                        thrpt:  [-4.8582% -4.0061% -3.1620%]
                        Performance has regressed.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
wheelname_parsing/flyte-long-incompatible
                        time:   [353.35 ns 357.49 ns 361.77 ns]
                        thrpt:  [340.06 MiB/s 344.13 MiB/s 348.17 MiB/s]
                 change:
                        time:   [+1.4846% +2.0228% +2.6504%] (p = 0.00 < 0.05)
                        thrpt:  [-2.5820% -1.9827% -1.4629%]
                        Performance has regressed.
Found 10 outliers among 100 measurements (10.00%)
  5 (5.00%) high mild
  5 (5.00%) high severe
wheelname_parsing/flyte-long-compatible
                        time:   [256.47 ns 258.12 ns 260.17 ns]
                        thrpt:  [417.88 MiB/s 421.20 MiB/s 423.90 MiB/s]
                 change:
                        time:   [+0.4079% +1.8252% +3.6270%] (p = 0.02 < 0.05)
                        thrpt:  [-3.5001% -1.7925% -0.4063%]
                        Change within noise threshold.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high severe
```

After:

```
wheelname_parsing_fastest/numpy-compatible
                        time:   [61.500 ns 61.904 ns 62.350 ns]
                        thrpt:  [703.60 MiB/s 708.66 MiB/s 713.32 MiB/s]
                 change:
                        time:   [+0.9879% +1.4542% +1.9311%] (p = 0.00 < 0.05)
                        thrpt:  [-1.8945% -1.4334% -0.9782%]
                        Change within noise threshold.
Found 8 outliers among 100 measurements (8.00%)
  6 (6.00%) high mild
  2 (2.00%) high severe
wheelname_parsing_fastest/flyte-short-incompatible
                        time:   [49.341 ns 49.538 ns 49.769 ns]
                        thrpt:  [651.50 MiB/s 654.54 MiB/s 657.16 MiB/s]
                 change:
                        time:   [+5.8750% +6.3656% +6.8338%] (p = 0.00 < 0.05)
                        thrpt:  [-6.3967% -5.9847% -5.5490%]
                        Performance has regressed.
Found 17 outliers among 100 measurements (17.00%)
  5 (5.00%) low severe
  1 (1.00%) low mild
  6 (6.00%) high mild
  5 (5.00%) high severe
wheelname_parsing_fastest/flyte-short-compatible
                        time:   [49.425 ns 49.789 ns 50.193 ns]
                        thrpt:  [570.01 MiB/s 574.63 MiB/s 578.86 MiB/s]
                 change:
                        time:   [+5.1267% +5.7418% +6.3476%] (p = 0.00 < 0.05)
                        thrpt:  [-5.9687% -5.4300% -4.8767%]
                        Performance has regressed.
Found 7 outliers among 100 measurements (7.00%)
  7 (7.00%) high mild
wheelname_parsing_fastest/flyte-long-incompatible
                        time:   [295.81 ns 298.01 ns 301.04 ns]
                        thrpt:  [408.66 MiB/s 412.82 MiB/s 415.89 MiB/s]
                 change:
                        time:   [+0.5553% +1.0842% +1.7059%] (p = 0.00 < 0.05)
                        thrpt:  [-1.6772% -1.0726% -0.5523%]
                        Change within noise threshold.
Found 4 outliers among 100 measurements (4.00%)
  3 (3.00%) high mild
  1 (1.00%) high severe
wheelname_parsing_fastest/flyte-long-compatible
                        time:   [214.80 ns 216.10 ns 217.50 ns]
                        thrpt:  [499.87 MiB/s 503.10 MiB/s 506.15 MiB/s]
                 change:
                        time:   [+0.9003% +1.3207% +1.8268%] (p = 0.00 < 0.05)
                        thrpt:  [-1.7940% -1.3035% -0.8923%]
                        Change within noise threshold.
Found 8 outliers among 100 measurements (8.00%)
  7 (7.00%) high mild
  1 (1.00%) high severe
```

(Ignore the percent changes; they're not relative to one another.)

So it's like >40% faster for the small case and >15% faster for the
large case.
2025-01-15 11:39:25 -05:00
Charlie Marsh 279043f864
Include build tag in rendered wheel filenames (#10599)
## Summary

I don't think this had an impact in practice, but it is "wrong" to omit
these. Confirmed that the cache (for example) now includes the build tag
(as in, `mkl_fft-1.3.8-72-cp310-cp310-manylinux2014_x86_64`).
2025-01-14 15:01:45 +00:00
Charlie Marsh faa4481ccc
Shrink size of platform tag enum (#10546)
## Summary

Reduces it from 56 bytes to 16 bytes.
2025-01-14 03:13:59 +00:00
Charlie Marsh 5c91217488
Use structured wheel tags everywhere (#10542)
## Summary

This PR extends the thinking in #10525 to platform tags, and then uses
the structured tag enums everywhere, rather than passing around strings.
I think this is a big improvement! It means we're no longer doing ad hoc
tag parsing all over the place.
2025-01-14 01:39:39 +00:00
Charlie Marsh 2ffa31946d
Show expected and available ABI tags in resolver errors (#10527)
## Summary

The idea here is to show both (1) an example of a compatible tag and (2)
the tags that were available, whenever we fail to resolve due to an
abscence of matching wheels.

Closes https://github.com/astral-sh/uv/issues/2777.
2025-01-14 01:03:11 +00:00
samypr100 73f60bbd2c
chore: update windows-registry and windows-result crates (#10532)
## Summary

Closes https://github.com/astral-sh/uv/pull/10517
Closes https://github.com/astral-sh/uv/pull/10516

They need to be updated together.
2025-01-13 18:06:34 -05:00
renovate[bot] b38d3fec64
Update Rust crate jiff to v0.1.22 (#10550) 2025-01-12 20:33:01 -05:00
Charlie Marsh 1e48c12837
Add a shared `uv-small-str` crate (#10545)
## Summary

I want to use `SmallString` elsewhere.
2025-01-12 20:23:18 +00:00
Sergei Nizovtsev 051aaa5fe5
Fix git-tag cache-key reader in case of slashes (#10467) (#10500)
## Summary

The assumption that all tags are listed under a flat `.git/ref/tags`
structure was wrong. Git creates a hierarchy of directories for tags
containing slashes. To fix the cache key calculation, we need to
recursively traverse all files under that folder instead.

## Test Plan

1. Create an `uv` project with git-tag cache-keys;
2. Add any tag with slash;
3. Run `uv sync` and see uv_cache_info error in verbose log;
4. `uv sync` doesn't trigger reinstall on next tag addition or removal;
5. With fix applied, reinstall triggers on every tag update and there
are no errors in the log.

Fixes #10467

---------

Co-authored-by: Sergei Nizovtsev <sergei.nizovtsev@eqvilent.com>
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2025-01-11 21:30:46 -05:00
renovate[bot] 5aa53863a7
Update Rust crate rustix to v0.38.43 (#10508) 2025-01-11 19:26:21 +00:00
renovate[bot] 8e0c7cfd76
Update Rust crate clap to v4.5.26 (#10503) 2025-01-11 19:24:45 +00:00
renovate[bot] 2c021e2f7d
Update Rust crate winreg to 0.53.0 (#10518) 2025-01-11 18:08:13 +00:00
renovate[bot] 69102e0563
Update Rust crate tokio to v1.43.0 (#10514) 2025-01-11 17:55:31 +00:00
renovate[bot] 08569667cb
Update Rust crate bitflags to v2.7.0 (#10512) 2025-01-11 12:29:13 -05:00
renovate[bot] ed5a53f01b
Update Rust crate thiserror to v2.0.11 (#10511) 2025-01-11 12:29:03 -05:00
renovate[bot] 3e2a8cbd04
Update Rust crate syn to v2.0.96 (#10510) 2025-01-11 12:28:56 -05:00
renovate[bot] bee6eff235
Update Rust crate serde_json to v1.0.135 (#10509) 2025-01-11 12:28:23 -05:00
renovate[bot] 94d4babe1a
Update Rust crate proc-macro2 to v1.0.93 (#10506) 2025-01-11 12:27:53 -05:00
renovate[bot] 716f3ec9eb
Update Rust crate goblin to v0.9.3 (#10504) 2025-01-11 12:27:01 -05:00
renovate[bot] 59eb60b819
Update Rust crate cargo-util to v0.2.17 (#10502) 2025-01-11 12:26:44 -05:00
renovate[bot] aa1fd76a15
Update Rust crate async-trait to v0.1.85 (#10501) 2025-01-11 12:26:36 -05:00
Charlie Marsh 27d1bad550
Bump version to v0.5.18 (#10499) 2025-01-11 14:38:26 +00:00
Charlie Marsh c198e2233e
Bump version to v0.5.17 (#10480) 2025-01-10 15:52:56 -05:00
Charlie Marsh 8420195aa7
Use `ArcStr` for marker values (#10453)
N.B. After fixing #10430, `ArcStr` became the fastest implementation
(and the gains were significantly reduced, down to 1-2%). See:
https://github.com/astral-sh/uv/pull/10453#issuecomment-2583344414.

## Summary

I tried out a variety of small string crates, but `Arc<str>`
outperformed them, giving a ~10% speed-up:

```console
❯ hyperfine "../arcstr lock" "../flexstr lock" "uv lock" "../arc lock" "../compact_str lock" --prepare "rm -f uv.lock" --min-runs 50 --warmup 20
Benchmark 1: ../arcstr lock
  Time (mean ± σ):     304.6 ms ±   2.3 ms    [User: 302.9 ms, System: 117.8 ms]
  Range (min … max):   299.0 ms … 311.3 ms    50 runs

Benchmark 2: ../flexstr lock
  Time (mean ± σ):     319.2 ms ±   1.7 ms    [User: 317.7 ms, System: 118.2 ms]
  Range (min … max):   316.8 ms … 323.3 ms    50 runs

Benchmark 3: uv lock
  Time (mean ± σ):     330.6 ms ±   1.5 ms    [User: 328.1 ms, System: 139.3 ms]
  Range (min … max):   326.6 ms … 334.2 ms    50 runs

Benchmark 4: ../arc lock
  Time (mean ± σ):     303.0 ms ±   1.2 ms    [User: 301.6 ms, System: 118.4 ms]
  Range (min … max):   300.3 ms … 305.3 ms    50 runs

Benchmark 5: ../compact_str lock
  Time (mean ± σ):     320.4 ms ±   2.0 ms    [User: 318.7 ms, System: 120.8 ms]
  Range (min … max):   317.3 ms … 326.7 ms    50 runs

Summary
  ../arc lock ran
    1.01 ± 0.01 times faster than ../arcstr lock
    1.05 ± 0.01 times faster than ../flexstr lock
    1.06 ± 0.01 times faster than ../compact_str lock
    1.09 ± 0.01 times faster than uv lock
```
2025-01-10 15:15:12 -05:00
Charlie Marsh b3d7beb1a0
Use `arcstr` for package, extra, and group names (#10475)
## Summary

This appears to be a consistent 1% performance improvement and should
also reduce memory quite a bit. We've also decided to use these for
markers, so it's nice to use the same optimization here.

```
❯ hyperfine "./uv pip compile --universal scripts/requirements/airflow.in" "./arcstr pip compile --universal scripts/requirements/airflow.in" --min-runs 50 --warmup 20
Benchmark 1: ./uv pip compile --universal scripts/requirements/airflow.in
  Time (mean ± σ):     136.3 ms ±   4.0 ms    [User: 139.1 ms, System: 241.9 ms]
  Range (min … max):   131.5 ms … 149.5 ms    50 runs

Benchmark 2: ./arcstr pip compile --universal scripts/requirements/airflow.in
  Time (mean ± σ):     134.9 ms ±   3.2 ms    [User: 137.6 ms, System: 239.0 ms]
  Range (min … max):   130.1 ms … 151.8 ms    50 runs

Summary
  ./arcstr pip compile --universal scripts/requirements/airflow.in ran
    1.01 ± 0.04 times faster than ./uv pip compile --universal scripts/requirements/airflow.in
```
2025-01-10 19:46:36 +00:00
Aria Desires e2c5526fbb
replace backoff with backon (#10442)
This should be essentially the exact same behaviour, but backon is a
total API redesign, so things had to be expressed slightly differently.
Overall I think the code is more readable, which is nice.

Fixes #10001
2025-01-09 16:01:23 -05:00
Charlie Marsh 14b685d9fb
Warn-and-ignore for unsupported `requirements.txt` options (#10420)
## Summary

Closes https://github.com/astral-sh/uv/issues/10366.
2025-01-09 13:19:51 -05:00
renovate[bot] ad09070dd7
Update Rust crate petgraph to 0.7.1 (#10317) 2025-01-08 18:39:26 +00:00
Charlie Marsh 333f03f112
Bump version to v0.5.16 (#10395) 2025-01-08 10:29:32 -05:00
Charlie Marsh c8b3e8523c
Re-enable `zlib-ng` on x86 platforms (#10365)
## Summary

Closes https://github.com/astral-sh/uv/issues/10363.
2025-01-07 11:00:32 -05:00
konsti c6ac121ed0
Refactor batch prefetch (#10349) 2025-01-07 14:58:36 +01:00
Zanie Blue eb6ad9a4fa
Bump version to 0.5.15 (#10337) 2025-01-06 18:04:25 -06:00
renovate[bot] 16097b51c4
Update Rust crate tempfile to v3.15.0 (#10318) 2025-01-05 21:29:38 -05:00
renovate[bot] 98d06f40f5
Update Rust crate insta to v1.42.0 (#10314) 2025-01-05 21:27:30 -05:00
renovate[bot] 5aefe69ecf
Update Rust crate itertools to 0.14.0 (#10316) 2025-01-05 21:27:14 -05:00
renovate[bot] 0b9519b1fc
Update Rust crate syn to v2.0.95 (#10312) 2025-01-06 01:19:11 +00:00
renovate[bot] f93ada48e9
Update Rust crate spdx to v0.10.8 (#10311) 2025-01-06 01:16:15 +00:00
renovate[bot] af23311d15
Update Rust crate jiff to v0.1.21 (#10310) 2025-01-06 01:12:57 +00:00
renovate[bot] f4cca71c0b
Update Rust crate async-trait to v0.1.84 (#10309) 2025-01-06 01:11:44 +00:00
renovate[bot] fbe6f1edf4
Update Rust crate reqwest to v0.12.12 (#10227) 2025-01-03 12:18:43 -05:00
Charlie Marsh 9f1ba2b967
Bump version to v0.5.14 (#10279) 2025-01-02 14:31:04 -05:00
Charlie Marsh c77aa5820b
Add a required version setting to uv (#10248)
## Summary

This follows Ruff's design exactly: you can provide a version specifier
(like `>=0.5`), and we'll enforce it at runtime.

Closes https://github.com/astral-sh/uv/issues/8605.
2024-12-31 15:37:46 +00:00
renovate[bot] 0ea4f5f8b1
Update Rust crate syn to v2.0.93 (#10229) 2024-12-30 03:03:52 +00:00
renovate[bot] 78e246f043
Update Rust crate serde to v1.0.217 (#10228) 2024-12-30 02:56:19 +00:00
renovate[bot] 4623ab32be
Update Rust crate jiff to v0.1.16 (#10226) 2024-12-30 02:55:16 +00:00
renovate[bot] 07f6596933
Update Rust crate glob to v0.3.2 (#10225) 2024-12-30 02:43:47 +00:00
renovate[bot] 19fc8865fb
Update Rust crate boxcar to v0.2.8 (#10224) 2024-12-30 02:42:41 +00:00
Charlie Marsh cecff3a726
Guard against self-deletion in `uv venv` and `uv tool` (#10206)
## Summary

Closes https://github.com/astral-sh/uv/issues/1327.
2024-12-29 10:46:45 -05:00
Charlie Marsh 4c49683f7b
Bump version to v0.5.13 (#10188) 2024-12-26 23:58:13 +00:00
Charlie Marsh b52d48973f
Revert "Update `reqwest` (#10178)" (#10187)
This reverts commit d2f58d9299.

Closes https://github.com/astral-sh/uv/issues/10186
2024-12-26 23:40:24 +00:00
Charlie Marsh 351d602d86
Bump version to v0.5.12 (#10175) 2024-12-26 14:16:19 -05:00
Charlie Marsh d2f58d9299
Update `reqwest` (#10178) 2024-12-26 14:16:12 -05:00
Charlie Marsh b6697a777c
Run `cargo update` (#10173) 2024-12-26 12:00:58 -05:00
Charlie Marsh 3cb723220e
Remove `anyhow::Result` for lock serialization (#10151) 2024-12-25 01:24:26 +00:00
Charlie Marsh d1b1da5ac1
Upgrade cargo-dist to v0.27.0 (#10141)
## Summary

Required peer to https://github.com/astral-sh/uv/pull/10115.
2024-12-24 08:24:14 -05:00
renovate[bot] 7796a9cb3e
Update Rust crate hyper to v1.5.2 (#10105) 2024-12-24 08:10:06 -05:00
renovate[bot] 5b3e54d9dd
Update Rust crate axoupdater to 0.9.0 (#10115) 2024-12-24 08:09:13 -05:00
renovate[bot] c329623770
Update Rust crate thiserror to v2.0.9 (#10112) 2024-12-23 08:48:06 -05:00
renovate[bot] 4008e313bf
Update Rust crate which to v7.0.1 (#10113) 2024-12-23 08:47:36 -05:00
renovate[bot] 54ab15121c
Update Rust crate target-lexicon to v0.13.1 (#10111) 2024-12-23 01:45:06 +00:00
renovate[bot] 27ec53c736
Update Rust crate syn to v2.0.91 (#10109) 2024-12-23 01:34:43 +00:00
renovate[bot] a31ec7aa16
Update Rust crate serde_json to v1.0.134 (#10108) 2024-12-23 01:33:50 +00:00
renovate[bot] 4945880270
Update Rust crate predicates to v3.1.3 (#10107) 2024-12-23 01:29:47 +00:00
renovate[bot] 1f97944c79
Update Rust crate platform-info to v2.0.5 (#10106) 2024-12-23 01:12:31 +00:00
renovate[bot] ad156f393c
Update Rust crate home to v0.5.11 (#10104) 2024-12-23 01:01:24 +00:00
renovate[bot] 18d8b79db1
Update Rust crate console to v0.15.10 (#10103) 2024-12-23 00:59:23 +00:00
renovate[bot] 9e33658ba9
Update Rust crate anyhow to v1.0.95 (#10102) 2024-12-23 00:49:18 +00:00
konsti ae659c8bfe
Stable order for virtual packages (#10024)
uv gives priorities to packages by package name, not by virtual package
(`PubGrubPackage`). pubgrub otoh when prioritizing order the virtual
packages. When the order of virtual packages changes, uv changes its
resolutions and error messages. This means uv was depending on
implementation details of pubgrub's prioritization caching.

This broke with https://github.com/pubgrub-rs/pubgrub/pull/299, which
added a tiebreaker term that made pubgrub's sorting deterministic given
a deterministic ordering of allocating the packages (which happens the
first time pubgrub sees a package).

The new custom tiebreaker decreases the difference to upstream pubgrub.
2024-12-20 09:28:46 +00:00
Zanie Blue c4d0caaee5
Bump version to 0.5.11 (#10044) 2024-12-19 18:01:45 -06:00
Zanie Blue 37b11ddb22
Bump version to 0.5.10 (#9983) 2024-12-17 14:53:19 -06:00
Zanie Blue 3fae5332c1
Fix `Cargo.lock` by updating thiserror (#9975) 2024-12-17 10:53:44 -06:00
konsti ebc6d20d9d
Better build error messages (#9660)
Build failures are one of the most common user facing failures that
aren't "obivous" errors (such as typos) or resolver errors. Currently,
they show more technical details than being focussed on this being an
error in a subprocess that is either on the side of the package or -
more likely - in the build environment, e.g. the user needs to install a
dev package or their python version is incompatible.

The new error message clearly delineates the part that's important (this
is a build backend problem) from the internals (we called this hook) and
is consistent about which part of the dist building stage failed. We
have to calibrate the exact wording of the error message some more. Most
of the implementation is working around the orphan rule, (this)error
rules and trait rules, so it came out more of a refactoring than
intended.

Example:


![image](https://github.com/user-attachments/assets/2bc12992-db79-4362-a444-fd0d94594b77)
2024-12-17 09:44:32 -06:00
konsti b7df5dbaf3
Avoid `liblzma-dev` system dep in uv-dev and uv-bench (#9933)
Enable `lzma-sys/static` through the performance feature not only in uv,
but in uv-dev and uv-bench too, to avoid the system dependency on
`liblzma-dev`.

Ref #9880
2024-12-17 16:12:33 +01:00
konsti 431ddc1d74
Change backtracking when packages conflict too much (#9843)
Background reading: https://github.com/astral-sh/uv/issues/8157
Companion PR: https://github.com/astral-sh/pubgrub/pull/36
Requires for test coverage: https://github.com/astral-sh/packse/pull/230

When two packages A and B conflict, we have the option to choose a lower
version of A, or a lower version of B. Currently, we determine this by
the order we saw a package (assuming equal specificity of the
requirement): If we saw A before B, we pin A until all versions of B are
exhausted. This can lead to undesirable outcomes, from cases where it's
just slow (sentry) to others cases without lower bounds where be
backtrack to a very old version of B. This old version may fail to build
(terminating the resolution), or it's a version so old that it doesn't
depend on A (or the shared conflicting package) anymore - but also is
too old for the user's application (fastapi). #8157 collects such cases,
and the `wrong-backtracking` packse scenario contains a minimized
example.

We try to solve this by tracking which packages are "A"s, culprits, and
"B"s, affected, and manually interfering with project selection and
backtracking. Whenever a version we just chose is rejected, we give the
current package a counter for being affected, and the package it
conflicted with a counter for being a culprit. If a package accumulates
more counts than a threshold, we reprioritize: Undecided after the
culprits, after the affected, after packages that only have a single
version (URLs, `==<version>`). We then ask pubgrub to backtrack just
before the culprit. Due to the changed priorities, we now select package
B, the affected, instead of package A, the culprit.

To do this efficiently, we ask pubgrub for the incompatibility that
caused backtracking, or just the last version to be discarded (due to
its dependencies). For backtracking, we use the last incompatibility
from unit propagation as a heuristic. When a version is discarded
because one of its dependencies conflicts with the partial solution, the
incompatibility tells us the package in the partial solution that
conflicted.

We only backtrack once per package, on the first time it passes the
threshold. This prevents backtracking loops in which we make the same
decisions over and over again. But we also changed the priority, so that
we shouldn't take the same path even after the one time we backtrack (it
would defeat the purpose of this change).

There are some parameters that can be tweaked: Currently, the threshold
is set to 5, which feels not too eager with so me of the conflicts that
we want to tolerate but also changes strategies quickly. The relative
order of the new priorities can also be changed, as for each (A, B) pair
the priority of B is afterwards lower than that for A. Currently,
culprits capture conflict for the whole package, but we could limit that
to a specific version. We could discard conflict counters after
backtracking instead of keeping them eternally as we do now. Note that
we're always taking about pairs (A, B), but in practice we track
individual packages, not pairs.

A case that we wouldn't capture is when B is only introduced to the
dependency graph after A, but I think that would require cyclical
dependency for A and B to conflict? There may also be cases where
looking at the last incompatibility is insufficient.

Another example that we can't repair with prioritization is
urllib3/boto3/botocore: We actually have to check all the newer versions
of boto3 and botocore to identify the version that allows with the older
urllib3, no shortcuts allowed.

```
urllib3<1.25.4
boto3
```

All examples I tested were cases with two packages where we only had to
switch the order, so I've abstracted them into a single packse case.

This PR changes the resolution for certain paths, and there is the risk
for regressions.

Fixes #8157

---

All tested examples improved.

Input fastapi:
```text
starlette<=0.36.0
fastapi<=0.115.2
```

```
# BEFORE
$ uv pip --no-progress compile -p 3.11 --exclude-newer 2024-10-01 --no-annotate debug/fastapi.txt
annotated-types==0.7.0
anyio==4.6.0
fastapi==0.1.17
idna==3.10
pydantic==2.9.2
pydantic-core==2.23.4
sniffio==1.3.1
starlette==0.36.0
typing-extensions==4.12.2

# AFTER
$ cargo run --profile fast-build --no-default-features pip compile -p 3.11 --no-progress --exclude-newer 2024-10-01 --no-annotate debug/fastapi.txt 
annotated-types==0.7.0
anyio==4.6.0
fastapi==0.109.1
idna==3.10
pydantic==2.9.2
pydantic-core==2.23.4
sniffio==1.3.1
starlette==0.35.1
typing-extensions==4.12.2
```


Input xarray:
```text
xarray[accel]
```

```
# BEFORE
$ uv pip --no-progress compile -p 3.11 --exclude-newer 2024-10-01 --no-annotate debug/xarray-accel.txt
bottleneck==1.4.0
flox==0.9.13
llvmlite==0.36.0
numba==0.53.1
numbagg==0.8.2
numpy==2.1.1
numpy-groupies==0.11.2
opt-einsum==3.4.0
packaging==24.1
pandas==2.2.3
python-dateutil==2.9.0.post0
pytz==2024.2
scipy==1.14.1
setuptools==75.1.0
six==1.16.0
toolz==0.12.1
tzdata==2024.2
xarray==2024.9.0

# AFTER
$ cargo run --profile fast-build --no-default-features pip compile -p 3.11 --no-progress --exclude-newer 2024-10-01 --no-annotate debug/xarray-accel.txt
bottleneck==1.4.0
flox==0.9.13
llvmlite==0.43.0
numba==0.60.0
numbagg==0.8.2
numpy==2.0.2
numpy-groupies==0.11.2
opt-einsum==3.4.0
packaging==24.1
pandas==2.2.3
python-dateutil==2.9.0.post0
pytz==2024.2
scipy==1.14.1
six==1.16.0
toolz==0.12.1
tzdata==2024.2
xarray==2024.9.0
```


Input sentry: The resolution is identical, but arrived at much faster:
main tries 69 versions (sentry-kafka-schemas: 63), PR tries 12 versions
(sentry-kafka-schemas: 6; 5 times conflicting, then once the right
version).

```text
python-rapidjson<=1.20,>=1.4
sentry-kafka-schemas<=0.1.113,>=0.1.50
```

```
# BEFORE
$ uv pip --no-progress compile -p 3.11 --exclude-newer 2024-10-01 --no-annotate debug/sentry.txt
fastjsonschema==2.20.0
msgpack==1.1.0
python-rapidjson==1.8
pyyaml==6.0.2
sentry-kafka-schemas==0.1.111
typing-extensions==4.12.2

# AFTER
$ cargo run --profile fast-build --no-default-features pip compile -p 3.11 --no-progress --exclude-newer 2024-10-01 --no-annotate debug/sentry.txt
fastjsonschema==2.20.0
msgpack==1.1.0
python-rapidjson==1.8
pyyaml==6.0.2
sentry-kafka-schemas==0.1.111
typing-extensions==4.12.2
```


Input apache-beam
```text
# Run on Python 3.10
dill<0.3.9,>=0.2.2
apache-beam<=2.49.0
```

```
# BEFORE
$ uv pip --no-progress compile -p 3.10 --exclude-newer 2024-10-01 --no-annotate debug/apache-beam.txt
  × Failed to download and build `apache-beam==2.0.0`
  ╰─▶ Build backend failed to determine requirements with `build_wheel()` (exit status: 1)

# AFTER
$ cargo run --profile fast-build --no-default-features pip compile -p 3.10 --no-progress --exclude-newer 2024-10-01 --no-annotate debug/apache-beam.txt
apache-beam==2.49.0
certifi==2024.8.30
charset-normalizer==3.3.2
cloudpickle==2.2.1
crcmod==1.7
dill==0.3.1.1
dnspython==2.6.1
docopt==0.6.2
fastavro==1.9.7
fasteners==0.19
grpcio==1.66.2
hdfs==2.7.3
httplib2==0.22.0
idna==3.10
numpy==1.24.4
objsize==0.6.1
orjson==3.10.7
proto-plus==1.24.0
protobuf==4.23.4
pyarrow==11.0.0
pydot==1.4.2
pymongo==4.10.0
pyparsing==3.1.4
python-dateutil==2.9.0.post0
pytz==2024.2
regex==2024.9.11
requests==2.32.3
six==1.16.0
typing-extensions==4.12.2
urllib3==2.2.3
zstandard==0.23.0
```
2024-12-16 11:39:50 +01:00
renovate[bot] 2b61a67cf7
Update Rust crate rustix to v0.38.42 (#9924) 2024-12-15 20:12:42 -05:00
renovate[bot] 34281d96f1
Update Rust crate thiserror to v2.0.7 (#9926) 2024-12-15 20:12:08 -05:00
renovate[bot] 3617dd1b46
Update Rust crate serde to v1.0.216 (#9925) 2024-12-15 20:11:53 -05:00
Charlie Marsh 0652800cb0
Bump version to v0.5.9 (#9889) 2024-12-13 17:28:19 -05:00
Charlie Marsh d2fb4c585d
Patch `sysconfig` data at install time (#9857)
## Summary

This PR reimplements
[`sysconfigpatcher`](https://github.com/bluss/sysconfigpatcher) in Rust
and applies it to our Python installations at install-time, ensuring
that the `sysconfig` data is more likely to be correct.

For now, we only rewrite prefixes (i.e., any path that starts with
`/install` gets rewritten to the correct absolute path for the current
machine).

Unlike `sysconfigpatcher`, this PR does not yet do any of the following:

- Patch `pkginfo` files.
- Change `clang` references to `cc`.

A few things that we should do as follow-ups, in my opinion:

1. Rewrite
[`AR`](c1ebf8ab92/src/sysconfigpatcher.py (L61)).
2. Remove `-isysroot`, which we already do for newer builds.
2024-12-13 14:36:22 -05:00
Zanie Blue 80d41671bc
Bump version to 0.5.8 (#9791) 2024-12-11 15:18:51 +00:00
renovate[bot] 3b727b7323
Update Rust crate target-lexicon to 0.13.0 (#9729) 2024-12-10 20:34:07 -05:00
Charlie Marsh 3ee2b10738
Enable `uv tool uninstall uv` on Windows (#8963)
## Summary

Extending self-delete and self-replace functionality to uv itself on
Windows.

Closes https://github.com/astral-sh/uv/issues/6400.
2024-12-10 13:13:22 -05:00
renovate[bot] b17902da0f
Update Rust crate thiserror to v2.0.6 (#9727) 2024-12-09 01:15:25 +00:00
Charlie Marsh c4f3d1cf14
Run `cargo update` (#9712) 2024-12-07 22:50:22 -05:00
Zanie Blue 3ca155ddd6
Bump version to 0.5.7 (#9698) 2024-12-06 17:50:21 -06:00
konsti 6ed6fc108e
Build backend: Add direct builds to the resolver and installer (#9621)
This is like #9556, but at the level of all other builds, including the
resolver and installer. Going through PEP 517 to build a package is
slow, so when building a package with the uv build backend, we can call
into the uv build backend directly instead: No temporary virtual env, no
temp venv sync, no python subprocess calls, no uv subprocess calls.

This fast path is gated through preview. Since the uv wheel is not
available at test time, I've manually confirmed the feature by comparing
`uv venv && cargo run pip install . -v --preview --reinstall .` and `uv
venv && cargo run pip install . -v --reinstall .`. When hacking the
preview so that the python uv build backend works without the setting
the direct build also (wheel built with `maturin build --profile
profiling`), we can see the perfomance difference:

```
$ hyperfine --prepare "uv venv" --warmup 3 \
    "UV_PREVIEW=1 target/profiling/uv pip install --no-deps --reinstall scripts/packages/built-by-uv --preview" \
    "target/profiling/uv pip install --no-deps --reinstall scripts/packages/built-by-uv --find-links target/wheels/"
Benchmark 1: UV_PREVIEW=1 target/profiling/uv pip install --no-deps --reinstall scripts/packages/built-by-uv --preview
  Time (mean ± σ):      33.1 ms ±   2.5 ms    [User: 25.7 ms, System: 13.0 ms]
  Range (min … max):    29.8 ms …  47.3 ms    73 runs
 
Benchmark 2: target/profiling/uv pip install --no-deps --reinstall scripts/packages/built-by-uv --find-links target/wheels/
  Time (mean ± σ):     115.1 ms ±   4.3 ms    [User: 54.0 ms, System: 27.0 ms]
  Range (min … max):   109.2 ms … 123.8 ms    25 runs
 
Summary
  UV_PREVIEW=1 target/profiling/uv pip install --no-deps --reinstall scripts/packages/built-by-uv --preview ran
    3.48 ± 0.29 times faster than target/profiling/uv pip install --no-deps --reinstall scripts/packages/built-by-uv --find-links target/wheels/
```

Do we need a global option to disable the fast path? There is one for
`uv build` because `--force-pep517` moves `uv build` much closer to a
`pip install` from source that a user of a library would experience (See
discussion at #9610), but uv overall doesn't really make guarantees
around the build env of dependencies, so I consider the direct build a
valid option.

Best reviewed commit-by-commit, only the last commit is the actual
implementation, while the preview mode introduction is just a
refactoring touching too many files.
2024-12-04 15:57:18 +00:00
konsti 19c3c08bf3
Improve build frontend error handling (#9611)
Move the error handling for `build_package` into an enum, to avoid
`bail!` and duplicated `.context()` calls.
2024-12-04 09:04:23 +00:00
Zanie Blue ae033e2d3b
Improve message when updater receipt is for a different uv executable (#9487)
Attempts to improve confusing messaging in cases like
https://github.com/astral-sh/uv/issues/6774#issuecomment-2504950681,
when the receipt is for a different uv executable.

```
❯ cargo run --all-features -q -- self update
warning: Self-update is only available for uv binaries installed via the standalone installation scripts.

The current executable is at `/Users/zb/workspace/uv/target/debug/uv` but the standalone installer was used to install uv to `/Users/zb/.cargo`. Are multiple copies of uv installed?
```

Requires https://github.com/axodotdev/axoupdater/pull/221
Closes https://github.com/astral-sh/uv/issues/6774
2024-12-04 01:26:32 +00:00
Zanie Blue 59460b8a7c
Bump version to 0.5.6 (#9612) 2024-12-03 14:13:06 -06:00
Charlie Marsh 75949f3fec
Avoid cloning `String` in marker evaluation (#9598)
## Summary

A small TODO that I found interesting. See:
https://github.com/astral-sh/pubgrub/pull/35.
2024-12-03 14:28:04 +00:00
renovate[bot] 89a25ba465
Update Rust crate rustc-hash to v2.1.0 (#9569) 2024-12-02 01:23:42 +00:00
renovate[bot] b5807754fe
Update Rust crate indexmap to v2.7.0 (#9567) 2024-12-01 20:07:06 -05:00
renovate[bot] 2ee710a620
Update tokio-tracing monorepo (#9566) 2024-12-01 20:06:59 -05:00
renovate[bot] 0a42c3c340
Update Rust crate syn to v2.0.90 (#9564) 2024-12-01 20:06:47 -05:00
renovate[bot] 3ee6ef2556
Update Rust crate rkyv to v0.8.9 (#9563) 2024-12-01 20:06:40 -05:00
renovate[bot] f92640cf2a
Update Rust crate pathdiff to v0.2.3 (#9562) 2024-12-01 20:06:34 -05:00
renovate[bot] fb64fb7e13
Update Rust crate jiff to v0.1.15 (#9561) 2024-12-01 20:06:28 -05:00
renovate[bot] ef20d6a92a
Update Rust crate cargo-util to v0.2.16 (#9560) 2024-12-01 20:06:20 -05:00
konsti 8a863194c8
Use `SharedState` for build dispatch (#9553)
When looking at the build frontend code, I noticed that we always pass
every single field of the shared state to the build dispatch:

```rust
    let build_dispatch = BuildDispatch::new(
        ...
        &state.index,
        &state.git,
        &state.capabilities,
        &state.in_flight,
        ...
    );
```

We can abstract this by moving `SharedState` into the build dispatch.
The `BuildDispatch` then has only immutable fields and the
`SharedState`. Since the `SharedState` is all `Arc`s, we can clone it
freely.
2024-12-01 17:20:28 -05:00
Zanie Blue 95cd8b8b3f
Bump version to 0.5.5 (#9478) 2024-11-27 11:37:39 -06:00
Charlie Marsh 916d5d7778
Migrate to PubGrub's arena for package names (#9448)
## Summary

There's more we can do here, i.e., to leverage the IDs more widely, but
this is a start.
2024-11-26 15:05:39 -05:00
konsti c94777fc54
Initialize rayon lazily (#9435)
When performing a noop sync, we don't need the rayon threadpool, yet we
pay for its initialization:

![Screenshot from 2024-11-26
08-59-07](https://github.com/user-attachments/assets/d918f50d-b5b7-4bdd-820d-cbe71b633aaa)

Be making the initialization lazy, we avoid that cost:

![Screenshot from 2024-11-26
09-53-08](https://github.com/user-attachments/assets/193baea0-667f-4b9d-9a75-886a86f0f837)

This code runs every time before user code in `uv run`.

This means that before calling rayon, one now needs to call
`LazyLock::force(&RAYON_INITIALIZE);`.

Performance mode (CPU 0 is a perf core):
```
$ taskset -c 0 hyperfine --warmup 5 -N "/home/konsti/projects/uv/uv-main sync" "/home/konsti/projects/uv/target/profiling/uv sync"
Benchmark 1: /home/konsti/projects/uv/uv-main sync
  Time (mean ± σ):       4.5 ms ±   0.1 ms    [User: 2.7 ms, System: 1.8 ms]
  Range (min … max):     4.4 ms …   6.4 ms    640 runs
 
  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
 
Benchmark 2: /home/konsti/projects/uv/target/profiling/uv sync
  Time (mean ± σ):       4.4 ms ±   0.1 ms    [User: 2.7 ms, System: 1.6 ms]
  Range (min … max):     4.3 ms …   5.0 ms    679 runs
 
Summary
  /home/konsti/projects/uv/target/profiling/uv sync ran
    1.03 ± 0.04 times faster than /home/konsti/projects/uv/uv-main sync
```

Power saver mode:
```
$ hyperfine --warmup 5 -N "/home/konsti/projects/uv/uv-main sync" "/home/konsti/projects/uv/target/profiling/uv sync"
Benchmark 1: /home/konsti/projects/uv/uv-main sync
  Time (mean ± σ):      28.1 ms ±   1.2 ms    [User: 15.5 ms, System: 20.3 ms]
  Range (min … max):    25.7 ms …  31.9 ms    102 runs
 
Benchmark 2: /home/konsti/projects/uv/target/profiling/uv sync
  Time (mean ± σ):      24.0 ms ±   1.2 ms    [User: 13.8 ms, System: 9.9 ms]
  Range (min … max):    22.2 ms …  28.2 ms    122 runs
 
Summary
  /home/konsti/projects/uv/target/profiling/uv sync ran
    1.17 ± 0.08 times faster than /home/konsti/projects/uv/uv-main sync
```
2024-11-26 14:58:38 +00:00
Charlie Marsh 0158717ae6
Don't warn when `--output-file` is empty (#9417)
## Summary

Closes https://github.com/astral-sh/uv/issues/9410.
2024-11-25 22:09:18 +00:00
renovate[bot] 288d128065
Update Rust crate url to v2.5.4 (#9405) 2024-11-24 20:48:44 -05:00
renovate[bot] 0c944681b1
Update Rust crate syn to v2.0.89 (#9404) 2024-11-24 20:48:37 -05:00
renovate[bot] ab0e1552ac
Update Rust crate proc-macro2 to v1.0.92 (#9403) 2024-11-24 20:48:31 -05:00
renovate[bot] abd8281328
Update Rust crate hashbrown to v0.15.2 (#9402) 2024-11-24 20:48:11 -05:00
renovate[bot] 64f65031b7
Update Rust crate async-compression to v0.4.18 (#9401) 2024-11-24 20:48:03 -05:00
Charlie Marsh c62c83c37a
Bump version to v0.5.4 (#9290) 2024-11-20 16:01:24 -05:00
Charlie Marsh 1b13036674
Add retries for Python downloads (#9274)
## Summary

This uses the same approach as in the rest of uv, but with another
dedicated method for retries.

Closes https://github.com/astral-sh/uv/issues/8525.
2024-11-20 09:42:42 -05:00
Charlie Marsh ccc0962cbd
Use `zlib-rs` on all platforms (#9264) 2024-11-20 00:01:58 -05:00
Ben Beasley 80ab562f9f
In uv-globfilter, use the workspace fs-err in dev-dependencies (#9262)
<!--
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

In uv-globfilter, use the workspace `fs-err` in `dev-dependencies`.

This fixes an unnecessary dev-dependency on `fs-err` 2.x even after the
workspace fs-err was updated to 3.x in
https://github.com/astral-sh/uv/pull/8625.

The `Cargo.lock` file still has `fs-err v2.11.0` after this PR, but it
is via `tracing-durations-export v0.3.0` rather than directly required
by any `uv` crate.

## Test Plan

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

```
$ cd crates/uv-globfilter/
$ cargo test
```
2024-11-20 03:59:37 +00:00
Charlie Marsh 45eeae61ff
Use existing index field in PEP 723 scripts (#9238)
## Summary

Purely internal, this setting already exists.
2024-11-19 14:45:12 -05:00
Charlie Marsh 56d3622087
Bump version to v0.5.3 (#9229) 2024-11-19 18:53:54 +00:00
renovate[bot] dae630ae50
Update Rust crate fs-err to v3 (#8625) 2024-11-19 15:09:00 +00:00
Charlie Marsh 0aaa6ba5be
Migrate to `zlib-rs` (#9184)
## Summary

I've tried this a few times; just curious if it passes tests.
2024-11-18 15:45:14 +00:00
konsti a07d5a1d18
Update pubgrub to `Ranges::from_iter` (#9145)
Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-11-18 12:28:17 +00:00
renovate[bot] b7de92d22c
Update Rust crate spdx to v0.10.7 (#9182) 2024-11-17 20:50:26 -05:00
renovate[bot] ff95014584
Update Rust crate serde_json to v1.0.133 (#9181) 2024-11-17 20:50:09 -05:00
renovate[bot] 655704a603
Update Rust crate regex-automata to v0.4.9 (#9179) 2024-11-17 20:49:51 -05:00
renovate[bot] e2ca4cf833
Update Rust crate indicatif to v0.17.9 (#9178) 2024-11-17 20:49:26 -05:00
renovate[bot] 352e3341de
Update Rust crate flate2 to v1.0.35 (#9176) 2024-11-17 20:48:21 -05:00
renovate[bot] b8a0ae8f27
Update Rust crate clap to v4.5.21 (#9175) 2024-11-17 20:48:01 -05:00
renovate[bot] c358161497
Update Rust crate serde to v1.0.215 (#9180) 2024-11-17 20:47:38 -05:00
Charlie Marsh 8dd095cab8
Include version constraints in derivation chains (#9112)
## Summary

Derivation chains can now include the versions at which a package was
requested.
2024-11-15 15:06:24 -05:00
renovate[bot] 312ae12650
Update Rust crate thiserror to v2 (#9006) 2024-11-15 09:54:16 -06:00
Michał Górny dafbd7d405
Update "tl" crate URL following repository transfer (#9147)
## Summary

Update the URL to the "tl" crate since the repository has been
transferred to astral-sh/. This is of no real consequence, except it
keeps triggering Gentoo linter that detects permanently redirected URL.

## Test Plan

`cargo test`
2024-11-15 13:07:51 +00:00
konsti 997ff9d57a
Allow apostrophe in venv name (#8984)
Escape an apostrophe in the venv path name.

Fixes #8947
2024-11-15 10:52:10 +01:00
konsti 0abb2a4595
Refactor shell quoting (#9055)
Move the shlex-like quoting utils in the uv-shell crate, so we only
write `r#"'"'"'"#` once.

Split out from #8984
2024-11-15 09:06:54 +00:00
Zanie Blue 195f4b634f
Bump version to 0.5.2 (#9133) 2024-11-14 15:59:50 -06:00
Charlie Marsh eb4330acc7
Add support for async unzipping with ZIP64 archives (#9110)
## Summary

See: https://github.com/charliermarsh/rs-async-zip/pull/4.

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

## Test Plan

I created a wheel with 100,000 files in it.

I verified that `uv pip install
https://github.com/astral-sh/uv/raw/refs/heads/charlie/sixtyfour/sixtyfour/dist/sixtyfour-0.1.0-py3-none-any.whl`
fails, while `cargo run pip install
https://github.com/astral-sh/uv/raw/refs/heads/charlie/sixtyfour/sixtyfour/dist/sixtyfour-0.1.0-py3-none-any.whl`
succeeds, and I can then `import sixtyfour`, `import
sixtyfour.file_20557`, etc.
2024-11-14 21:45:41 +00:00
Charlie Marsh a552f74308
Refactor `Resolution` type to retain dependency graph (#9106)
## Summary

This PR should not contain any user-visible changes, but the goal is to
refactor the `Resolution` type to retain a dependency graph. We want to
be able to explain _why_ a given package was excluded on error (see:
https://github.com/astral-sh/uv/issues/8962), which in turn requires
that at install time, we can go back and figure out the dependency
chain. At present, `Resolution` is just a map from package name to
distribution; this PR remodels it as a graph in which each node is a
package, and the edges contain markers plus extras or dependency groups.
2024-11-14 15:25:34 -05:00
konsti 3a7db17147
Build backend: Add source tree -> source dist -> wheel tests (#9091)
A first milestone: source tree -> source dist -> wheel -> install works.
This PR adds a test for this.

There's obviously a lot still missing, including basics such as the
Readme inclusion.
2024-11-14 19:15:32 +00:00
konsti 4ac78f673b
Build backend: Switch to custom glob-walkdir implementation (#9013)
When doing a directory traversal for source dist inclusion, we want to
offer the user include and exclude options, and we want to avoid
traversing irrelevant directories. The latter is important for
performance, especially on network file systems, but also with large
data directories, or (not-included) directories with other permissions.
To support this, we introduce `GlobDirFilter`, which uses a DFA from
regex_automata to determine whether any children of a directory can be
included and skips the directory if not.

The globs are based on PEP 639. The syntax is more restricted than glob
or globset, but it's standardized. I chose it over glob or globset
because we're already using this syntax for `project.license-files` a
required by PEP 639, so it makes sense to use the same globs for all
includes (see e.g.
4f52a3bb62/pyproject.toml (L36-L48)
for example with same semantics for include and exclude)

### Semantics

Glob semantics are complex due to mixing directories and files,
expectations around simplicity and our need to exclude most of the tree
in the project from traversal. The current draft uses a syntax that
optimizes for simple default use cases for the start.

#### includes

Glob expressions which files and directories to include in the source
distribution.

Includes are anchored, which means that `pyproject.toml` includes only
`<project root>/pyproject.toml`. Use for example `assets/**/sample.csv`
to include for all
`sample.csv` files in `<project root>/assets` or any child directory. To
recursively include
all files under a directory, use a `/**` suffix, e.g. `src/**`. For
performance and
reproducibility, avoid unanchored matches such as `**/sample.csv`.

The glob syntax is the reduced portable glob from
[PEP 639](https://peps.python.org/pep-0639/#add-license-FILES-key).

#### excludes

Glob expressions which files and directories to exclude from the
previous source
distribution includes.

Excludes are not, which means that `__pycache__` excludes all
directories named
`__pycache__` and it's children anywhere. To anchor a directory, use a
`/` prefix, e.g.,
`/dist` will exclude only `<project root>/dist`.

The glob syntax is the reduced portable glob from
[PEP 639](https://peps.python.org/pep-0639/#add-license-FILES-key).
2024-11-14 13:14:58 +00:00
Andrew Gallant 06943ca870 uv-pypi-types: make room for group names in addition to extras
This adds support for providing conflicting group names in addition to
extra names to `Conflicts`.

This merely makes "room" for it in the types while keeping everything
working. We'll add proper support for it in the next commit.

Note that one interesting trick we do here is depend directly on
`hashbrown` so that we can make use of its `Equivalent` trait. This in
turn lets us use things like `ConflictItemRef` as a lookup key for a
hashset that contains `ConflictItem`. This mirrors using a `&str` as a
lookup key for a hashset that contains `String`, but works for arbitrary
types. `std` doesn't support this, but `hashbrown` does. This trick in
turn lets us simplify some of our data structures.

This also rejiggers some of the serde-interaction with the conflicting
types. We now use a wire type to represent our conflicting items for
more flexibility. i.e., Support `extra` XOR `group` fields.
2024-11-14 08:02:46 -05:00
Andrew Gallant 15ef807c80
add support for specifying conflicting extras (#8976)
This PR adds support for conflicting extras. For example, consider
some optional dependencies like this:

```toml
[project.optional-dependencies]
project1 = ["numpy==1.26.3"]
project2 = ["numpy==1.26.4"]
```

These dependency specifications are not compatible with one another.
And if you ask uv to lock these, you'll get an unresolvable error.

With this PR, you can now add this to your `pyproject.toml` to get
around this:

```toml
[tool.uv]
conflicting-groups = [
    [
      { package = "project", extra = "project1" },
      { package = "project", extra = "project2" },
    ],
]
```

This will make the universal resolver create additional forks
internally that keep the dependencies from the `project1` and
`project2` extras separate. And we make all of this work by reporting
an error at **install** time if one tries to install with two or more
extras that have been declared as conflicting. (If we didn't do this,
it would be possible to try and install two different versions of the
same package into the same environment.)

This PR does *not* add support for conflicting **groups**, but it is
intended to add support in a follow-up PR.

Closes #6981

Fixes #8024

Ref #6729, Ref #6830

This should also hopefully unblock
https://github.com/dagster-io/dagster/pull/23814, but in my testing, I
did run into other problems (specifically, with `pywin`). But it does
resolve the problem with incompatible dependencies in two different
extras once you declare `test-airflow-1` and `test-airflow-2` as
conflicting for `dagster-airflow`.

NOTE: This PR doesn't make `conflicting-groups` public yet. And in a
follow-up PR, I plan to switch the name to `conflicts` instead of
`conflicting-groups`, since it will be able to accept conflicting extras
_and_ conflicting groups.
2024-11-13 09:52:28 -05:00
konsti 828045cd27
Use crates.io reqwest-middleware (#9058)
Thanks to https://github.com/TrueLayer/reqwest-middleware/pull/198, we
can now remove the git dependency and switch back to a crates.io
dependency.
2024-11-12 13:57:47 +00:00
Shane Kennedy 052b4e77a6
Handle sigterm calls, fixes #6724 (#8933)
<!--
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

This PR builds off of https://github.com/astral-sh/uv/pull/6738 to fix
#6724 (sorry for the new PR @charliermarsh I didn't want to push to your
branch, not even sure if I could). The reason the original PR doesn't
fix the issue described in #6724 is because the fastapi is ran in the
project context (as I assume a lot of use cases are). This PR adds an
extra commit to handle the signals in the project/run.rs file

~It also addresses the comment
[here](https://github.com/astral-sh/uv/pull/6738/files#r1734757548) to
not use the tokio ctrl-c method since we are now handling SIGINT
ourselves~ update, tokio handles SIGINT in a platform agnostic way,
intercepting this ouselves makes the logic more complicated with
windows, decided to leave the tokio ctrl-c handler

~[This
comment](https://github.com/astral-sh/uv/pull/6738/files#r1743510140)
remains unaddressed, however, the Child process does not have any other
methods besides kill() so I don't see how we can "preserve" the
interrupt call :/ I tried looking around but no luck.~ updated, this PR
is reduced to only handling SIGTERM propagation on unix machines, and
the sigterm call to the child is preserved by making use of the nix
package, instead of relying on tokio which only allowed for `kill()` on
a child process

## Test Plan

I tested this by building the docker container locally with these
changes and tagging it "myuv", and then using that as the base image in
uv-docker-example, (and ofc following the rest of the repro issues in
#6724. In my tests I see that ctrl-c in the docker-compose up command
exits the process almost immediately 👍

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-11-11 20:48:21 -06:00
Charlie Marsh e059c25bd6
Consistently box distributions in fetch and build errors (#9038)
## Summary

This is useful for pattern-matching.
2024-11-12 02:19:38 +00:00
renovate[bot] 9368268e49
Update Rust crate url to v2.5.3 (#9002) 2024-11-11 14:49:31 +00:00
renovate[bot] 489d42a012
Update Rust crate tempfile to v3.14.0 (#9004) 2024-11-11 02:38:48 +00:00
renovate[bot] 0e3bcb8d92
Update Rust crate tokio to v1.41.1 (#9001) 2024-11-11 02:26:40 +00:00
renovate[bot] 1818bb0ed3
Update Rust crate rustix to v0.38.40 (#9000) 2024-11-11 02:22:16 +00:00
renovate[bot] 52fa269939
Update Rust crate reflink-copy to v0.1.20 (#8999) 2024-11-11 02:20:57 +00:00
renovate[bot] 3c10a430f6
Update Rust crate csv to v1.3.1 (#8998) 2024-11-11 02:19:28 +00:00
renovate[bot] 399a3a25a8
Update Rust crate boxcar to v0.2.7 (#8997) 2024-11-11 02:14:27 +00:00
renovate[bot] ce14207e2e
Update Rust crate anyhow to v1.0.93 (#8996) 2024-11-11 02:13:34 +00:00
renovate[bot] 5832076e65
Update Rust crate anstream to v0.6.18 (#8995) 2024-11-11 02:12:27 +00:00
Zanie Blue f399a52719
Bump to 0.5.1 (#8959) 2024-11-08 17:15:28 -06:00
Charlie Marsh 0db38844d9
Enable uv to replace and delete itself on Windows (#8914)
## Summary

On Windows, we can't delete the currently-running executable -- at
least, not trivially. But the
[`self_replace`](https://docs.rs/self-replace/latest/self_replace/)
crate can help us here.

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

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

## Test Plan

On my Windows machine:

- `maturin build`
- `python -m venv .venv`
- `.venv/Scripts/activate`
- `pip install /path/to/uv.whl`
- `uv pip install /path/to/uv.whl`
- `uv pip uninstall uv`
2024-11-07 21:57:38 -05:00
Zanie Blue 8d665267cd
Bump version to 0.5.0 (#8899)
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
2024-11-07 22:38:25 +00:00
Zanie Blue 1df8f86c22 Eliminate dependencies on `directores` and `dirs-sys` (#8048)
Migrate all directory related logic to `etcetera`, eliminated two
dependecies.
2024-11-07 14:29:54 -06:00
konsti 107ab3d71c
Build basic source distributions (#8886)
Very basic source distribution support. What's included:

- Include and exclude patterns (hard-coded): Currently, we have
globset+walkdir in one part and glob in the other. I'll migrate
everything to globset+walkset and some custom perf optimizations to
avoid traversing irrelevant directories on top. I'll also pick a glob
syntax (or subset), PEP 639 seems like a good candidate since it's
consistent with what we already have to support.
- Add the `PKG-INFO` file with metadata: Thanks to Code Metadata 2.2,
this metadata is reliable and can be read statically by external tools.

Example output:

```
$ tar -ztvf dist/dummy-0.1.0.tar.gz
-rw-r--r-- 0/0             154 1970-01-01 01:00 dummy-0.1.0/PKG-INFO
-rw-rw-r-- 0/0             509 1970-01-01 01:00 dummy-0.1.0/pyproject.toml
drwxrwxr-x 0/0               0 1970-01-01 01:00 dummy-0.1.0/src/dummy
drwxrwxr-x 0/0               0 1970-01-01 01:00 dummy-0.1.0/src/dummy/submodule
-rw-rw-r-- 0/0              30 1970-01-01 01:00 dummy-0.1.0/src/dummy/submodule/impl.py
-rw-rw-r-- 0/0              14 1970-01-01 01:00 dummy-0.1.0/src/dummy/submodule/__init__.py
-rw-rw-r-- 0/0              12 1970-01-01 01:00 dummy-0.1.0/src/dummy/__init__.py
```

No tests since the source distributions don't build valid wheels yet.
2024-11-07 14:29:54 +01:00
Charlie Marsh b98bdc818f
Add support for `pip list --outdated` (#8872)
## Summary

Closes https://github.com/astral-sh/uv/issues/2150.
2024-11-07 02:32:30 +00:00
Jo dcd24b7c42
Add progress bar for `uv cache clean` (#8857)
## Summary

Closes #8786
2024-11-06 11:43:43 -05:00
Zanie Blue 61ed2a236a
Bump version to 0.4.30 (#8820) 2024-11-04 18:52:57 -06:00
Zanie Blue fb1d679f69
Improve interactions with existing Python executables during install (#8733)
Previously, we'd use the `--reinstall` flag to determine if we should
replace existing Python executables in the bin directory during an
install. There are a few problems with this:

- We replace executables we don't manage
- We can replace executables from other uv Python installations during
reinstall (surprising)
- We don't do the "right" thing when installing patch versions e.g.
installing `3.12.4` then `3.12.6` would fail without the reinstall flag

In `uv tool`, we have separate `--force` and `--reinstall` concepts.
Here we separate the flags (`--force` was previously just a
`--reinstall` alias) and add inspection of the existing executables to
inform a decision on replacement.

In brief, we will:

- Replace any executables with `--force`
- Replace executables for the same installation with `--reinstall`
- Replace executables for an older patch version by default
2024-11-04 20:22:44 +00:00
Charlie Marsh a42c09fdfb
Add support for `.env` and custom env files in `uv run` (#8811)
## Summary

This PR pulls in https://github.com/astral-sh/uv/pull/8263 and
https://github.com/astral-sh/uv/pull/8463, which were originally merged
into the v0.5 tracking branch but can now be committed separately, as
we've made `.env` loading opt-in.

In summary:

- `.env` loading is now opt-in (`--env-file .env`).
- `.env` remains supported on `uv run`, so it's meant for providing
environment variables to the run command, rather than to uv itself.

---------

Co-authored-by: Eduardo González Vaquero <47718648+edugzlez@users.noreply.github.com>
2024-11-04 14:26:05 -05:00
renovate[bot] a052418dcd
Update Rust crate which to v7 (#8794) 2024-11-03 21:15:17 -05:00
renovate[bot] e77ecfd2bd
Update Rust crate procfs to 0.17.0 (#8793) 2024-11-03 21:15:10 -05:00
renovate[bot] f234ec37d5
Update Rust crate axoupdater to 0.8.0 (#8792) 2024-11-03 21:15:04 -05:00
renovate[bot] 15d003a65f
Update Rust crate thiserror to v1.0.67 (#8790) 2024-11-03 21:14:54 -05:00
renovate[bot] aa96307273
Update Rust crate syn to v2.0.87 (#8789) 2024-11-03 21:14:51 -05:00
Jo 3dfedf1fef
Generate environment variables doc from code (#8493)
## Summary

Resolves #8417

I've just begun learning procedural macros, so this PR is more of a
proof of concept. It's still a work in progress, and I welcome any
assistance or feedback.
2024-11-03 08:31:38 -06:00
Charlie Marsh d3e50a2376
Enable `--all-packages --frozen` in `uv sync` and `uv export` (#8760)
## Summary

This PR improves the interaction of `--frozen` such that we reduce the
dependency on the `pyproject.toml` and increase the dependency on the
`uv.lock`. Specifically, we now read the list of workspace members from
the `uv.lock` rather than the `pyproject.toml`, which means we don't
need to discover the member `pyproject.toml` files in order to perform a
`uv sync --frozen --all-packages`.
2024-11-02 02:48:55 +00:00
Charlie Marsh f4da6ffdd6
Run `cargo update` (#8703)
Pull in https://github.com/prefix-dev/async_http_range_reader/pull/19,
removes a version of `itertools`.
2024-11-01 10:26:21 -04:00
Andrew Gallant 049ccf7d77
uv-client: switch to RFC 9110 compatible format (#8752)
This still utilizes the RFC 2822 datetime formatter, but utilizes new
methods [added in jiff 0.1.14] to emit timestamps in a format strictly
compatible with RFC 9110.

It seems like most HTTP servers were pretty flexible and supported RFC
2822 datetime formats, but #8747 shows at least one case where that
isn't true. Given that the [MDN docs prescribe RFC 9110], we defer to
them.

Fixes #8747

[added in jiff 0.1.14]: https://github.com/BurntSushi/jiff/pull/154
[MDN docs prescribe RFC 9110]:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since
2024-11-01 09:46:24 -04:00
Zanie Blue 8d3408fe39
Add support for installing versioned Python executables on Windows (#8663)
Incorporating #8637 into #8458 

- Adds `python-managed` feature selection to Windows CI for `python
install` tests
- Adds trampoline sniffing utilities to `uv-trampoline-builder`
- Uses a trampoline to install Python executables into the `PATH` on
Windows
2024-10-31 15:58:35 +00:00
konsti 082259493e
Skip existing, second iteration: Check the index before uploading (#8531)
Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-10-31 16:23:12 +01:00
Zanie Blue 85f9a0d0ec
Bump version to 0.4.29 (#8711) 2024-10-30 18:22:53 -05:00
Zanie Blue 4dd36b799f
Install versioned Python executables into the bin directory during `uv python install` (#8458)
Updates `uv python install` to link `python3.x` in the executable
directory (i.e., `~/.local/bin`) to the the managed interpreter path.

Includes

- #8569 
- #8571 

Remaining work

- #8663 
- #8650 
- Add an opt-out setting and flag
- Update documentation
2024-10-30 14:13:20 +00:00
konsti 94fc35edd9
Fix feature scoping for pep508 wasm32 support for ruff (#8694) 2024-10-30 12:21:23 +00:00
konsti c1a0fb35e8
Simplify pep440 -> version ranges conversion (#8683) 2024-10-30 13:10:48 +01:00
konsti d0afd10ca4
Update windows-registry to 0.3.0 (#8696) 2024-10-30 12:00:33 +00:00
Pietro Zambelli 2b0e16cb75
Fix hard and soft float libc detection for managed Python distributions on ARM (#8498) 2024-10-29 23:46:21 +00:00
Charlie Marsh 2e14724224
Handle cycles in `uv pip tree` (#8689)
## Summary

Porting the improvements I made to `uv tree` over to `uv pip tree`.

Closes #8678.
2024-10-29 22:18:46 +00:00
konsti e5b8cdba70
Merge uv-pubgrub into uv-pep440 (#8669) 2024-10-29 20:15:18 +01:00
konsti 36102dbd0e
Start using the version ranges crate (#8667) 2024-10-29 16:39:50 +00:00
Zanie Blue c335dc5e5d
Add a trampoline variant that just executes `python` (#8637)
Currently, our trampoline is used to convert `<command> [args]` to
`python <command> [args]` for script entrypoints installed into virtual
environments. For #8458, it'd be nice to convert a shim `python3.12
[args]` to `python [args]`. Here, we modify the trampolines to support
this use-case.

The only change we really need here is to avoid injecting `<command>`
into the child process. We change the "magic number" at the end of the
trampoline executables from `UVUV` to `UVSC` and `UVPY` which define
"script" and "python" variants to the trampoline. We then omit the
`<command>` injection in the latter case. We also omit writing the zip
script payload.

To support construction of the new variant, a new
`uv-trampoline-builder` crate is introduced — this avoids requirements
on `uv-install-wheel` in future work. I also use `uv-trampoline-builder`
to consolidate some of the test setup for `uv-trampoline`.

There should be no backwards compatibility concerns, since trampolines
are fully self-referential.

I rebased to fix the commits at the end, as this took many iterations to
get working via CI. This should roughly be reviewable by commit if you
prefer.
2024-10-29 09:21:15 -05:00
Zanie Blue 4c82561488
Bump version to 0.4.28 (#8648) 2024-10-28 16:38:59 -05:00
renovate[bot] f239f258c1
Update Rust crate tokio to v1.41.0 (#8623) 2024-10-28 01:25:09 +00:00
renovate[bot] 8216f871d4
Update Rust crate insta to v1.41.0 (#8622) 2024-10-28 01:20:21 +00:00
renovate[bot] b7f3e7a7f8
Update Rust crate goblin to 0.9.0 (#8621) 2024-10-28 01:13:20 +00:00
renovate[bot] be92a2bbef
Update Rust crate thiserror to v1.0.65 (#8618) 2024-10-28 01:06:22 +00:00
renovate[bot] 6777a19d92
Update Rust crate syn to v2.0.85 (#8617) 2024-10-28 01:04:14 +00:00
renovate[bot] 454eb3cbaf
Update Rust crate serde to v1.0.213 (#8616) 2024-10-28 01:01:59 +00:00
renovate[bot] dd67763dd2
Update Rust crate rustix to v0.38.38 (#8615) 2024-10-28 01:01:21 +00:00
renovate[bot] f2f5cd45dd
Update Rust crate regex to v1.11.1 (#8614) 2024-10-28 00:59:38 +00:00
renovate[bot] 2161f34ef1
Update Rust crate proc-macro2 to v1.0.89 (#8613) 2024-10-27 20:56:46 -04:00
renovate[bot] 0a83f957fb
Update Rust crate anyhow to v1.0.91 (#8612) 2024-10-27 20:56:33 -04:00
renovate[bot] b896c1a853
Update Rust crate anstream to v0.6.17 (#8611) 2024-10-27 20:56:26 -04:00
Zanie Blue 4727acbc62
Bump version to 0.4.27 (#8573) 2024-10-25 19:06:06 +00:00
Charlie Marsh 1b9b9d56b3
Bump version to v0.4.26 (#8508) 2024-10-23 15:17:49 -04:00
Charlie Marsh 72185baf70
Avoid rewriting `[[tool.uv.index]]` entries when credentials are provided (#8502)
## Summary

Instead of creating a new entry, we should reuse the existing entry (to
preserve decor); similarly, we should avoid overwriting fields that are
already "correct".

Closes https://github.com/astral-sh/uv/issues/8483.
2024-10-23 10:57:13 -04:00
Zanie Blue d6d6de8769
Upgrade `axoupdater` (#8475) 2024-10-22 20:46:01 -04:00
Zanie Blue 2f6fa082c4
Add `uv-dirs` to consolidate directory lookup methods (#8453)
I need the executable directory outside `uv-tool` and figured I should
consolidate these to a central location.
2024-10-22 11:33:25 -05:00
Ben Beasley 40f842df09
Switch from a git snapshot to released rust-netrc 1.1.2 (#8424)
<!--
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? -->

Before this PR (and since 651fe6f4e6) `uv`
depends on a git snapshot of `rust-netrc` at
544f3890b6,
with fixes from https://github.com/gribouille/netrc/pull/3 for
https://github.com/astral-sh/uv/issues/8003.

Since `rust-netrc` 0.1.2 was just released, and it includes those fixes
– plus an additional [change to support
`~`-expansion](ca0860c0a0)
– `uv` can go back to depending on published crates from crates.io.

## Test Plan

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

```
$ cargo build
$ cargo run python install
$ cargo test
```

I get

```

────────────────────────────────────────────────────────────────────────────────

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Snapshot Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Snapshot: sha
Source: crates/uv/tests/it/build.rs:1454
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Expression: snapshot
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
-old snapshot
+new results
────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   11    11 │ writing top-level names to src/project.egg-info/top_level.txt
   12    12 │ writing manifest file 'src/project.egg-info/SOURCES.txt'
   13    13 │ reading manifest file 'src/project.egg-info/SOURCES.txt'
   14    14 │ writing manifest file 'src/project.egg-info/SOURCES.txt'
         15 │+[CACHE_DIR]/builds-v0/[TMP]/pkg_resources.html
         16 │+  import pkg_resources
   15    17 │ running sdist
   16    18 │ running egg_info
   17    19 │ writing src/project.egg-info/PKG-INFO
   18    20 │ writing dependency_links to src/project.egg-info/dependency_links.txt
┈┈┈┈┈┈┈┈┈┈┈┈┼┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
   35    37 │ copying src/project.egg-info/top_level.txt -> project-0.1.0/src/project.egg-info
   36    38 │ Writing project-0.1.0/setup.cfg
   37    39 │ Creating tar archive
   38    40 │ removing 'project-0.1.0' (and everything under it)
         41 │+[CACHE_DIR]/builds-v0/[TMP]/pkg_resources.html
         42 │+  import pkg_resources
   39    43 │ Building wheel from source distribution...
   40    44 │ running egg_info
   41    45 │ writing src/project.egg-info/PKG-INFO
   42    46 │ writing dependency_links to src/project.egg-info/dependency_links.txt
   43    47 │ writing requirements to src/project.egg-info/requires.txt
   44    48 │ writing top-level names to src/project.egg-info/top_level.txt
   45    49 │ reading manifest file 'src/project.egg-info/SOURCES.txt'
   46    50 │ writing manifest file 'src/project.egg-info/SOURCES.txt'
         51 │+[CACHE_DIR]/builds-v0/[TMP]/pkg_resources.html
         52 │+  import pkg_resources
   47    53 │ running bdist_wheel
   48    54 │ running build
   49    55 │ running build_py
   50    56 │ creating build
┈┈┈┈┈┈┈┈┈┈┈┈┼┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
   73    79 │ adding 'project-0.1.0.dist-info/WHEEL'
   74    80 │ adding 'project-0.1.0.dist-info/top_level.txt'
   75    81 │ adding 'project-0.1.0.dist-info/RECORD'
   76    82 │ removing build/bdist.linux-x86_64/wheel
         83 │+[CACHE_DIR]/builds-v0/[TMP]/pkg_resources.html
         84 │+  import pkg_resources
   77    85 │ Successfully built dist/project-0.1.0.tar.gz and dist/project-0.1.0-py3-none-any.whl
────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
To update snapshots run `cargo insta review`
Stopped on the first failure. Run `cargo insta test` to run all snapshots.
thread 'build::sha' panicked at /home/ben/.cargo/registry/src/index.crates.io-6f17d22bba15001f/insta-1.40.0/src/runtime.rs:548:9:
snapshot assertion for 'sha' failed in line 1454
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    build::sha

test result: FAILED. 1299 passed; 1 failed; 4 ignored; 0 measured; 0 filtered out; finished in 101.18s

error: test failed, to rerun pass `-p uv --test it`
```

The sole failure looks unrelated to me, and I can reproduce it on `main`
(currently e8b8daf0fb), so I conclude that
it has nothing to do with this change.
2024-10-21 14:43:07 -04:00
Amjith Ramanujam 351ad84eaf
Add support for system-level `uv.toml` configuration (#7851)
## Summary

Look for a system level uv.toml config file under `/etc/uv/uv.toml` or
`C:\ProgramData`.

This PR is to address #6742 and start a conversation. 

## Test Plan

This was tested locally manually on MacOS. I am happy to contribute
tests once we settle on the approach.

cc @thatch

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-21 17:33:02 +00:00
Charlie Marsh 97eb6ab4aa
Bump version to v0.4.25 (#8402) 2024-10-21 00:37:50 +00:00
renovate[bot] 451e3578ca
Update Rust crate syn to v2.0.82 (#8400) 2024-10-21 00:18:58 +00:00
renovate[bot] a372c8117f
Update Rust crate proc-macro2 to v1.0.88 (#8398) 2024-10-21 00:14:02 +00:00
renovate[bot] 4d2f31cb75
Update Rust crate serde_json to v1.0.132 (#8399) 2024-10-21 00:13:41 +00:00
renovate[bot] 12fbd37cd0
Update Rust crate async-compression to v0.4.17 (#8396) 2024-10-21 00:12:40 +00:00
renovate[bot] 159b664f95
Update Rust crate anyhow to v1.0.90 (#8395) 2024-10-21 00:10:22 +00:00
konsti e3e1403c4b
Update reqwest-middleware (#8325) 2024-10-18 11:51:02 +00:00
konsti 32bba9f33b
Don't prefetch unreachable packages (#8246) 2024-10-18 13:44:24 +02:00
Zanie Blue b9cd549138
Bump version to 0.4.24 (#8312) 2024-10-17 18:50:13 -05:00
Charlie Marsh 7beb5ebe26
Improve sources deserialization errors (#8308) 2024-10-17 21:33:04 +00:00
Zanie Blue 83f835b0d0
Bump version to 0.4.23 (#8275)
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-17 14:26:39 +00:00
Charlie Marsh 4ca158931a
Show hint in resolution failure on `Forbidden` (`403`) or `Unauthorized` (`401`) (#8264)
## Summary

Closes https://github.com/astral-sh/uv/issues/8167.
2024-10-16 17:34:29 +00:00
konsti 31bf8eb43b
Update PubGrub (#8245) 2024-10-16 15:39:23 +00:00
Charlie Marsh 6a81d302bb
Update to hyper v1.5.0 (#8254)
Saw a Tweet about this, it has some nice improvements.
2024-10-16 13:52:15 +00:00
samypr100 b4dca669b4
chore(uv): update env vars map to include newly added ones (#8233)
## Summary

Add some new env var mappings

## Test Plan

Existing tests
2024-10-15 21:40:09 -04:00
Charlie Marsh 1925922770
Enable environment variable authentication for named indexes (#7741)
## Summary

This PR enables users to provide index credentials via named environment
variables.

For example, given an index named `internal` that requires a username
(`public`) and password
(`koala`), you can define the index (without credentials) in your
`pyproject.toml`:

```toml
[[tool.uv.index]]
name = "internal"
url = "https://pypi-proxy.corp.dev/simple"
```

Then set the `UV_INDEX_INTERNAL_USERNAME` and
`UV_INDEX_INTERNAL_PASSWORD`
environment variables, where `INTERNAL` is the uppercase version of the
index name:

```sh
export UV_INDEX_INTERNAL_USERNAME=public
export UV_INDEX_INTERNAL_PASSWORD=koala
```
2024-10-15 22:35:07 +00:00
Charlie Marsh 5b391770df
Add support for named and explicit indexes (#7481)
## Summary

This PR adds a first-class API for defining registry indexes, beyond our
existing `--index-url` and `--extra-index-url` setup.

Specifically, you now define indexes like so in a `uv.toml` or
`pyproject.toml` file:

```toml
[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu121"
```

You can also provide indexes via `--index` and `UV_INDEX`, and override
the default index with `--default-index` and `UV_DEFAULT_INDEX`.

### Index priority

Indexes are prioritized in the order in which they're defined, such that
the first-defined index has highest priority.

Indexes are also inherited from parent configuration (e.g., the
user-level `uv.toml`), but are placed after any indexes in the current
project, matching our semantics for other array-based configuration
values.

You can mix `--index` and `--default-index` with the legacy
`--index-url` and `--extra-index-url` settings; the latter two are
merely treated as unnamed `[[tool.uv.index]]` entries.

### Index pinning

If an index includes a name (which is optional), it can then be
referenced via `tool.uv.sources`:

```toml
[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu121"

[tool.uv.sources]
torch = { index = "pytorch" }
```

If an index is marked as `explicit = true`, it can _only_ be used via
such references, and will never be searched implicitly:

```toml
[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu121"
explicit = true

[tool.uv.sources]
torch = { index = "pytorch" }
```

Indexes defined outside of the current project (e.g., in the user-level
`uv.toml`) can _not_ be explicitly selected.

(As of now, we only support using a single index for a given
`tool.uv.sources` definition.)

### Default index

By default, we include PyPI as the default index. This remains true even
if the user defines a `[[tool.uv.index]]` -- PyPI is still used as a
fallback. You can mark an index as `default = true` to (1) disable the
use of PyPI, and (2) bump it to the bottom of the prioritized list, such
that it's used only if a package does not exist on a prior index:

```toml
[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu121"
default = true
```

### Name reuse

If a name is reused, the higher-priority index with that name is used,
while the lower-priority indexes are ignored entirely.

For example, given:

```toml
[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu121"

[[tool.uv.index]]
name = "pytorch"
url = "https://test.pypi.org/simple"
```

The `https://test.pypi.org/simple` index would be ignored entirely,
since it's lower-priority than `https://download.pytorch.org/whl/cu121`
but shares the same name.

Closes #171.

## Future work

- Users should be able to provide authentication for named indexes via
environment variables.
- `uv add` should automatically write `--index` entries to the
`pyproject.toml` file.
- Users should be able to provide multiple indexes for a given package,
stratified by platform:
```toml
[tool.uv.sources]
torch = [
  { index = "cpu", markers = "sys_platform == 'darwin'" },
  { index = "gpu", markers = "sys_platform != 'darwin'" },
]
```
- Users should be able to specify a proxy URL for a given index, to
avoid writing user-specific URLs to a lockfile:
```toml
[[tool.uv.index]]
name = "test"
url = "https://private.org/simple"
proxy = "http://<omitted>/pypi/simple"
```
2024-10-15 18:24:23 -04:00
Charlie Marsh 34be3af84f
Bump version to v0.4.22 (#8227) 2024-10-15 16:05:49 -04:00
Jo 0b5cc9595a
Reuse the result of `which git` (#8224)
## Summary

Cache the path to git executable in a `LazyLock` and reuse it throughout
the process. This might reduce some costs on finding the git executable.
2024-10-15 13:50:43 -04:00
Charlie Marsh 855c1917e1
Respect `[tool.uv.sources]` in build requirements (#7172)
## Summary

We weren't respecting `tool.uv.sources` for `build-requires`.

Closes https://github.com/astral-sh/uv/issues/7147.
2024-10-15 15:31:04 +00:00
konsti 7c5d94030d
Mock uv version in build backend tests (#8205) 2024-10-15 09:27:33 +00:00
Ahmed Ilyas 88cbc98eec
Support interactive input in `uv publish` (#8158) 2024-10-15 10:00:43 +02:00
samypr100 01c44af3c3
chore: unify all env vars used (#8151)
## Summary

This PR declares and documents all environment variables that are used
in one way or another in `uv`, either internally, or externally, or
transitively under a common struct.

I think over time as uv has grown there's been many environment
variables introduced. Its harder to know which ones exists, which ones
are missing, what they're used for, or where are they used across the
code. The docs only documents a handful of them, for others you'd have
to dive into the code and inspect across crates to know which crates
they're used on or where they're relevant.

This PR is a starting attempt to unify them, make it easier to discover
which ones we have, and maybe unlock future posibilities in automating
generating documentation for them.

I think we can split out into multiple structs later to better organize,
but given the high influx of PR's and possibly new environment variables
introduced/re-used, it would be hard to try to organize them all now
into their proper namespaced struct while this is all happening given
merge conflicts and/or keeping up to date.

I don't think this has any impact on performance as they all should
still be inlined, although it may affect local build times on changes to
the environment vars as more crates would likely need a rebuild. Lastly,
some of them are declared but not used in the code, for example those in
`build.rs`. I left them declared because I still think it's useful to at
least have a reference.

Did I miss any? Are their initial docs cohesive?

Note, `uv-static` is a terrible name for a new crate, thoughts? Others
considered `uv-vars`, `uv-consts`.

## Test Plan

Existing tests
2024-10-14 16:48:13 -05:00
renovate[bot] 0a23be4a6a
Update Rust crate async-compression to v0.4.15 (#8163) 2024-10-14 21:42:49 +00:00
Charlie Marsh c5d9f55bc4
Bump version to v0.4.21 (#8188) 2024-10-14 20:44:43 +00:00
Charlie Marsh 2901a8d6cc
Run `cargo update` (#8152) 2024-10-12 21:30:52 +00:00
konsti c07000718a
Enable HTTP/2 in reqwest (#8049) 2024-10-09 18:58:24 +02:00
Zanie Blue 651fe6f4e6
Bump netrc crate to latest commit (#8021)
Closes https://github.com/astral-sh/uv/issues/8003
Closes https://github.com/astral-sh/uv/issues/6809

This hasn't been released ~4 months later and these are pretty critical
fixes for Windows users.
2024-10-08 17:15:39 -05:00
Zanie Blue 0e1b25a536
Bump version to 0.4.20 (#8016) 2024-10-08 19:55:21 +00:00
Kemal Akkoyun 1a39ffe391
uv run: List available scripts when a script is not specified (#7687)
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
## Summary

This PR adds the ability to list available scripts in the environment
when `uv run` is invoked without any arguments.
It somewhat mimics the behavior of `rye run` command
(See https://rye.astral.sh/guide/commands/run).

This is an attempt to fix #4024.

## Test Plan

I added test cases. The CI pipeline should pass.

### Manuel Tests

```shell
❯ uv run
Provide a command or script to invoke with `uv run <command>` or `uv run script.py`.

The following scripts are available:

normalizer
python
python3
python3.12

See `uv run --help` for more information.
```

---------

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-10-08 19:34:50 +00:00
renovate[bot] fa4ac3d2bd
Update Rust crate boxcar to v0.2.6 (#7951)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [boxcar](https://redirect.github.com/ibraheemdev/boxcar) |
workspace.dependencies | patch | `0.2.5` -> `0.2.6` |

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/astral-sh/uv).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC45Ny4wIiwidXBkYXRlZEluVmVyIjoiMzguOTcuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiaW50ZXJuYWwiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-08 03:36:44 -04:00
Zanie Blue a451fb6858
Bump version to 0.4.19 (#7991) 2024-10-07 17:32:37 -05:00
renovate[bot] a3e21d61e3
Update Rust crate futures to v0.3.31 (#7953) 2024-10-07 17:59:22 +00:00
renovate[bot] 48792bf3af
Update Rust crate async-compression to v0.4.13 (#7950) 2024-10-07 12:52:14 -05:00
renovate[bot] 6dc06fae67
Update Rust crate clap to v4.5.19 (#7952) 2024-10-07 12:50:35 -05:00
renovate[bot] af32e04fd8
Update Rust crate reqwest to v0.12.8 (#7954) 2024-10-07 12:50:14 -05:00
renovate[bot] 0f691f21f4
Update Rust crate indexmap to v2.6.0 (#7956) 2024-10-07 12:49:54 -05:00
konsti ceafa476c7
Basic functional build backend wheels (#7966) 2024-10-07 19:30:52 +02:00
konsti 5d789c6af7
Implement build backend metadata (#7961) 2024-10-07 10:51:45 +02:00
konsti 92538ada7c
Metadata transformation for the build backend (#7781) 2024-10-07 10:38:40 +02:00
Charlie Marsh 005bb235f0
Improve legibility of build failure errors (#7854)
## Summary

We now...

- Only show `stdout` and/or `stderr` if they're non-empty.
- Use a colorful header for the start of each section
- Highlight the step that failed

## Test Plan

![Screenshot 2024-10-01 at 8 18
42 PM](https://github.com/user-attachments/assets/c3dadf6d-11be-468d-940c-a0a29c4a88f0)
2024-10-03 12:52:53 +00:00
Charlie Marsh 14507a1793
Add `uv-` prefix to all internal crates (#7853)
## Summary

Brings more consistency to the repo and ensures that all crates
automatically show up in `--verbose` logging.
2024-10-01 20:15:32 -04:00
Zanie Blue 7b55e97909
Bump version to 0.4.18 (#7852) 2024-10-01 18:25:34 -05:00
Charlie Marsh 6c7f8bb564
Use build failure hints for `dotenv` errors, rather than in `uv add` (#7825)
## Summary

We now display the "Did you mean `python-dotenv`?"-style errors on build
failure, rather than in `uv add`. This is less opinionated and couples
us less to specific content in the registry.

## Test Plan

![Screenshot 2024-09-30 at 10 15
05 PM](https://github.com/user-attachments/assets/5b6684e2-d992-4f20-82ab-05632779ba91)
2024-10-01 16:31:27 +00:00
konsti bd3c462674
Remove pyo3 feature from pep440 and pep508 crates (#7843) 2024-10-01 14:24:34 +00:00
Charlie Marsh b6de417c94
Use `serde-untagged` to improve some untagged enum error messages (#7822)
## Summary

This is related to https://github.com/astral-sh/uv/issues/7817, but
doesn't close it.
2024-09-30 23:40:21 +00:00
Charlie Marsh f67347e72c
Allow multiple source entries for each package in `tool.uv.sources` (#7745)
## Summary

This PR enables users to provide multiple source entries in
`tool.uv.sources`, e.g.:

```toml
[tool.uv.sources]
httpx = [
  { git = "https://github.com/encode/httpx", tag = "0.27.2", marker = "sys_platform == 'darwin'" },
  { git = "https://github.com/encode/httpx", tag = "0.24.1", marker = "sys_platform == 'linux'" },
]
```

The implementation is relatively straightforward: when we lower the
requirement, we now return an iterator rather than a single requirement.
In other words, the above is transformed into two requirements:

```txt
httpx @ git+https://github.com/encode/httpx@0.27.2 ; sys_platform == 'darwin'
httpx @ git+https://github.com/encode/httpx@0.24.1 ; sys_platform == 'linux'
```

We verify (at deserialization time) that the markers are
non-overlapping.

Closes https://github.com/astral-sh/uv/issues/3397.
2024-09-30 21:16:44 +00:00
Charlie Marsh 71d5661bd8
Add a custom suggestion for `uv add dotenv` (#7799)
## Summary

This was brought up on Twitter recently. `dotenv` hasn't been updated in
years and doesn't build successfully anymore. Users almost always mean
to install `python-dotenv`. I think we can add helpful hints here to
point users in the right direction.

## Test Plan

![Screenshot 2024-09-29 at 9 27
27 PM](https://github.com/user-attachments/assets/72585860-9d98-4478-9eac-2c17ac06178b)
2024-09-30 17:00:31 +00:00
Charlie Marsh b6ce39f45e
Remove lossy resolution-to-requirements conversion in install plan (#7798)
## Summary

This is a longstanding piece of technical debt. After we resolve, we
have a bunch of `ResolvedDist` entries. We then convert those to
`Requirement` (which is lossy -- we lose information like "the index
that the package was resolved to"), and then back to `Dist`.
2024-09-30 10:13:09 -04:00
renovate[bot] 077affc11a
Update Rust crate platform-info to v2.0.4 (#7790) 2024-09-30 01:35:30 +00:00
renovate[bot] 7947422c92
Update Rust crate hyper-util to v0.1.9 (#7789) 2024-09-30 01:10:33 +00:00
renovate[bot] ad6236b903
Update Rust crate regex to v1.11.0 (#7793) 2024-09-29 21:01:13 -04:00
renovate[bot] 9044931c5b
Update Rust crate toml_edit to v0.22.22 (#7792) 2024-09-29 21:01:09 -04:00
renovate[bot] 3b0b1d4dc1
Update Rust crate syn to v2.0.79 (#7791) 2024-09-29 21:01:04 -04:00
renovate[bot] a7038e1b4a
Update Rust crate flate2 to v1.0.34 (#7788) 2024-09-29 21:00:38 -04:00
renovate[bot] 0019aae813
Update Rust crate async-trait to v0.1.83 (#7787) 2024-09-29 21:00:27 -04:00
renovate[bot] bcada9f99c
Update Rust crate tempfile to v3.13.0 (#7795) 2024-09-29 21:00:14 -04:00
Charlie Marsh d2e7b40cec
Bump version to v0.4.17 (#7742) 2024-09-27 13:28:38 -04:00
Jo 0c801f8f4b
Initialize a Git repository in `uv init` (#5476)
## Summary

Similiar to `cargo init --vcs <VCS>`, this PR adds the `--vcs <VCS>`
flag for `uv init`, allowing to create a version control system during
initialization. By default, `uv init` will create a Git repository if
the `--vcs` flag is not provided. Use `--vcs none` to disable this
feature.

Currently, only Git is supported. While Cargo also supports hg, pijul,
and fossil, this initial PR only includes Git. We can add more later if
there are any user requests.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-09-26 02:40:39 +00:00
konsti 9004364de3
Rename `uv-build` to `uv-build-frontend` (#7688)
uv will soon support both a build frontend (`uv build`) and a build
backend (`build-system = "uv"`). To avoid the name clash, I'm renaming
the `uv-build` crate to `uv-build-frontend`. In a follow-up PR, I will
add a `uv-build-backend` crate with the build backend implementation.
2024-09-25 14:17:54 -04:00
tfsingh 106633a5e5
Add support for upgrading Python in tool environments (#7605)
This PR adds support for upgrading the build environment of tools with
the addition of a ```--python``` argument to ```uv upgrade```, as
specified in #7471.

Some things to note:
- I added support for individual packages — I didn't think there was a
good reason for ```--python``` to only apply to all packages
- Upgrading with ```--python``` also upgrades the package itself — I
think this is fair as if a user wants to _strictly_ switch the version
of Python being used to build a tool's environment they can use ```uv
install```. This behavior can of course be modified if others don't
agree!

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

Closes https://github.com/astral-sh/uv/issues/7471.
2024-09-25 17:40:28 +00:00
konsti f5601e2610
Clean up "performance allocators" and "performance flate2" backends (#7686)
Co-authored-by: Amos Wenger <amos@bearcove.net>
2024-09-25 15:41:40 +00:00
Zanie Blue e81ed8ec5d
Bump version to 0.4.16 (#7669) 2024-09-24 14:39:21 -05:00
konsti 16a6fd2c42
Add retries to `uv publish` (#7635) 2024-09-24 16:24:44 +00:00
konsti 205bf8cabe
Implement trusted publishing (#7548)
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-09-24 16:07:20 +00:00
konsti c053dc84f4
Progress bars for `uv publish` (#7613) 2024-09-24 15:55:33 +00:00
konsti 1995d20298
Add `uv publish`: Basic upload with username/password or keyring (#7475)
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-09-24 15:33:06 +00:00
renovate[bot] ab2bba285e
Update Rust crate thiserror to v1.0.64 (#7630) 2024-09-22 22:33:03 -04:00
renovate[bot] 4be9e3aeb3
Update Rust crate clap to v4.5.18 (#7629) 2024-09-22 21:00:58 -04:00
Charlie Marsh 0d81bfbc67
Bump version to v0.4.15 (#7612) 2024-09-21 09:01:20 -04:00
Zanie Blue a497b156bb
Bump version to 0.4.14 (#7600) 2024-09-20 15:08:54 -05:00
Zanie Blue d6c9603594
Fix handling of `sys.base_prefix` collision in interpreter identity check during tool installs (#7596)
Closes https://github.com/astral-sh/uv/issues/7586

Extends https://github.com/astral-sh/uv/pull/7593 (thanks @lucab!)

---------

Co-authored-by: Luca BRUNO <lucab@lucabruno.net>
2024-09-20 14:01:14 -05:00
Zanie Blue b8f9ee3b4d
Bump version to 0.4.13 (#7558) 2024-09-19 20:43:56 +00:00
Charlie Marsh f3463b3d08
Heal cache entries with missing source distributions (#7559)
## Summary

`uv cache prune --ci` will remove the source distribution directory. If
we then need to build a _different_ wheel (e.g., you're building a
package that has Python minor version-specific wheels), we fail, because
we expect the source to be there.

Now, if the source is missing, we re-download it. It would be slightly
easier to just _ignore_ that revision, but that would mean we'd also
lose the already-built wheels -- so if you ran against many Python
versions, we'd continuously lose the cached data.

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

## Test Plan

We can add tests, but they _need_ to build non-pure Python wheels, which
tends to be expensive...

For reference:

```console
$ cargo run venv --python 3.12
$ cargo run pip install mercurial==6.8.1 --verbose
$ cargo run cache prune --ci
$ cargo run venv --python 3.11
$ cargo run pip install mercurial==6.8.1 --verbose
```

I also did this with a local `.tar.gz` that I downloaded from PyPI.
2024-09-19 20:31:55 +00:00
Charlie Marsh e36cc99b0d
Use portable paths when serializing sources (#7504)
## Summary

Closes https://github.com/astral-sh/uv/issues/7493.
2024-09-18 18:51:14 +00: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
Charlie Marsh fe4e39a230
Add `socks` support (#7503)
## Summary

This adds about 50 KB to the binary:

```
❯ du ./target/release/socks
44736	./target/release/socks

❯ du ./target/release/uv
44632	./target/release/uv
```

So need some input on whether it's worth supporting.

Closes https://github.com/astral-sh/uv/issues/7484.
2024-09-18 11:46:06 -04:00
Zanie Blue 8b830de94d
Do not use a user-facing warning for "Waiting to acquire lock..." message (#7502)
Closes https://github.com/astral-sh/uv/issues/7489
2024-09-18 15:34:27 +00:00
Zanie Blue 2545bca692
Bump version to 0.4.12 (#7499) 2024-09-18 08:50:04 -05:00
Charlie Marsh 6c52f36655
Bump version to v0.4.11 (#7478) 2024-09-17 19:48:37 +00:00
Charlie Marsh c87ce7aaf8
Run `cargo upgrade` (#7448)
Co-authored-by: konstin <konstin@mailbox.org>
2024-09-17 12:39:58 +02:00