Commit graph

2900 commits

Author SHA1 Message Date
Zanie Blue
a68146d978
Support toolchain requests with platform-tag style Python implementations and version (#4407)
Closes https://github.com/astral-sh/uv/issues/4399

---------

Co-authored-by: Andrew Gallant <andrew@astral.sh>
2024-06-19 17:04:24 +00:00
Zanie Blue
e5f061e1f1
Add test case for wheel with the same name at a different absolute path (#4398)
As discussed at
https://github.com/astral-sh/uv/pull/4396#issuecomment-2176741999

This may not be the desired behavior, but let's track it.
2024-06-19 15:08:01 +00:00
Zanie Blue
1f2dd5b942
Remove stale comment (#4413) 2024-06-19 15:01:33 +00:00
Zanie Blue
39da3917e5
Improve handling of command arguments in uv run and uv tool run (#4404)
Closes https://github.com/astral-sh/uv/issues/4390

We no longer require `--` to disambiguate child command options that
overlap with uv options.
2024-06-19 14:55:21 +00:00
Zanie Blue
9a3b8511f1
Treat mismatched directory and file urls as unsatisfied requirements (#4393)
Closes https://github.com/astral-sh/uv/issues/4391
2024-06-19 14:50:13 +00:00
Zanie Blue
0db5ce0e98
Filter uv version display in standard filters (#4403)
No reason for these to be special-cased and I need them for #4404 tests
2024-06-19 09:46:40 -05:00
Zanie Blue
2b74d13f40
Fix test case for toolchain find with no intepreters (#4408) 2024-06-19 09:40:10 -05:00
Zanie Blue
549d7dfe37
Add test case for wheel installation with different path (#4396)
Regression test for #4391 / https://github.com/astral-sh/uv/pull/4393
2024-06-19 09:39:55 -05:00
Zanie Blue
f219f88553
Rename Downloader for clarity (#4395)
Follow-up to https://github.com/astral-sh/uv/pull/4394 with internal
refactor
2024-06-18 16:00:10 -05:00
Zanie Blue
b22ee82f0d
Use "Prepared" instead of "Downloaded" in logs (#4394)
We download, build, and unzip packages in this stage. The current name
is very misleading.

Closes https://github.com/astral-sh/uv/issues/4011
2024-06-18 13:38:18 -05:00
konsti
e486eb86b7
Log when we fork (#4386)
We currently don't log if or when we split the resolution graphs into
forks. I ran into this when trying to debug missing forking.
2024-06-18 11:47:06 -05:00
Zanie Blue
fa6ed34105
Bump version to 0.2.13 (#4388) 2024-06-18 11:46:32 -05:00
Ibraheem Ahmed
eefc8c6d3c
Add --workspace option to uv add (#4362)
## Summary

Implements `uv add foo --workspace`, which adds `foo` as a workspace
dependency with the corresponding `tool.uv.sources` entry.

Part of https://github.com/astral-sh/uv/issues/3959.
2024-06-18 16:26:07 +00:00
Zanie Blue
96bfba9435
Fix duplicate changelog header (#4387) 2024-06-18 16:00:11 +00:00
Zanie Blue
b3e3d899e5
Use &impl AsRef<Path> instead of type parameter (#4383) 2024-06-18 15:54:07 +00:00
Zanie Blue
0b0a0472ad
Request Python 3.12 in the release script (#4384)
Otherwise, if another version is active we fail because Rooster requires
3.12
2024-06-18 10:44:42 -05:00
Andrew Gallant
20b44f3017 uv-resolver: add some tracing logs for when we filter requirements
Specifically, these are emitted when requirements fail to satisfy
`Requires-Python` or the markers associated with the current fork in the
resolver.

Closes #4373
2024-06-18 11:15:16 -04:00
Zanie Blue
58f53f01bb
Ignore query errors during uv toolchain list (#4382)
Closes #4380 

This is the same logic as `should_stop_discovery` but I changed the log
level and duplicated it because I don't really want that method to be
public. Maybe it should be though?
2024-06-18 14:52:59 +00:00
Zanie Blue
1ce21475a5
Respect .python-version files and fetch manged toolchains in uv project commands (#4361)
As in #4360, updates the uv project CLI to respect `.python-version`
files as default Python version requests. Additionally, updates project
interpreter discovery to fetch managed toolchains as in `uv venv
--preview`.
2024-06-18 09:43:52 -05:00
Zanie Blue
903dfc2f1f
Respect .python-version in uv venv --preview (#4360)
Adds support for reading Python version files (introduced in #4335) to
`uv venv`. If present, we'll use the file version as the default.
2024-06-18 14:21:35 +00:00
Zanie Blue
76c26db444
Move virtual environment test context into main context (#4370)
It was becoming problematic that the virtual environment test context
diverged from the other one i.e. we had to implement filtering twice.
This combines the contexts and tweaks the `TestContext` API and
filtering mechanisms for Python versions. Combined with my previous
changes to the test context at #4364 and
https://github.com/astral-sh/uv/pull/4368 this finally unblocks the
snapshots for test cases in #4360 and
https://github.com/astral-sh/uv/pull/4362.
2024-06-18 09:11:47 -05:00
Michał Górny
a193834813
Fix cache-prune-test to work outside the git repository (#4375)
## Summary

Make the git commit/date part of the version string matched in
cache_prune optional, so that the test also works correctly when uv is
built from an unpacked release tarball rather than a git repository.

Fixes #4374

## Test Plan

Ran `cargo test` inside the git repository and inside unpacked archive
for `0.2.12` release with the patch applied on top.
2024-06-18 10:15:40 +03:00
Charlie Marsh
c996e8e3f3
Enable workspace lint configuration in remaining crates (#4329)
## Summary

We didn't have Clippy enabled (to match our workspace settings) in a few
crates.
2024-06-18 03:02:28 +00:00
Zanie Blue
b8c0391667
Bump version to 0.2.12 (#4371) 2024-06-17 16:46:28 -05:00
Ibraheem Ahmed
a813a1de4c
uv sync --no-clean (#4367)
## Summary

Adds a `--no-clean` flag to `uv sync` that keeps extraneous
installations. This is the default in `uv run` and `uv add`, but not in
`uv sync` or `uv remove`. This means you need to run an explicit `uv
sync/remove` to clean the virtual environment.
2024-06-17 20:24:22 +00:00
Zanie Blue
05870609ee
Add filtering of interpreter names for tests with multiple Python versions (#4368)
Extends new filters for interpreter paths to apply to tests with
multiple Python versions. Adds patch version filtering for them as well,
which is needed for #4360 tests.
2024-06-17 20:22:46 +00:00
Zanie Blue
3f164b5a3a
Add Python version filtering for ad-hoc virtual environments (#4365)
Extends #4364 automatically adding filters to the test context for
additional test virtual environments.

It turns out that the `pip sync` tests were really on the loose with
their virtual environment creation and it was difficult to use the new
helpers because they require mutability and the tests had immutable
borrows to extend the filters 😭. I refactored the tests to just reset
the environment.
2024-06-17 15:15:00 -05:00
Zanie Blue
56f0a117ca
Move version file reading to uv-toolchain (#4340)
In preparation for using this in other commands.
2024-06-17 18:54:22 +00:00
Zanie Blue
631994c485
Remove cargo dev fetch-python (#4337)
This has been fully replaced by `uv toolchain install`
2024-06-17 18:49:06 +00:00
Ibraheem Ahmed
05d79f8d38
Remove extraneous installations in uv sync by default (#4366)
## Summary

First step of https://github.com/astral-sh/uv/issues/4358. `uv sync`
will now remove any extraneous installations by default.
2024-06-17 14:38:34 -04:00
Zanie Blue
47d3834fd3
Read Python version files during toolchain installs (#4335)
A bare `uv toolchain install` invocation now reads default requests from
Python version files in the working directory. In order, a bare
invocation means:

- requests from `.python-versions`
- a single request from`.python-version`
- any installed managed toolchain
- the latest managed toolchain download

This replaces all the functionality of `cargo dev fetch-python`, which
we drop in #4337
2024-06-17 18:37:52 +00:00
samypr100
a0eca1ac14
feat: display keyring stderr (#4343)
## Summary

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

Changes keyring subprocess to allow display of stderr.
This aligns with pip's behavior since pip 23.1.

## Test Plan

* Tested using gnome-keyring-backend on a self-hosted private registry
as well as the keyring script described in #4162 to confirm both
existing functionality and the new stderr display.
* Existing tests using `scripts/packages/keyring_test_plugin` are now
showing its stderr output as well.
2024-06-17 13:29:33 -05:00
Zanie Blue
fdcdc2cbe6
Allow multiple toolchains to be requested in uv toolchain install (#4334)
Allows installation of multiple toolchains in a single invocation
because I don't want to be limited to one! Most of the implementation
for concurrent downloads ported from `cargo dev fetch-python`.
2024-06-17 18:24:11 +00:00
renovate[bot]
4db6b902eb
Update Rust crate reqwest to v0.12.5 (#4363) 2024-06-17 13:18:46 -05:00
Zanie Blue
5248269d27
Add support for toolchain requests by key (#4332)
Adds support for toolchain keys e.g. `cpython-3.11.2-macos` allowing you
to download toolchains for specific architectures and operating systems
using the format we use to uniquely identify a toolchain.
2024-06-17 13:11:24 -05:00
Zanie Blue
94fe70d547
Add filtering of the test context Python interpreter (#4364)
Does not handle tests with multiple Python versions yet, working on that
separately because the change is more invasive
2024-06-17 13:11:12 -05:00
Zanie Blue
b5d280dc40
Refactor Toolchain API to always take ToolchainRequest instead of str (#4341)
This API was taking an `Option<&str>` for caller convenience in some
places but we ought to just take a `ToolchainRequest` consistently.
2024-06-17 11:16:15 -05:00
Zanie Blue
67f1285ce3
Add EXTERNALLY-MANAGED markers to managed toolchains (#4312)
Closes #4240 

e.g.

```
❯ cargo run -q -- pip install anyio --python "/Users/zb/Library/Application Support/uv/toolchains/cpython-3.12.0-macos-aarch64-none/install/bin/python3"
error: The interpreter at /Users/zb/Library/Application Support/uv/toolchains/cpython-3.12.0-macos-aarch64-none/install is externally managed, and indicates the following:

  This toolchain is managed by uv and should not be modified.

Consider creating a virtual environment with `uv venv`.
```
2024-06-17 15:25:34 +00:00
Andrew Gallant
e264637b63 uv/tests: add more fork marker tests
These were prompted by @konstin's question here:
https://github.com/astral-sh/uv/pull/4339#discussion_r1642622391
2024-06-17 09:30:37 -04:00
Andrew Gallant
bb40d13603 scenarios: bump to packse 0.3.27 2024-06-17 09:30:37 -04:00
Andrew Gallant
6a7b56ca05 uv/tests: add fork marker packse tests 2024-06-17 09:30:37 -04:00
Andrew Gallant
eea1bf9bf2 scenarios: bump to packse 0.3.26 2024-06-17 09:30:37 -04:00
Andrew Gallant
dbb12bcfe4 uv-resolver: fix bug in marker disjointness checking
I found this while testing the tracking of marker expressions across
resolver forks. Namely, given

    sys_platform == 'darwin' and implementation_name == 'pypy'

And:

    sys_platform == 'bar' or implementation_name == 'foo'

These should be disjoint, but the disjointness checker was reporting
them as overlapping. I fixed this by giving handling of disjunctions
higher precedence than conjunctions, although I am not 100% confident
that this is correct for all cases.
2024-06-17 09:30:37 -04:00
Andrew Gallant
407f1e370b uv-resolver: filter dependencies that can't exist in a fork
This commit adds marker expressions to our `Fork` type, which are in
turn passed down into `PubGrubDependencies::from_requirements` to filter
our any dependencies with markers that are disjoint from the fork's
marker expression.

This is necessary to avoid visiting packages in the dependency graph
that can never actually be installed. This is because when a fork is
created in the resolver, it always happens when there are two sibling
dependency specifications on a package with the same name, but with
non-overlapping marker expressions. Each fork corresponds to each
such conflicting dependency specification, and each fork assumes the
the corresponding marker expression as a pre-condition for any future
dependencies considered by it. That is, since the fork represents an
installation path that can only be taken when the corresponding
dependency specification (and its marker expression) is actually used,
it also therefore follows that the marker expression is true. Therefore,
any dependency visited in that fork with a marker expression that cannot
possibly be true when the markers of the fork are true can and ought to
be completely ignored.
2024-06-17 09:30:37 -04:00
Andrew Gallant
07db2b167f uv-resolver: document some of our intermediate data structures
There are some key invariants that I had to re-learn by reading the
code. This hopefully makes those invariants easier to discover by future
me (and others).
2024-06-17 09:30:37 -04:00
renovate[bot]
147aec4d37
Update Rust crate configparser to v3.1.0 (#4353) 2024-06-17 05:40:51 -05:00
Zanie Blue
52bb9a694c
Isolate virtual environment tests from developer toolchains (#4342)
Otherwise, when testing `uv venv --preview` the default toolchain
directory will leak into the test.

I believe I've made a similar change for the standard `TestContext` in
another commit somewhere in my stack, if not I'll add it after.
2024-06-17 05:40:11 -05:00
renovate[bot]
3a55c17ef1
Update pre-commit dependencies (#4352) 2024-06-17 00:04:08 -05:00
renovate[bot]
e0b5b0b84a
Update Rust crate reflink-copy to v0.1.18 (#4350) 2024-06-17 00:03:12 -05:00
renovate[bot]
df04fdf33d
Update Rust crate http-body-util to v0.1.2 (#4349) 2024-06-17 00:02:07 -05:00