Commit graph

2872 commits

Author SHA1 Message Date
konsti
e34ab96e80
Remove special casing from no solution error (#5067)
The only pubgrub error that can occur is a `NoSolutionError`, and the
only place it can occur is `unit_propagation`, all other variants if
`PubGrubError` are unreachable. By changing the return type on pubgrub's
side (https://github.com/astral-sh/pubgrub/pull/28), we can remove the
pattern matching and the `unreachable!()` asserts on `PubGrubError`.

Our pubgrub error wrapper used to have a two phased initialization,
first mostly stubs in `solve[_tracked]()` and then adding the actual
context in `resolve()`. When constructing the error in `solve` we
already have all this context, so we can unify this to a regular
constructor and remove the special casing in `resolve()` and `hints()`.
2024-07-15 17:43:35 +02:00
konsti
00c055a6bd
Use correct pyproject.toml path in warnings (#5069)
One part of #5068. I think the other is not warning when the version is
dynamic, but this fix is needed either way.
2024-07-15 11:15:58 +00:00
renovate[bot]
cc0983a8db
Update Rust crate toml_edit to v0.22.15 (#5055) 2024-07-14 20:40:23 -04:00
renovate[bot]
865ba6db10
Update Rust crate tracing-tree to 0.4.0 (#5059) 2024-07-14 20:39:56 -04:00
renovate[bot]
97d2a7c567
Update Rust crate tikv-jemallocator to 0.6.0 (#5058) 2024-07-14 20:39:50 -04:00
renovate[bot]
4d14a1a371
Update Rust crate clap_complete_command to 0.6.0 (#5057) 2024-07-14 20:39:43 -04:00
renovate[bot]
51b75992b0
Update pre-commit dependencies (#5056) 2024-07-14 20:39:33 -04:00
renovate[bot]
d230323241
Update Rust crate thiserror to v1.0.62 (#5054) 2024-07-14 20:39:26 -04:00
renovate[bot]
27247029c9
Update Rust crate target-lexicon to v0.12.15 (#5053) 2024-07-14 20:39:21 -04:00
renovate[bot]
517487e2d0
Update Rust crate syn to v2.0.71 (#5052) 2024-07-14 20:39:15 -04:00
konsti
f3430c3a2a
Improve error message when package has no installation candidates (#5010)
Currently, with
```toml
[project]
name = "transformers"
version = "4.39.0.dev0"
requires-python = ">=3.10"
dependencies = [
  "torch==1.10.0"
]
```
i get
```
$ uv sync --preview
Resolved 3 packages in 7ms
error: found distribution torch==1.10.0 @ registry+https://pypi.org/simple with neither wheels nor source distribution
```
This error message is wrong, there are wheels, they are just not
compatible. I initially got this error message during `uv lock` (in a
build), so i also added that this is about installation, not about
locking.

We should reject this version immediately because with the current
requires python, it can never be installed, but even then we need to
change the error message because you can be on the correct python
version, but an unsupported platform.
2024-07-15 00:00:40 +00:00
Charlie Marsh
a571150949
Normalize out complementary == or != markers (#5050)
## Summary

Closes https://github.com/astral-sh/uv/issues/5044.
2024-07-14 23:53:58 +00:00
konsti
04c96c8df8
Remove non-existent feature (#5049)
Nightly rustc is complaining about this.
2024-07-14 19:49:22 -04:00
Di-Is
720ae195a1
Respect the libc of the execution environment with uv python list (#5036)
Fix #4988

## Summary

Running `uv python list` on glibc-based Linux will list musl pythons.

```bash
$ uv version
uv 0.2.24
$ uv python list
warning: `uv python list` is experimental and may change without warning.
cpython-3.12.3-linux-x86_64-musl     <download available>
cpython-3.12.3-linux-x86_64-gnu      /usr/bin/python3
cpython-3.12.3-linux-x86_64-gnu      /bin/python3
cpython-3.11.9-linux-x86_64-musl     <download available>
cpython-3.10.14-linux-x86_64-musl    <download available>
cpython-3.9.19-linux-x86_64-musl     <download available>
cpython-3.8.19-linux-x86_64-musl     <download available>
cpython-3.7.9-linux-x86_64-musl      <download available>
```

Change it to show Python matching the environment's libc as follows.

```bash
$ uv python list
warning: `uv python list` is experimental and may change without warning.
cpython-3.12.3-linux-x86_64-gnu     /usr/bin/python3
cpython-3.12.3-linux-x86_64-gnu     /bin/python3
cpython-3.12.3-linux-x86_64-gnu     <download available>
cpython-3.11.9-linux-x86_64-gnu     <download available>
cpython-3.10.14-linux-x86_64-gnu    <download available>
cpython-3.9.19-linux-x86_64-gnu     <download available>
cpython-3.8.19-linux-x86_64-gnu     <download available>
cpython-3.7.9-linux-x86_64-gnu      <download available>
```

Also, if --all-platforms is specified, change to list Python for all
architectures and libc.

```bash
$ uv python list --all-platforms
warning: `uv python list` is experimental and may change without warning.
cpython-3.12.3-windows-x86_64-none       <download available>
cpython-3.12.3-windows-x86-none          <download available>
cpython-3.12.3-macos-x86_64-none         <download available>
cpython-3.12.3-macos-aarch64-none        <download available>
cpython-3.12.3-linux-x86_64-musl         <download available>
cpython-3.12.3-linux-x86_64-gnu          /usr/bin/python3
cpython-3.12.3-linux-x86_64-gnu          /bin/python3
cpython-3.12.3-linux-x86_64-gnu          <download available>
cpython-3.12.3-linux-s390x-gnu           <download available>
cpython-3.12.3-linux-powerpc64le-gnu     <download available>
cpython-3.12.3-linux-armv7-gnueabihf     <download available>
cpython-3.12.3-linux-armv7-gnueabi       <download available>
cpython-3.12.3-linux-aarch64-gnu         <download available>
...
```

## Test Plan

The following commands were executed on the command line to confirm the
results in Ubuntu 24.04.
- `cargo run python list`
- `cargo run python list --all-platforms`
2024-07-14 11:14:57 -05:00
Charlie Marsh
afe35e787d
Update standalone Pythons to include 3.12.4 (#5042) 2024-07-14 01:51:47 +00:00
Charlie Marsh
a2edc33ead
Add a custom error message for --no-build-isolation torch dependencies (#5041)
## Summary

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

## Test Plan

```
❯ cargo run pip install torch torch-scatter --no-cache
⠼ torch-scatter==2.1.2                                                                                                    error: Failed to download and build `torch-scatter==2.1.2`
  Caused by: Failed to build: `torch-scatter==2.1.2`
  Caused by: Build backend failed to determine extra requires with `build_wheel()` with exit status: 1
--- stdout:

--- stderr:
Traceback (most recent call last):
  File "<string>", line 14, in <module>
  File "/private/var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpuxrhWj/builds-v0/.tmp1OBLbw/lib/python3.12/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=[])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpuxrhWj/builds-v0/.tmp1OBLbw/lib/python3.12/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires
    self.run_setup()
  File "/private/var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpuxrhWj/builds-v0/.tmp1OBLbw/lib/python3.12/site-packages/setuptools/build_meta.py", line 497, in run_setup
    super().run_setup(setup_script=setup_script)
  File "/private/var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpuxrhWj/builds-v0/.tmp1OBLbw/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup
    exec(code, locals())
  File "<string>", line 8, in <module>
ModuleNotFoundError: No module named 'torch'
---
  Caused by: This error likely indicates that torch-scatter==2.1.2 depends on torch, but doesn't declare it as a build dependency. If torch-scatter==2.1.2 is a first-party package, consider adding torch to its `build-system.requires`. Otherwise, `uv pip install torch` into the environment and re-run with `--no-build-isolation
```
2024-07-13 21:12:26 +00:00
Charlie Marsh
b5f0e0729e
Use versioned bages when uploading to PyPI (#5039) 2024-07-13 18:12:45 +00:00
Charlie Marsh
b629ab89c5
Set absolute URLs prior to uploading to PyPI (#5038)
## Summary

Closes https://github.com/astral-sh/uv/issues/5030.
2024-07-13 17:29:21 +00:00
skshetry
e8c16889f1
pip compile: exclude --upgrade-package when option and value are passed as a single argument (#5033)
This excludes `--upgrade-package` from `compile_command` when value and
option are passed as a single argument. Eg:

```console
--upgrade-package=package
-P=package
-Ppackage
```

I missed this on #5032.
Fixes #5031.

## Test Plan

Tested locally
2024-07-13 16:51:36 +00:00
Zanie Blue
9997dc0870
There are no rage requests here (#5037) 2024-07-13 15:35:51 +00:00
Jo
4bdcec9622
Fix Fedora system test (#5034)
Seems like the latest
[`fedora:41`](https://hub.docker.com/layers/library/fedora/rawhide/images/sha256-c037a87094660ceda037ee319b17f59559241d2a3580d1d0f414e72b0a8f3827?context=explore)
(pushed at Jul 12, 2024 at 22:05 UTC) docker image has removed the
`python3` package, causing our current [CI
failure](2740152817).
2024-07-13 10:25:03 -05:00
skshetry
f770b25be2
pip compile: exclude --upgrade-package from the header (#5032)
## Summary

Fixes #5031.

## Test Plan

Existing snapshot tests should cover it.
2024-07-12 23:24:35 -05:00
Charlie Marsh
4eb19c76bd
Add Windows path updates for uv tool (#5029)
## Summary

Largely based on rustup's implementation (linked in the source).

Closes #5027.

## Test Plan

- Changed the executable directory to `uv/foo`.
- Ran script; verified that I could access executables in `foo`.
2024-07-13 01:55:05 +00:00
Charlie Marsh
a61464e802
Move shell manipulation into its own crate (#5028)
## Summary

This is going to get a little more complex as we support Windows, so
carving it out.
2024-07-12 21:12:58 -04:00
Ibraheem Ahmed
ba217f1059
Use lockfile to prefill resolver index (#4495)
## Summary

Use the lockfile to prefill the `InMemoryIndex` used by the resolver.
This enables us to resolve completely from the lockfile without making
any network requests/builds if the requirements are unchanged. It also
means that if new requirements are added we can still avoid most I/O
during resolution, partially addressing
https://github.com/astral-sh/uv/issues/3925.

The main limitation of this PR is that resolution from the lockfile can
fail if new versions are requested that are not present in the lockfile,
in which case we have to perform a fresh resolution. Fixing this would
likely require lazy version/metadata requests by `VersionMap` (this is
different from the lazy parsing we do, the list of versions in a
`VersionMap` is currently immutable).

Resolves https://github.com/astral-sh/uv/issues/3892.

## Test Plan

Added a `deterministic!` macro that ensures that a resolve from the
lockfile and a clean resolve result in the same lockfile output for all
our current tests.
2024-07-12 18:49:28 -04:00
Charlie Marsh
df2ee8ad14
Improve rc file detection based on rustup (#5026)
## Summary

Brings in some learnings from `rustup`:
fede22fea7/src/cli/self_update/shell.rs (L197).

For example: we only need to write to `.zshenv` (but we have to respect
`ZDOTDIR`). Additionally, for Fish, we need to respect `XDG_CONFIG_HOME`
2024-07-12 22:40:31 +00:00
Charlie Marsh
a4cb21e081
Add a command to append uv's binary directory to PATH (#4975)
## Summary

I'll open follow-up tickets for Windows support.

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

## Test Plan

```
❯ cargo run tool install flask
Resolved 7 packages in 353ms
Prepared 7 packages in 392ms
Installed 7 packages in 17ms
 + blinker==1.8.2
 + click==8.1.7
 + flask==3.0.3
 + itsdangerous==2.2.0
 + jinja2==3.1.4
 + markupsafe==2.1.5
 + werkzeug==3.0.3
Installed 1 executable: flask
warning: /Users/crmarsh/.local/bin is not on your PATH. To use installed tools, run:
  export PATH="/Users/crmarsh/.local/bin:$PATH"
```

Then:

```
❯ which flask
flask not found
```

Then:

```
❯ cargo run tool ensurepath
warning: `uv tool ensurepath` is experimental and may change without warning.
Updated configuration file: /Users/crmarsh/workspace/puffin/bar
Restart your shell for the changes to take effect.
```

Then:
```
❯ which flask
/Users/crmarsh/.local/bin/flask
```
2024-07-12 22:09:34 +00:00
Ibraheem Ahmed
a4e9b63d5b
Fix benchmarks CI job (#5023) 2024-07-12 17:57:12 -04:00
Charlie Marsh
5f851d1d19
Warn when unused pyproject.toml configuration is detected (#5025)
## Summary

Closes https://github.com/astral-sh/uv/issues/5022.
2024-07-12 17:50:04 -04:00
Charlie Marsh
6a6168ec78
Update SchemaStore script (#5024)
## Summary

Small mistakes I noticed while running.

## Test Plan

`python scripts/update_schemastore.py`
2024-07-12 17:49:38 -04:00
Ahmed Ilyas
26d8879c3a
uv tool run error messages references uvx when appropriate (#5014)
## Summary

Resolves #5013. 

## Test Plan

```console
❯ ./target/debug/uv tool run fastapi-cli
warning: `uv tool run` is experimental and may change without warning.
Resolved 9 packages in 28ms
The executable fastapi-cli was not found.
However, the following executables are available via uv tool run --from fastapi-cli <EXECUTABLE>:
- fastapi
```

```console
❯ ./target/debug/uvx fastapi-cli
warning: `uvx` is experimental and may change without warning.
Resolved 9 packages in 23ms
The executable fastapi-cli was not found.
However, the following executables are available via uvx --from fastapi-cli <EXECUTABLE>:
- fastapi
```

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-07-12 17:17:26 +00:00
Silvano Cerza
2ccb7ed305
Add --no-pager option in help command (#5007)
## Summary

Fixes #4941.

This PR adds a `--no-pager` option in `help` command to explicitly
disable the pager.

I noted that the template used for the text printed when calling `help`
with no argument or option doesn't show any option. It made sense before
this PR since `help` didn't have any available option. Though I'm unsure
if it makes sense to update the template as it would make it extremely
verbose as all the global options would be shown too.

I leave the decision to you.

## Test Plan

I ran `cargo run -- help` to verify `--isolated` was visible and it.
I ran clippy with `cargo clippy --workspace --all-targets --all-features
--locked -- -D warnings` as CI does.

I also ran tests locally with:
```
cargo nextest run \
            --features python-patch \
            --workspace \
            --status-level skip --failure-output immediate-final --no-fail-fast -j 12 --final-status-level slow
```
2024-07-12 11:11:50 -05:00
Silvano Cerza
2a50bc94ca
Fix CONTRIBUTING.md instructions to install multiple Python versions (#5015)
## Summary

I noticed the command to install multiple Python versions was wrong as
it was failing cause `toolchain` is not a known command.

I looked in the `ci.yml` workflow to see which command is used there and
updated the instructions accordingly.

## Test Plan

I just ran the command locally. :)
2024-07-12 11:00:38 -05:00
Ibraheem Ahmed
a1f71a36e7
Fix substring marker expression disjointness checks (#4998)
## Summary

Noticed a bug here, `'a' in env` and `env not in 'a'` are not disjoint
given `env == 'ab'`.
2024-07-12 15:21:21 +00:00
Andrew Gallant
abdb58d2df uv: fix doc test
[Doc tests can't use crate internal APIs unfortunately.][internal-doc]
I really want them to be able to, but for now, mark such tests as
`ignore`.

I was motivated to do this because it otherwise breaks `cargo t --all`
for me.

[internal-doc]: https://github.com/rust-lang/rust/issues/50784
2024-07-12 07:57:29 -07:00
Silvano Cerza
663c190c2d
Unhide --isolated global argument (#5005)
## Summary

This PR makes the `--isolated` global argument visible, previously it
was hidden.
Fixes #4981.

## Test Plan

I ran `cargo run -- help` to verify `--isolated` was visible and it is.
I ran clippy with `cargo clippy --workspace --all-targets --all-features
--locked -- -D warnings` as CI does.

I also ran tests locally with:
```
cargo nextest run \
            --features python-patch \
            --workspace \
            --status-level skip --failure-output immediate-final --no-fail-fast -j 12 --final-status-level slow
```
2024-07-12 09:34:00 -05:00
Andrew Gallant
8d6c49b36c pep508: add MarkerTree::negate
It does what you think it does, for the most part.
2024-07-12 04:37:36 -07:00
Andrew Gallant
da8a4a6faa pep508: write x.y.* when serializing MarkerExpression
It's unclear to me whether this was intentional or not, but
I realized that converting a MarkerExpression to a string
treated EqualStar and NotEqualStar as Equal and NotEqual,
respectively. I tweaked this to match the Display impl for
VersionSpecifier.

(Negation tests in the next commit cover this change.)
2024-07-12 04:37:36 -07:00
Ahmed Ilyas
23c6cd774b
uv tool run suggest valid commands when command is not found (#4997)
## Summary

Resolves #4979.


## Test Plan

`cargo test`

<img width="619" alt="Screenshot 2024-07-11 at 22 45 36"
src="https://github.com/user-attachments/assets/62526010-9123-43f5-9f8d-1f9e89f6be59">

<img width="636" alt="Screenshot 2024-07-11 at 22 45 23"
src="https://github.com/user-attachments/assets/a348cd73-f891-40b1-8934-afbd1aa19326">
2024-07-12 02:26:15 +00:00
Charlie Marsh
6949796110
Allow URL dependencies in tool run --from (#5002)
## Summary

Converting to a lock requires that we generate hashes; but generating
hashes isn't required here. So let's just use a different representation
for the cache key.

Closes https://github.com/astral-sh/uv/issues/4990.
2024-07-12 01:31:07 +00:00
Caíque Porfirio
9643fb99d1
Rename python install --force parameter to --reinstall (#4999)
## Summary

Rename the `--force` parameter of `uv python install` to `--reinstall`.

Closes #4961.
2024-07-12 01:06:54 +00:00
Charlie Marsh
c345484c93
Fall back to streaming wheel when Content-Length header is absent (#5000)
## Summary

Closes https://github.com/astral-sh/uv/issues/4993
2024-07-12 01:04:21 +00:00
Charlie Marsh
55b41d7d3d
Lock directories to synchronize wheel-install copies (#4978)
## Summary

Closes https://github.com/astral-sh/uv/issues/4831.
2024-07-12 00:53:20 +00:00
Billy Doyle
22cca77329
Exit with zero when uv tool install request is already satisfied (#4986)
## Summary

`uv tool install X` fails for tools already installed and exits with
code 1. Allow already installed tools to exit with code 0.
2024-07-11 20:43:31 -04:00
Zanie Blue
42cb2541b5
Remove extra "project" docs files (#4977) 2024-07-10 17:38:13 -05:00
Charlie Marsh
9307928765
Improve missing wheel error message with --no-build-isolation (#4964)
Closes https://github.com/astral-sh/uv/issues/4069.
2024-07-10 21:10:20 +00:00
Zanie Blue
527b711bc7
Bump version to 0.2.24 (#4974) 2024-07-10 13:50:12 -05:00
Zanie Blue
c14de2a92a
Allow uv crate to be used as a library (#4642)
This is pulled out of #4632 — a user noted that it would be useful to
use the `uv` crate from Rust. This makes it way easier to invoke `uv`
from Rust with arbitrary arguments as well as use various functionality
in the `uv` crate.

Note this is no longer needed for #4632 and is not particularly urgent.
2024-07-10 17:15:54 +00:00
Zanie Blue
e0fae8e6f4
Add uv python pin (#4950)
Adds a `uv python pin` command to write to a `.python-version` file.

We support all of our Python version request formats. We also support a
`--resolved` flag to pin to a specific interpreter instead of the
provided version. We canonicalize the request with #4949, it's not just
printed verbatim. We always attempt to find the interpreter so we can
warn if it's not available. With `--resolved`, if we can't find the
interpreter we fail. If no arguments are provided, we'll attempt to
display the current pin.

In the future:

- We should confirm that this satisfies the `Requires-Python` metadata
if a `pyproject.toml` is present
- We should support writing to a `uv.python-version` field if
`pyproject.toml` or `uv.toml` are present
- We should support finding and updating the "nearest" Python version
file (looking in ancestors)
- We should support finding version files in workspaces
- We should support some sort of global pin
2024-07-10 16:52:24 +00:00
Charlie Marsh
7925d255f7
Add manylinux_2_31 to supported --python-platform (#4965)
## Summary

I'll make an issue for arbitrary `manylinux_x_y` support.

Closes https://github.com/astral-sh/uv/issues/4956.
2024-07-10 16:30:35 +00:00