Commit graph

1529 commits

Author SHA1 Message Date
Ahmed Ilyas
a3b61a2644
add UV_LINK_MODE as env variable (#3315)
Resolves https://github.com/astral-sh/uv/issues/3313

## Summary

Add a new env variable `UV_LINK_MODE` as alias for the cli argument
--link-mode.
Updated the README env variables section.

## Test Plan

Tested manually using `UV_LINK_MODE=hardlink cargo run -p uv pip install
flask`.
2024-04-29 17:29:36 +00:00
konsti
cedb8259f7
Avoid panic for file url (#3306)
When using find links with a file url, we shouldn't panic because we
can't remove username/password for a host-less url.

See #3262
2024-04-29 16:39:16 +02:00
konsti
1344cfae4b
Use fs_err for cachedir errors (#3304)
When running

```
set UV_CACHE_DIR=%LOCALAPPDATA%\uv\cache-foo && uv venv venv
```

in windows CMD, the error would be just

```
error: The system cannot find the path specified. (os error 3)
```

The problem is that the first action in the cache dir is adding the tag,
and the `cachedir` crate is using `std::fs` instead of `fs_err`. I've
copied the two functions we use from the crate and changed the import
from `std::fs` to `fs_err`.

The new error is

```
error: failed to open file `C:\Users\Konstantin\AppData\Local\uv\cache-foo \CACHEDIR.TAG`
  Caused by: The system cannot find the path specified. (os error 3)
```

which correctly explains the problem.

Closes #3280
2024-04-29 16:33:10 +02:00
konsti
f63a1fde42
Fix span recording with install_wheel_rs (#3293)
We would only record spans for `uv` prefixed crates, while the rayon
operations are in `install_wheel_rs`, therefore "disappearing" spans
from rayon.

With these changes, we can profile the parallel installation:


![jupyter](bb3c626a-ba9a-443d-9727-ac1e3bf14a71)
2024-04-28 18:33:40 +00:00
Charlie Marsh
eabefbf8a2
Ignore 401 errors with multiple indexes (#3292)
## Summary

It seems like Azure might return a 401 when you request a package that
doesn't exist (even with valid credentials)? But I admittedly haven't
tested this. (We already skip 403, and this seems similar?)

Closes https://github.com/astral-sh/uv/issues/3291.
2024-04-28 10:06:43 -04:00
Charlie Marsh
42a44dcfff
Fix serialization of index URLs (#3289)
Closes https://github.com/astral-sh/uv/issues/3288.
2024-04-27 12:52:06 +00:00
Charlie Marsh
028b407411
Bump version to v0.1.39 (#3286) 2024-04-27 07:18:16 -04:00
Charlie Marsh
da89e53090
Fix documentation on --cache-dir CLI (#3285)
## Summary

This looks like a copy-paste error.
2024-04-27 02:28:00 +00:00
Yorick
43181f1933
Implement --index-strategy unsafe-best-match (#3138)
## Summary

This index strategy resolves every package to the latest possible
version across indexes. If a version is in multiple indexes, the first
available index is selected.

Implements #3137 

This closely matches pip.

## Test Plan

Good question. I'm hesitant to use my certifi example here, since that
would inevitably break when torch removes this package. Please comment!
2024-04-27 01:24:54 +00:00
Charlie Marsh
a0e7d9fe87
Add a --isolated mode to ignore on-disk configuration (#3283)
## Summary

We have the same thing in Ruff. Really useful.
2024-04-26 23:33:34 +00:00
Charlie Marsh
845dc3d8d9
Add debug logging for --target (#3282) 2024-04-26 23:31:19 +00:00
Charlie Marsh
ad99e3af63
Create --target directories lazily (#3274)
## Summary

Based on feedback in
https://github.com/astral-sh/uv/pull/3257#issuecomment-2078560574.
2024-04-26 03:36:56 +00:00
Charlie Marsh
1a4f7de831
Revise compile_index_url_fallback_prefer_primary (#3273)
## Summary

Closes https://github.com/astral-sh/uv/issues/3238.
2024-04-25 23:30:44 +00:00
Charlie Marsh
ed8f6e4556
Add --target support to sync and install (#3257)
## Summary

The approach taken here is to model `--target` as an install scheme in
which all the directories are just subdirectories of the `--target`.
From there, everything else... just works? Like, upgrade, uninstalls,
editables, etc. all "just work".

Closes #1517.
2024-04-25 19:15:39 -04:00
Grzegorz Bokota
fab8d858b6
fix platform_machine for macos arm (#3267)
## Summary

based on PEP 508 the `platform_machine` should be same as
`platform.machine()` output:
https://peps.python.org/pep-0508/#environment-markers

From my macOS M2 

```python
In [1]: import platform

In [2]: platform.machine()
Out[2]: 'arm64'
```

I napari we also use `arm64` in requirements and it works as expected: 

9fcf63e69a/pyproject.toml (L120)

## Test Plan

<!-- How was it tested? -->
2024-04-25 18:16:52 +00:00
Charlie Marsh
413859768d
Replace Twisted with an empty bz2 package (#3258)
## Summary

This is just an empty package taken from packse, rezipped with `tar -cjf
bz2-1.0.0.tar.bz2 bz2-1.0.0`.
2024-04-25 03:45:23 +00:00
Zanie Blue
3b6e16bb0e
Fix uv-toolchain requirement on pep508_rs (#3256) 2024-04-24 19:10:47 -04:00
Zanie Blue
0b23caa18d
Bump version to 0.1.38 (#3251) 2024-04-24 13:28:50 -05:00
Zanie Blue
c22e15f07d
Warn when an unsupported Python version is encountered (#3250)
I rebased https://github.com/astral-sh/uv/pull/2757 then realized that
we want to implement this for more than `uv venv`.

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

```
❯ cargo run -q -- pip install -p /Users/mz/bin/python3.7 anyio
warning: uv is only compatible with Python 3.8+, found Python 3.7.17.
Audited 1 package in 84ms

❯ cargo run -q -- venv -p /Users/mz/bin/python3.7
warning: uv is only compatible with Python 3.8+, found Python 3.7.17.
Using Python 3.7.17 interpreter at: /Users/mz/bin/python3.7
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate
```

---------

Co-authored-by: Stevie Gayet <stegayet@users.noreply.github.com>
2024-04-24 17:51:57 +00:00
Ibraheem Ahmed
20e9589662
Combine dependency clauses with the same root (#3225)
## Summary

Simplifies dependency errors of the form `you require package-a and you
require package-b` to `you require package-a and package-b`. Resolves
https://github.com/astral-sh/uv/issues/1009.
2024-04-24 12:34:32 -04:00
Zanie Blue
eb27d742b9
Add --python support to uv run (#3189) 2024-04-24 16:03:50 +00:00
konsti
005b76770e
Update BUILD_VENDOR_LINKS_URL from packse version (#3246)
Make `generate.py` update the packse version used in
`BUILD_VENDOR_LINKS_URL`.

Closes #3245
2024-04-24 17:54:38 +02:00
Zanie Blue
691b7d26a0
Upgrade packse to 0.3.15 (#3244)
Includes https://github.com/astral-sh/packse/pull/179 for #3225

```
uv pip compile scripts/scenarios/requirements.in -o scripts/scenarios/requirements.txt --refresh-package packse --upgrade
cargo dev fetch-python
source .env
./scripts/sync_scenarios.sh
```
2024-04-24 10:54:03 -05:00
Zanie Blue
84bb6e1976
Remove KeyringProvider.cache (#3243)
This is handled by `CredentialsCache.fetches` instead since #3237 

Moves the test demonstrating the flaw in the cache to the middleware
level.
2024-04-24 15:39:24 +00:00
Zanie Blue
a5abb8eb1e
Add keyring logs for URL and host fetches (#3212)
So we can identify when we need to fall back to the host.
2024-04-24 10:32:17 -05:00
Zanie Blue
a07adf72de
Use read-write locks instead of mutexes in authentication handling (#3210)
- Use `RwLock` for `KeyringProvider` cache
- Use `RwLock` for `CredentialsCache`
2024-04-24 10:17:16 -05:00
Andrew Gallant
0b84eb0140
once-map: avoid hard-coding Arc (#3242)
The only thing a `OnceMap` really needs to be able to do with the value
is to clone it. All extant uses benefited from having this done for them
by automatically wrapping values in an `Arc`. But this isn't necessarily
true for all things. For example, a value might have an `Arc` internally
to making cloning cheap in other contexts, and it doesn't make sense to
re-wrap it in an `Arc` just to use it with a `OnceMap`. Or
alternatively, cloning might just be cheap enough on its own that an
`Arc` isn't worth it.
2024-04-24 11:11:46 -04:00
Andrew Gallant
67d8805ca8
uv-toolchain: use colocated temporary directory (#3240)
Previously, this would use the "system" temporary directory.
Because we rename the resulting directory to its final destination,
and because renaming is implemented via hardlinking, and because
hardlinking doesn't work across mount points, and because /tmp is
commonly on a different mount point than where `uv` is checked out,
we "fix" this by putting the temporary directory somewhere close to
the final destination of the fetched artifact.

There are alternatives we might consider pursuing. For example,
if the `rename` fails, then we should probably do a recursive
directory copy. But this is a quick fix for now and it also
consistent with colocation of other temporary directories in `uv`.

The main downside of this change is that if a user does ^C while
`uv-dev fetch-python` is running, then there is no mechanism for
cleaning up temporary directories.
2024-04-24 10:56:03 -04:00
Zanie Blue
e92b38cfb9
Only perform fetches of credentials for a realm once (#3237)
Closes https://github.com/astral-sh/uv/issues/3205

Tested with

`RUST_LOG=uv=trace cargo run -- pip install -r
scripts/requirements/trio.in --index-url
https://oauth2accesstoken@us-central1-python.pkg.dev/zb-test-project-421213/pypyi/simple/
--no-cache --keyring-provider subprocess -vv --reinstall 2>&1 | grep
keyring`

On `main` you can see a dozen keyring attempts at once. Here, the other
requests wait for the first attempt and only a single keyring call is
performed.
2024-04-24 09:53:44 -05:00
Charlie Marsh
116d47ed03
Add alternate manylinux targets to --python-platform (#3229)
## Summary

I initially implemented this by allowing arbitrary
`x86_64-manylinux_x_y`, but it makes the Clap, Serde, and Schemars
definitions more complicated, _and_ makes it harder for the user.
Ultimately, manylinux itself only provides images for 2_17 and 2_28, so
this seems like it should be sufficient.

Closes https://github.com/astral-sh/uv/issues/3222.
2024-04-24 07:53:25 -04:00
Charlie Marsh
84989a3f49
Unroll self-dependencies via extras (#3230)
## Summary

We now recursively expand any self-dependencies via extras, which lets
us detect conflicts sooner and avoid building unnecessary versions of
packages that are excluded via the extra.

Closes https://github.com/astral-sh/uv/issues/3135.
2024-04-24 07:51:56 -04:00
konsti
3783292c43
Remove unused dependencies (#3236)
`cargo shear --fix` and some manual fixing for tokio and flate2.

I wanted to prepare my branch and realized main also needs this.
2024-04-24 11:18:24 +00:00
konsti
a653670d04
Move RequirementsTxtRequirement to its own module (#3235)
Small refactoring, no functional changes.
2024-04-24 11:16:10 +00:00
konsti
bed730571d
Fix single crate tokio features (#3234)
Previously, uv-auth would fail to compile due to a missing process
feature. I chose to make all tokio features we use top level features,
so we can share the tokio cache between all test invocations.
2024-04-24 08:55:15 +00:00
Charlie Marsh
8b711d2e4d
Avoid adding extras when expanding constraints (#3232)
## Summary

See the diff in the tests. If you have a constraint with an extra, we
should respect it, but we shouldn't _add_ the extra to the requirements.
2024-04-24 02:00:27 +00:00
Charlie Marsh
c7d7b07408
Add test for extra-in-constraint (#3231)
## Summary

We have the wrong behavior here, so starting by adding a test for it.
2024-04-23 21:52:41 -04:00
Charlie Marsh
084408b88f
Upgrade macOS target to 12.0 (#3228)
## Summary

macOS 11 has been EOL for 7 months, and it seems like it's common to
publish ARM-only wheels at 12.0+. I think this is a better default for
ARM macs.

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

## Test Plan

`cargo run pip install scikit-learn==1.3.2 --python-platform macos
--no-build`
2024-04-23 23:28:14 +00:00
Michael Ritsema
936facfb08
Gave a better name to the --color placeholder (#3226)
## Summary

The cli gives <COLOR> as value placeholder which is misleading. I
changed this to <COLOR_CHOICE> to make it obvious you don't supply a
color but a ColorChoice value.

## Test Plan

Compiled and verified --help text was correct
2024-04-23 18:13:17 -04:00
samypr100
308f95fce1
chore: use uv-version in uv-virtualenv (#3221)
## Summary

This is mainly a cleanup PR to leverage uv-version in uv-virtualenv
instead of passing it via `uv`.
In #1852 I introduced the ability to pass extra cfg to `gourgeist` for
the primary purpose of passing the uv version, but since the dawn of the
uv-version crate dynamically passing more values to pyvenv.cfg is no
longer needed.

## Test Plan

Existing `uv` tests should still verify `uv = <version>` exists in the
venv and make sure no regressions were introduced.
2024-04-23 16:18:40 -04:00
Charlie Marsh
697d821343
Reinstall package when editable label is removed (#3219)
## Summary

Closes https://github.com/astral-sh/uv/issues/3200.
2024-04-23 19:03:44 +00:00
haarisr
1c2a7f6a85
Use directory instead of file when searching for uv.toml file (#3203)
## Summary

The function `find_in_directory` joins `uv.toml`. The initial join in
`user` is redundant.

Also a small comment fix.

## Test Plan

Not really sure how to test this. Please suggest if any tests need to be
added.
2024-04-23 14:36:38 -04:00
Ibraheem Ahmed
fa53de9223
Avoid Removing Quotes From Requirement Markers (#3214)
## Summary

Avoid removing quotes from markers, e.g. `numpy (>=1.19) ;
python_version >= "3.7"` should not be rewritten. Fixes
https://github.com/astral-sh/uv/issues/2551.

This PR also makes fixups a bit more flexible internally for fixes that
aren't simple to implement with a pure regex replacement, like this one.
https://github.com/astral-sh/uv/pull/1529 fixed a similar problem but
the current regex is still not smart enough to avoid all markers
completely (like `python_version`).

## Test Plan

Added a few unit tests.
2024-04-23 14:07:51 -04:00
konsti
70ee3b7cd2
An enum and backticks for lookahead error (#3216)
Mostly a small refactor, adds backticks to be coherent with #3004.
2024-04-23 17:28:10 +00:00
konsti
4a49ff4372
Rename ancillary direct url types to parsed url (#3211)
Followup to #3187. Renaming only
2024-04-23 14:51:23 +00:00
Zanie Blue
645d0399fd
Bump version to 0.1.37 (#3208) 2024-04-23 14:35:27 +00:00
Zanie Blue
b8302d44de
Improve tracing for keyring provider (#3207) 2024-04-23 09:23:21 -05:00
Zanie Blue
598a67cf31
Fix fetch of credentials when cache is seeded with username (#3206)
Fixes the failure to lookup credentials in
https://github.com/astral-sh/uv/issues/3205

The issue is that we seed the cache with the index URL which includes a
username but no password. We did not ensure that a password was present
in the cached credentials before attempting a request with them. Now,
the cache will not return credentials when a username is provided and
the cached credentials have no password — the cached credentials are
useless in that case.

Tested with a Google Artifact Registry and keyring

```
RUST_LOG=uv=trace cargo run -q -- pip install requests --index-url https://oauth2accesstoken@us-central1-python.pkg.dev/<project>/pypi/simple/ --no-cache --keyring-provider subprocess -v
```
2024-04-23 09:02:29 -05:00
哇呜哇呜呀咦耶
65efaf70da
Make KeyringProvider::fetch_* async (#3089)
To resolve #3073
2024-04-23 07:58:00 -05:00
Charlie Marsh
ad923b71a7
Improve --python-platform documentation (#3202)
See:
https://github.com/astral-sh/uv/pull/3154#pullrequestreview-2016083883
2024-04-23 02:42:30 +00:00
renovate[bot]
054fa3e439
Update Rust crate zip to v1 (#3175) 2024-04-22 22:17:44 -04:00