Commit graph

2162 commits

Author SHA1 Message Date
Charlie Marsh
7c6632114b
Improve JSON Schema and add export script (#3461)
## Summary

A few errors I noticed after generating the schema.
2024-05-08 16:15:16 +00:00
Charlie Marsh
18d229e2bb
Upgrade async_http_range_reader to v0.8.0 (#3460)
## Summary

Closes #2025.
Closes https://github.com/astral-sh/uv/issues/3255.
Closes https://github.com/astral-sh/uv/pull/2843.
2024-05-08 10:54:08 -04:00
Charlie Marsh
76a3ceb2ca
Add basic uv sync and uv lock commands (#3436)
## Summary

These aren't intended for production use; instead, I'm just trying to
frame out the overall data flows and code-sharing for these commands. We
now have `uv sync` (sync the environment to match the lockfile, without
refreshing or resolving) and `uv lock` (generate the lockfile). Both
_require_ a virtual environment to exist (something we should change).
`uv sync`, `uv run`, and `uv lock` all share code for the underlying
subroutines (resolution and installation), so the commands themselves
are relatively small (~100 lines) and mostly consist of reading
arguments and such.

`uv lock` and `uv sync` don't actually really work yet, because we have
no way to include the project itself in the lockfile (that's a TODO in
the lockfile implementation).

Closes https://github.com/astral-sh/uv/issues/3432.
2024-05-08 14:51:51 +00:00
konsti
0228b15baf
Improve trailing version string error message (#3453)
We would previously show the parsed version when erroring due to
trailing content after a valid version, which can look different than
the input. E.g. when encountering `0.1-bulbasaur`, we would display:

```
after parsing '0.1b0', found 'ulbasaur', which is not part of a valid version
```

With storing the input string instead of the input version, we now show:

```
after parsing '0.1-b', found 'ulbasaur', which is not part of a valid version
```
2024-05-08 14:50:29 +02:00
Shantanu
5a07923eb4
Use Metadata10 to parse PKG-INFO of legacy editable (#3450)
It turns out setuptools often uses Metadata-Version 2.1 in their
PKG-INFO:
4e766834d7/setuptools/dist.py (L64)
`Metadata23` requires Metadata-Version of at least 2.2.

This means that uv doesn't actually recognise legacy editable
installations from the most common way you'd actually get legacy
editable installations (works great for most legacy editables I make at
work though!)

Anyway, over here we only need the version and don't care about anything
else. Rather than make a `Metadata21`, I just add a version field to
`Metadata10`. The one slightly tricky thing is that only
Metadata-Version 1.2 and greater guarantee that the [version number is
PEP 440 compatible](https://peps.python.org/pep-0345/#version), so I
store the version in `Metadata10` as a `String` and only parse to
`Version` at time of use.

Also did you know that back in 2004, paramiko had a pokemon based
versioning system?
2024-05-08 10:58:18 +02:00
Shantanu
962fde29b2
Apply normcase to line from easy-install.pth (#3451)
Thanks for the suggestion from
https://github.com/astral-sh/uv/pull/3415#discussion_r1591772942

Also it looks like you improved `egg-link` parsing in
e23c91f52e
so copying the changes over to the other parse site (happy to move this
to a helper too, if so lmk where to put it)
2024-05-08 10:40:21 +02:00
konsti
1ad6aa8a23
Use generic pubgrub incompatibility reason (#3335)
Pubgrub got a new feature where all unavailability is a custom, instead
of the reasonless `UnavailableDependencies` and our custom `String` type
previously (https://github.com/pubgrub-rs/pubgrub/pull/208). This PR
introduces a `UnavailableReason` that tracks either an entire version
being unusable, or a specific version. The error messages now also track
this difference properly.

The pubgrub commit is our main rebased onto the merged
https://github.com/pubgrub-rs/pubgrub/pull/208, i'll push
`konsti/main-rebase-generic-reason` to `main` after checking for rebase
problems.
2024-05-08 08:40:15 +00:00
Charlie Marsh
bd7860de17
Remove some allow(unused) (#3448) 2024-05-07 22:19:07 -04:00
Charlie Marsh
b0d7a26431
Bump version to v0.1.41 (#3446) 2024-05-08 01:05:47 +00:00
Charlie Marsh
49937a386d
Remove unconstrained version error from requirements (#3443)
## Summary

It's not clear to me that this should exist at all, but it's causing
errors in projects that don't use `tool.uv.sources`, so we should
definitely remove it for now.
2024-05-07 20:04:44 -04:00
DaniPopes
c59cb1381a
Use into_par_iter instead of par_bridge (#3435)
## Summary

Use the native rayon range iterator instead of bridging the standard
library's.
2024-05-07 19:38:35 +00:00
Charlie Marsh
d665410d59
Move PyO3 derive down (#3434)
## Summary

For some reason the current order is breaking the IntelliJ LSP.
2024-05-07 18:16:28 +00:00
Charlie Marsh
e8b423de77
Use top-level --isolated for uv run (#3431)
## Summary

We already have a global `--isolated`, which means "ignore any on-disk
configuration". I think we should reuse this for the "ignore the
workspace" setting in `uv run`, rather than `--no-workspace`.

I've also merged the existing `--isolated` and `--no-workspace`
behaviors in `uv run` into a single flag. We may not need separate flags
for this, since the current intent seems to be "ignore the workspace
environment"? Though we could always re-add later.

Closes https://github.com/astral-sh/uv/issues/3421.
2024-05-07 13:30:02 -04:00
Charlie Marsh
7fe9f0a3dd
Bump version to v0.1.40 (#3433) 2024-05-07 17:29:29 +00:00
Charlie Marsh
f8a7813add
Rename --force to --allow-existing (#3416)
## Summary

We've found `--force` to be a confusing name here. (Not breaking as this
hasn't shipped in a release.)
2024-05-07 17:11:31 +00:00
konsti
f8901e9989
Always activate non-pep508-extensions (#3428)
Avoid compilation errors when running partial tests due to that feature
being missing.
2024-05-07 16:13:09 +00:00
Alex Waygood
3830e90770
Tell renovate not to try to update GitHub runners (#3427) 2024-05-07 16:09:21 +00:00
Ahmed Ilyas
388dba4815
add compat arg --user error message to pip install (#3424)
Resolves [#3419](https://github.com/astral-sh/uv/issues/3419)

## Summary

Add compatargs to pip install command and hint the user to create a venv
for --user arg.

## Test Plan

Tested it locally.

```bash
cargo run pip install --user flask
   Compiling uv v0.1.39 (/home/ahmedilyas/uv/crates/uv)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 8.96s
     Running `target/debug/uv pip install --user flask`
error: pip install's `--user` is unsupported (use a virtual environment instead).
```
2024-05-07 14:59:53 +00:00
konsti
55f6e4e66b
Make Requirement generic over url type (#3253)
This change allows switching out the url type for requirements. The
original idea was to allow different types for different requirement
origins, so that core metadata reads can ban non-pep 508 requirements
while we only allow them for requirements.txt. This didn't work out
because we expect `&Requirement`s from all sources to match.

I also tried to split `pep508_rs` into a PEP 508 compliant crate and
into our extensions, but they are to tightly coupled.

I think this change is an improvement still as it reduces the hardcoded
dependence on `VerbatimUrl`.
2024-05-07 16:45:49 +02:00
Zanie Blue
8e86cd0c73
Add hint to use a venv to pip sync --user (#3418) 2024-05-07 08:50:23 -05:00
konsti
24f38d7c22
Preserve given for tool.uv.sources paths (#3412)
We now correctly emit relative paths in `uv pip compile` with
`tool.uv.sources` path inputs.

`tool.uv.sources` is mainly intended to be used with the uv lock file
over requirements.txt, but it's good to have basic `uv pip` support
working.

Fixes #3366
2024-05-07 09:00:02 +00:00
Shantanu
18516b4e41
List and uninstall legacy editables (#3415) 2024-05-07 03:51:50 +00:00
Ibraheem Ahmed
94cf604574
Remove unnecessary uses of DashMap and Arc (#3413)
## Summary

All of the resolver code is run on the main thread, so a lot of the
`Send` bounds and uses of `DashMap` and `Arc` are unnecessary. We could
also switch to using single-threaded versions of `Mutex` and `Notify` in
some places, but there isn't really a crate that provides those I would
be comfortable with using.

The `Arc` in `OnceMap` can't easily be removed because of the uv-auth
code which uses the
[reqwest-middleware](https://docs.rs/reqwest-middleware/latest/reqwest_middleware/trait.Middleware.html)
crate, that seems to adds unnecessary `Send` bounds because of
`async-trait`. We could duplicate the code and create a `OnceMapLocal`
variant, but I don't feel that's worth it.
2024-05-06 22:30:43 -04:00
konsti
2c84af15b8
Rename distribution_types::VersionOrUrl to VersionOrUrlRef (#3254)
This is more consistent with the other `*Ref` types and reduces
confusion with the real `VersionOrUrl` type.
2024-05-06 14:15:56 -04:00
Charlie Marsh
e9490b92b5
Upgrade cargo-dist to v0.14.0 (#3414) 2024-05-06 13:48:41 -04:00
Charlie Marsh
ed27dde8a2
Revise comment on virtualenv discovery from cwd (#3406)
See:
37d229b2c2..cd53a28181 (r1590746360)
2024-05-06 14:07:11 +00:00
Charlie Marsh
26045e5f59
Respect and enable uninstalls of existing .egg-info packages (#3380)
## Summary

Users often find themselves dropped into environments that contain
`.egg-info` packages. While we won't support installing these, it's not
hard to support identifying them (e.g., in `pip freeze`) and
_uninstalling_ them.

Closes https://github.com/astral-sh/uv/issues/2841.
Closes #2928.
Closes #3341.

## Test Plan

Ran `cargo run pip freeze --python
/opt/homebrew/Caskroom/miniforge/base/envs/TEST/bin/python`, with an
environment that includes `pip` as an `.egg-info`
(`/opt/homebrew/Caskroom/miniforge/base/envs/TEST/lib/python3.12/site-packages/pip-24.0-py3.12.egg-info`):

```
cffi @ file:///Users/runner/miniforge3/conda-bld/cffi_1696001825047/work
pip==24.0
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1711811537435/work
setuptools==69.5.1
wheel==0.43.0
```

Then ran `cargo run pip uninstall`, verified that `pip` was uninstalled,
and no longer listed in `pip freeze`.
2024-05-06 09:47:28 -04:00
konsti
098944fc7d
Improve non-git error message (#3403)
The boxing changes are due to clippy
2024-05-06 13:28:05 +02:00
konsti
d0c3146ef6
Restore verbatim in error message (#3402)
Fixup for
https://github.com/astral-sh/uv/pull/3263#discussion_r1589718035
2024-05-06 11:17:06 +00:00
konsti
b2f6b92e3b
Move pep508-rs Cursor into its own module (#3401) 2024-05-06 10:13:27 +00:00
Shantanu
95f31f2266
Better error for unsupported Python version (#3398)
Fixes #3371

It seems like uv doesn't proactively enforce 3.8+ and in most cases just
issues a warning. This PR keeps that property, only adding the new check
when it is known to fail. I checked the imports in this file and the
other ones seem fine.
2024-05-06 11:12:36 +02:00
konsti
9de49c8a60
Make pubgrub an allowed ident (#3399)
Followup to #3361, fix some backtick-quoting.
2024-05-06 09:10:37 +00:00
renovate[bot]
1efaf3fd31
Update Rust crate junction to v1.1.0 (#3393) 2024-05-06 02:41:15 +00:00
renovate[bot]
aec9573d42
Update Rust crate mailparse to 0.15.0 (#3394) 2024-05-06 02:29:55 +00:00
renovate[bot]
c125ce394a
Update Rust crate rmp-serde to v1.3.0 (#3395) 2024-05-06 02:29:24 +00:00
renovate[bot]
c1370cab1b
Update pre-commit dependencies (#3391) 2024-05-06 02:18:51 +00:00
renovate[bot]
5a8d13a05a
Update Rust crate axoupdater to 0.6.0 (#3392) 2024-05-06 02:12:42 +00:00
renovate[bot]
1cf07ebf08
Update Rust crate zip to v1.1.4 (#3390) 2024-05-06 02:12:21 +00:00
renovate[bot]
409f38c7f5
Update Rust crate tokio-util to v0.7.11 (#3389) 2024-05-06 02:09:04 +00:00
renovate[bot]
cce8e0dd7d
Update Rust crate test-log to v0.2.16 (#3388) 2024-05-06 02:06:27 +00:00
renovate[bot]
c06266874e
Update Rust crate serde to v1.0.200 (#3387) 2024-05-06 02:04:30 +00:00
renovate[bot]
e6efe48d52
Update Rust crate cargo-util to v0.2.11 (#3386) 2024-05-06 02:02:11 +00:00
renovate[bot]
0042533dc3
Update Rust crate base64 to v0.22.1 (#3385) 2024-05-06 02:01:09 +00:00
renovate[bot]
a9756872e6
Update Rust crate anstream to v0.6.14 (#3384) 2024-05-06 02:00:17 +00:00
Charlie Marsh
7e17dd10a3
Add UV_CUSTOM_COMPILE_COMMAND to environment variable docs (#3382)
Closes https://github.com/astral-sh/uv/issues/3381.
2024-05-05 23:33:27 +00:00
Godefroid Chapelle
ef92c38486
Detect current venv when uv is invoked from within a virtualenv (#3379)
Fixes #3378.
2024-05-05 22:53:25 +00:00
Charlie Marsh
6d73db2b1e
Use Cow for source call (#3377) 2024-05-05 02:21:24 +00:00
Charlie Marsh
37635fda56
Update activation scripts from virtualenv (#3376)
## Summary

Refreshes some of the activation scripts, and fixes some bugs in
`activate_this.py` that were likely the rest of some erroneous
copy-pasting.

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

## Test Plan

```
❯ python
Python 3.12.0 (main, Feb 28 2024, 09:44:16) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import httpx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'httpx'
>>> activator = '.venv/bin/activate_this.py'
>>> with open(activator) as f:
...     exec(f.read(), {'__file__': activator})
...
>>> import httpx
```
2024-05-04 23:30:00 +00:00
Charlie Marsh
2a212eb6a9
Add branch and tag variants to Git reference (#3374)
## Summary

Closes https://github.com/astral-sh/uv/issues/3368.
2024-05-04 21:13:11 +00:00
Charlie Marsh
69e99b3502
Use canonical URLs in satisfaction check (#3373)
## Summary

Closes https://github.com/astral-sh/uv/issues/3367.
2024-05-04 12:44:25 +00:00