Commit Graph

4744 Commits

Author SHA1 Message Date
Charlie Marsh
e0f657ed37 DRY up diagnostic reporting for resolution failures (#9044)
## Summary

Not thrilled with this but helps for now. I feel like this
error-handling should happen at the top-level, rather than on all these
individual commands. But we don't have a unified result type at the
top-level of the CLI -- all these commands return `anyhow::Result`.
2024-11-12 14:46:03 +00: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
konsti
5248dff2dc Typo fixes (#9057) 2024-11-12 13:45:22 +00:00
Charlie Marsh
c5caf92edf Use rich diagnostic formatting for install failures (#9043)
## Summary

Shows similar diagnostics for failures that happen at install time,
rather than resolve time. This will ultimately feed into
https://github.com/astral-sh/uv/issues/8962 since we'll now have
consolidated handling for these kinds of failures.
2024-11-11 22:54:30 -05:00
Charlie Marsh
00bf69be28 Revert uv.lock changes when uv add fails (#9030)
## Summary

If a `uv add` fails at the sync stage, we need to clean up the changes
to the `uv.lock`, since it might've been edited during in the lock stage
(which, by necessity, succeeded). As-is, we revert the `pyproject.toml`
but not the `uv.lock`, so the two are out-of-sync.

Closes https://github.com/astral-sh/uv/issues/9028.
Closes https://github.com/astral-sh/uv/issues/7992.
2024-11-12 03:38:05 +00:00
Charlie Marsh
de9dc398a8 Rename fetch_and_build to download_and_build (#9042) 2024-11-12 03:23:29 +00:00
Charlie Marsh
a147ed0b55 Use rich diagnostic formatting for early build failures (#9041)
## Summary

This addresses cases like URL distributions, which are built before we
get to the resolver.
2024-11-12 03:12:38 +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
5187f330c1 Hide --no-system from uv pip tree CLI (#9040)
## Summary

This is hidden from all other commands, so it looks like an oversight.

Closes #9035.
2024-11-12 02:32:31 +00:00
Charlie Marsh
b3c660c58a Rename Fetch to Download in build errors (#9039)
## Summary

We're inconsistent with these -- sometimes it's `Error::Fetch` and
sometimes it's `Error::Download`. The message says download, so let's
just use that?
2024-11-12 02:30:20 +00: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
Charlie Marsh
59f3ec2b6c Remove duplicate Lock::to_resolution (#9029)
## Summary

This got moved to `InstallTarget`! Must've been an oversight not to
delete. I verified that no code was changed here since the date that we
moved it to `InstallTarget`.
2024-11-11 20:30:00 +00:00
Charlie Marsh
dd4b27bfbd Allow --no-build to validate lock (#9024)
## Summary

Just as we don't enforce tag compliance, we shouldn't enforce
`--no-build` when validating the lockfile. If we end up building from
source, the distribution database will correctly error.

Closes https://github.com/astral-sh/uv/issues/9016.
2024-11-11 14:02:37 -05:00
Charlie Marsh
a3c2a36422 Add an error case for --no-binary sync failures (#9025) 2024-11-11 18:52:22 +00:00
Zanie Blue
58bc604b6e Update format of environment variable reference (#9018)
- Sorts the variables
- Separates `UV_` variables from others
- Uses headings so the toc is available
2024-11-11 12:41:33 -06:00
Charlie Marsh
769afa96a4 Avoid retraversing filesystem when testing exact glob matches (#9022)
## Summary

When testing for exact inclusion, we can just test the glob directly.
There's no need to re-traverse the filesystem to find it.
2024-11-11 12:54:35 -05:00
konsti
760cf82ee3 Use Python syntax for value_type consistently (#9017)
Spotted that when looking though `value_type =` declarations.
2024-11-11 17:38:47 +00:00
renovate[bot]
cc5a0dfdbf Update pre-commit dependencies (#9003) 2024-11-11 10:29:39 -06:00
Mathieu Kniewallner
85a7d458f9 docs(tools): mention how to use extras (#8972)
## Summary

Figured this could be helpful to mention in the documentation, as it
might not be obvious that this is possible.

## Test Plan

Tested the commands locally.
2024-11-11 08:58:31 -06:00
renovate[bot]
9368268e49 Update Rust crate url to v2.5.3 (#9002) 2024-11-11 14:49:31 +00:00
Daniel Possenriede
33a227ee72 typo (#9014)
Just a typo
2024-11-11 08:32:05 -06: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
Charlie Marsh
f52bb1b25d Consistent colon usage in build failure errors (#8994) 2024-11-11 02:00:03 +00:00
Charlie Marsh
ac9ce853cf Remove some unused public methods (#8993)
## Summary

Notice these in an unrelated refactor.
2024-11-10 22:55:22 +00:00
Charlie Marsh
744a9091a2 Allow default indexes to be marked as explicit (#8990)
## Summary

Closes https://github.com/astral-sh/uv/issues/8985.
2024-11-10 18:05:39 +00:00
Charlie Marsh
13c3a70ab1 Use [N] in lieu of exact prune counts (#8992)
## Summary

These can seemingly vary.
2024-11-10 12:54:40 -05:00
konsti
874aa29b57 Pin publish test to 3.12 (#8951)
The bump to 3.13 broke the test
2024-11-10 15:43:47 +01:00
konsti
249089c96a Fix prune unzipped snapshot (#8987)
Fixes the tests on main, cause unknown.
2024-11-10 13:52:58 +01:00
Charlie Marsh
a2e90b74bc Avoid creating .venv in uv add --frozen and uv add --no-sync` (#8980)
## Summary

Closes https://github.com/astral-sh/uv/issues/8977.
2024-11-10 02:21:12 +00:00
Charlie Marsh
73ad9f9a07 Remove use of resolution_environment from uv add (#8979)
## Summary

This should only be used in the pip commands; not clear how it ended up
here.
2024-11-10 01:59:00 +00:00
Zanie Blue
dac8c41af6 Some minor copy-edits for the 0.5.0 introduction (#8975) 2024-11-09 11:32:27 -06:00
Mathieu Kniewallner
ecb3e98da0 ci: validate project metadata (#8973)
## Summary

As per https://github.com/astral-sh/uv/pull/8943#discussion_r1835065562,
adding a CI step to validate project metadata. Documentation for the
tool: https://validate-pyproject.readthedocs.io/en/stable/readme.html.
`store` is an extra that uses [this
package](https://github.com/henryiii/validate-pyproject-schema-store) to
get a weekly update of the schema in SchemaStore.

## Test Plan

Step passes on CI, and testing the same command locally while
voluntarily using a wrong classifier fails:
```console
$ uvx --from 'validate-pyproject[all,store]' validate-pyproject pyproject.toml
Invalid file: pyproject.toml
[ERROR] `project.classifiers[5]` must be trove-classifier
```
2024-11-09 08:48:45 -06:00
Charlie Marsh
8a3e5d43e6 Fix references to --resolution-strategy in error message output (#8971)
Closes https://github.com/astral-sh/uv/issues/8967.
2024-11-09 13:54:49 +00:00
Kasper Zutterman
f508ef038c Fix reference to --resolution in docs (#8968)
<!--
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? -->
Update `resolution` to `--resolution`, so it's aligned with the rest of
the resolution documentation, and copy-pastable for usage.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-11-09 13:43:53 +00:00
Zanie Blue
65e2f955f1 Update uv development status classifier to "Stable" on PyPI (#8943)
Closes https://github.com/astral-sh/uv/issues/8941
2024-11-08 21:21:00 -05:00
Charlie Marsh
363c589f76 Prefer compatible to incompatible distributions when packages exist on multiple indexes (#8961)
## Summary

At time of writing, `markupsafe==3.0.2` exists on the PyTorch index, but
there's
only a single wheel:


`MarkupSafe-3.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl`

Meanwhile, there are a large number of wheels on PyPI for the same
version. If the
user is on Python 3.12, and we return the incompatible PyTorch wheel
without
considering the PyPI wheels, PubGrub will mark 3.0.2 as an incompatible
version,
even though there are compatible wheels on PyPI.

Closes https://github.com/astral-sh/uv/issues/8922.
2024-11-08 19:48:48 -05:00
Charlie Marsh
75c26229a2 Support multiple extras in universal pip compile output (#8960)
## Summary

We were making some incorrect assumptions in the extra-merging code for
universal `pip compile`. This PR corrects those assumptions and adds a
bunch of additional tests.

Closes https://github.com/astral-sh/uv/issues/8915.
2024-11-08 18:22:29 -05:00
Zanie Blue
f399a52719 Bump to 0.5.1 (#8959) 0.5.1 2024-11-08 17:15:28 -06:00
Zanie Blue
7f9ab17577 Upgrade to cargo-dist 0.25.2-prerelease.3 (#8958)
Gets us the upstream fix
(https://github.com/axodotdev/cargo-dist/pull/1538Z) for
https://github.com/axodotdev/axoupdater/issues/210 so we don't need to
patch releases manually for self update to work.

Includes a few other changes, i.e., they validate checksums now.
2024-11-08 17:08:23 -06:00
Zanie Blue
ccfc49e7c8 Move "from PyPI" install message to above the relevant code block (#8906)
A minor follow-up to https://github.com/astral-sh/uv/pull/8853

I also included `pipx`, if anyone is opposed I'm happy to drop it.
2024-11-08 17:06:41 -06:00
Charlie Marsh
b5a3d09958 Respect comma-separated extras in --with (#8946)
## Summary

We need to treat `flask,anyio` as two requirements, but
`psycopg[binary,pool]` as a single requirement.

Closes #8918.
2024-11-08 20:13:30 +00:00
Charlie Marsh
0b5a06194b Compute superset of existing and required hashes when healing cache (#8955)
## Summary

The basic issue here is that `uv add` will compute and store a hash for
each package. But if you later run `uv pip install` _after_ `uv cache
prune --ci`, we need to re-download the source distribution. After
re-downloading, we compare the hashes before and after. But `uv pip
install` doesn't compute any hashes by default. So the hashes "differ"
and we error.

Instead, we need to compute a superset of the already-existing and
newly-requested hashes when performing this re-download. (In practice,
this will always be SHA-256.)

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

## Test Plan

```shell
export UV_CACHE_DIR="$PWD/cache"

rm -rf "$UV_CACHE_DIR" .venv .venv-2 pyproject.toml uv.lock

echo $(uv --version)

uv init --name uv-cache-issue
cargo run add --python 3.13 "pycairo"

uv cache prune --ci

rm -rf .venv .venv-2

uv venv --python python3.11 .venv-2
. .venv-2/bin/activate
cargo run pip install "pycairo"
```
2024-11-08 15:12:15 -05:00
konsti
f29634bbaa Wait longer for index updates in publish test (#8950)
Increasing the timeout for
https://github.com/astral-sh/uv/actions/runs/11745370474/job/32722897436
2024-11-08 16:49:38 +00:00