Commit graph

4903 commits

Author SHA1 Message Date
samypr100
b918557ae7
ci(docker): improve release tagging order and display on ghcr.io (#7568)
## Summary

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

This change adds a new job at the end of docker publish which adds
annotations the primary image digests in order to make ghcr.io rank
`ghcr.io/astral-sh/uv` at the top once again. The solution is to
annotate the index at the end during a re-publish to make ghcr.io
consider it a more updated entry than the others and rank it at the top
once again.

## Test Plan

Tested on release run on my own fork
* Packages: https://github.com/samypr100/uv/pkgs/container/uv will show
`ghcr.io/astral-sh/uv` first once again
* Run: 1095140473
2024-09-20 14:05:51 -05:00
Zanie Blue
398f13824e
Add integration test for UV_PROJECT_ENVIRONMENT (#7591)
[Example](3044567357)

Test for #7585
2024-09-20 14:03:42 -05:00
Charlie Marsh
445d1c0d43
Avoid validating workspace members when --no-sources is provided (#7599)
## Summary

Closes https://github.com/astral-sh/uv/issues/7572.
2024-09-20 19:03:31 +00:00
Zanie Blue
d6c9603594
Fix handling of sys.base_prefix collision in interpreter identity check during tool installs (#7596)
Closes https://github.com/astral-sh/uv/issues/7586

Extends https://github.com/astral-sh/uv/pull/7593 (thanks @lucab!)

---------

Co-authored-by: Luca BRUNO <lucab@lucabruno.net>
2024-09-20 14:01:14 -05:00
Zanie Blue
e93b54e240
Adjust messaging for frozen hint on resolution failure during uv add (#7597)
The existing message has been driving me a little crazy :) it's too
vague.
2024-09-20 14:01:07 -05:00
Charlie Marsh
86ff740100
Remove flatten to improve deserialization error messages (#7598)
## Summary

`#[serde(flatten)]` has a disastrous effect on error messages: serde no
longer tells you which field errored, nor does it show it to you in the
diagnostic output.

Before:

```
warning: Failed to parse `pyproject.toml` during settings discovery:
  TOML parse error at line 9, column 1
    |
  9 | [tool.uv]
    | ^^^^^^^^^
  invalid type: string "foo", expected a sequence
```

After:

```
warning: Failed to parse `pyproject.toml` during settings discovery:
  TOML parse error at line 10, column 19
     |
  10 | extra-index-url = "foo"
     |                   ^^^^^
  invalid type: string "foo", expected a sequence
```

Closes https://github.com/astral-sh/uv/issues/7113.
2024-09-20 14:54:12 -04:00
Charlie Marsh
85af2732ea
Revert "Remove duplicate warning for settings discovery errors (#7384)" (#7594)
## Summary

This reverts commit 3060fd22c0.

These are now _never_ shown to users, because `tracing` isn't set up at
that point. I'm going to try and improve the solution more holistically,
but this is better than the status quo.

Closes https://github.com/astral-sh/uv/issues/7573.
2024-09-20 14:18:40 -04:00
Luca Bruno
2c6d353711
Provide resolution hints in case of possible local name conflicts (#7505)
This enhances the hints generator in the resolver with some heuristic to
detect and warn in case of failures due to version mismatches on a local
package. Those may be the symptom of name conflict/shadowing with a
transitive dependency.

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

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-09-20 13:07:34 -05:00
Zanie Blue
9164999f23
Allow system environments during project environment validity check (#7585) 2024-09-20 12:28:17 -05:00
Jacob Coffee
8259600ca6
Fix - to _ in Packaged applications doc (#7571)
## Summary

Small stale/typo char in docs when generating a project

```
➜ ntp -v uv-test && uv venv --python 3.12 --seed && uv init --app --package example-packaged-app
Directory /tmp/testing/uv-test created and switched to.
Using Python 3.12.4 interpreter at: /Users/coffee/.local/share/mise/installs/python/3.12/bin/python3.12
Creating virtual environment with seed packages at: .venv
 + pip==24.2
Activate with: source .venv/bin/activate.fish
Virtual environment created with Python 3.12 and activated.
Using Python 3.12.4 interpreter at: /Users/coffee/.local/share/mise/installs/python/3.12/bin/python3.12
Creating virtual environment with seed packages at: .venv
 + pip==24.2
Activate with: source .venv/bin/activate.fish
Initialized project `example-packaged-app` at `/private/tmp/testing/uv-test/example-packaged-app`

/tmp/testing/uv-test via  pyenv (uv-test) on ☁  (us-east-2)
➜ tree
   0 B    ┌─ README.md
4096 B    ├─ pyproject.toml
4096 B    │     ┌─ __init__.py
4096 B    │  ┌─ example_packaged_app
4096 B    ├─ src
8192 B ┌─ example-packaged-app
8192 B uv-test
```

## Test Plan

Eyeballs
2024-09-20 08:47:53 +02:00
bluss
7a25a82fc9
Move uvx shell completion to uvx --generate-shell-completion (#7511)
## Summary

Because a problem was found with Powershell and combining the generated
completion scripts for uv and uvx, let's try separating uv and uvx
command completion scripts.

The generated powershell script template can be seen in clap_complete
source, and it starts with `using` directives, which makes it impossible
(apparently) to concatenate two of those script outputs.

As a side effect, this is available under `uv tool run
--generate-shell-completion` too.

Fixes #7482

## Test Plan

- `eval "$(cargo run --bin uvx -- --generate-shell-completion bash)"`
- Test Powershell
2024-09-20 01:27:25 +00:00
Charlie Marsh
99d354b893
Replace pretix ecosystem test with saleor (#7567)
## Summary

The AGPL license is confusing some analyzers. This replaces pretix with
saleor which (similarly) is a web application.

Closes https://github.com/astral-sh/uv/issues/7566.
2024-09-19 21:20:44 -04:00
Charlie Marsh
f9b882939f
Make uv cache prune robust to unreadable rkyv entries (#7561)
## Summary

We're robust to these in the rest of the CLI, but not in `uv cache
prune`.
2024-09-19 20:48:20 +00:00
Zanie Blue
b8f9ee3b4d
Bump version to 0.4.13 (#7558) 2024-09-19 20:43:56 +00:00
Charlie Marsh
f3463b3d08
Heal cache entries with missing source distributions (#7559)
## Summary

`uv cache prune --ci` will remove the source distribution directory. If
we then need to build a _different_ wheel (e.g., you're building a
package that has Python minor version-specific wheels), we fail, because
we expect the source to be there.

Now, if the source is missing, we re-download it. It would be slightly
easier to just _ignore_ that revision, but that would mean we'd also
lose the already-built wheels -- so if you ran against many Python
versions, we'd continuously lose the cached data.

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

## Test Plan

We can add tests, but they _need_ to build non-pure Python wheels, which
tends to be expensive...

For reference:

```console
$ cargo run venv --python 3.12
$ cargo run pip install mercurial==6.8.1 --verbose
$ cargo run cache prune --ci
$ cargo run venv --python 3.11
$ cargo run pip install mercurial==6.8.1 --verbose
```

I also did this with a local `.tar.gz` that I downloaded from PyPI.
2024-09-19 20:31:55 +00:00
Charlie Marsh
5de6d2338d
Bump the wheel and sdist cache versions (#7560)
## Summary

Both of these can contain rkyv data in their HTTP cache envelopes. As
such, the entries aren't readable by earlier versions of uv, and `uv
cache prune` can break. I should make `uv cache prune` robust to this,
but this feels safest.
2024-09-19 19:53:06 +00:00
Charlie Marsh
18c18b8406
Treat invalid platform as more compatible than invalid Python (#7556)
## Summary

I think this is just inverted. It means that when we fail in
https://github.com/astral-sh/uv/issues/7553, we show a message for
"invalid Python implementation" (since there are some wheels that don't
match), but we should be showing "invalid platform", matching the order
of operations in our compatibility check.

Closes https://github.com/astral-sh/uv/issues/7553.
2024-09-19 13:25:21 -04:00
Zanie Blue
5206a33e78
Do not error if the CACHEDIR.TAG file exists but cannot be written to (#7550)
Attempting to address the error in
https://github.com/astral-sh/uv/issues/7434 — it seems overkill to fail
if the file exists but isn't writable.
2024-09-19 09:39:59 -05:00
Zanie Blue
99d57ca80e
Improve invalid environment warning messages (#7544)
Adds display of the target path of the link (since the link filename
itself is basically static) and distinguishes between broken links and
missing files.
2024-09-19 09:11:17 -05:00
Luca Bruno
248bef13bd
Compute resolver hints using the final reduced derivation tree (#7546)
This switches the no-solution formatter to use the final derivation tree
(simplified and reduced) when generating hints.
2024-09-19 16:06:55 +02:00
Zanie Blue
df90cc6f95
Filter flaky counts in sync_build_isolation_extra (#7531)
I've seen this flake several times now, e.g.,
3035128927

I don't quite understand why, but we have a standard filter for this.
2024-09-19 07:03:03 -05:00
You Jiacheng
a235b7d70d
Clarify behavior of of overrides in CLI reference (#7537)
## Summary
Improve the description of override-dependencies based on the statement
in `concepts/resolution.md`: "As with constraints, overrides do not add
a dependency on the package and only take effect if the package is
requested in a direct or transitive dependency."

I tested it locally, `concepts/resolution.md` is correct. It would be
better to also include this in the Reference Chapter of the docs.
2024-09-19 07:02:42 -05:00
Zanie Blue
6b08aaecad
Avoid warning about bad Python interpreter links for empty project environment directories (#7527)
Someone reported this a while back (will try to find the issue), and I
ran into it working on #7522
2024-09-19 06:49:35 -05:00
konsti
4fdf5fc73f
Use a single lint task in CI (#7540) 2024-09-19 13:32:08 +02:00
Zanie Blue
8d26e11380
Avoid deleting the project environment directory if it is not a virtual environment (#7522)
Closes https://github.com/astral-sh/uv/issues/7519
2024-09-19 11:21:05 +00:00
Zanie Blue
09a2ebca8b
Add new PythonRequest::Any and VersionRequest::Any variants (#7517)
Follow-up to https://github.com/astral-sh/uv/pull/7514 and #7526 adding
the `Any` variants again with slightly different semantics (i.e., they
allow pre-releases)

We'll be able to use this in https://github.com/astral-sh/uv/pull/7508
to avoid querying a bunch of alternative interpreters unnecessarily in
the non-list case.
2024-09-19 11:19:13 +00:00
Zanie Blue
0f9a2e3870
Rename VersionRequest::Any -> VersionRequest::Default (#7526)
As in https://github.com/astral-sh/uv/pull/7514
2024-09-19 11:05:09 +00:00
Zanie Blue
0cc36a457b
Use placeholder for virtual environment activation bin filter (#7530)
I think it's best practice to use a placeholder when we transform
something, and #7522 is having snapshot issues because this filter
conflicts with `with_filtered_virtualenv_bin`
2024-09-19 05:56:46 -05:00
Zanie Blue
5941709e55
Rename PythonRequest::Any -> PythonRequest::Default (#7514)
As we support more complex Python discovery behaviors such as:

- #7431 
- #7335 
- #7300 

`Any` is no longer accurate, we actually are looking for a reasonable
default Python version to use which may exclude the first one we find.
Separately, we need the idea of `Any` to improve behavior when listing
versions (e.g., #7286) where we do actually want to match _any_ Python
version. As a first step, we'll rename `Any` to `Default`. Then, we'll
introduce a new `Any` that actually behaves as we'd expect.
2024-09-19 05:56:05 -05:00
Zanie Blue
209c870232
Add UV_LINK_MODE to Docker caching example (#7510)
As mentioned in https://github.com/astral-sh/uv/issues/7509
2024-09-19 05:55:54 -05:00
Zanie Blue
7778a11b2d
Use more verbose spelling of "virtualenv" during creation (#7523)
This stands out alongside other messaging which uses the longer spelling
"virtual environment"
2024-09-18 21:22:37 -05:00
Charlie Marsh
e36cc99b0d
Use portable paths when serializing sources (#7504)
## Summary

Closes https://github.com/astral-sh/uv/issues/7493.
2024-09-18 18:51:14 +00:00
Andrew Gallant
1379b530f6 uv: migrate to rkyv 0.8
Recently, rkyv 0.8 was released. Its API is a fair bit simpler now for
higher level uses (like for us in `uv`) and results in us being able to
delete a fair bit of code. This also removes our last dependency on `syn
1.0`, and thus drops that dependency.

Performance (via testing on the `transformers` example) seems to remain
about the same, which is what was expected:

```
$ hyperfine -w5 -r100 'uv lock' 'uv-ag-rkyv-update lock'
Benchmark 1: uv lock
  Time (mean ± σ):      55.6 ms ±   6.4 ms    [User: 30.4 ms, System: 35.1 ms]
  Range (min … max):    43.0 ms …  73.1 ms    100 runs

Benchmark 2: uv-ag-rkyv-update lock
  Time (mean ± σ):      56.5 ms ±   7.2 ms    [User: 30.5 ms, System: 36.3 ms]
  Range (min … max):    39.1 ms …  71.5 ms    100 runs

Summary
  uv lock ran
    1.02 ± 0.18 times faster than uv-ag-rkyv-update lock
```

Closes #7415
2024-09-18 14:49:54 -04:00
Andrew Gallant
91a574c6d2 uv/tests: filter out link mode warning in two more tests
More whack-a-mole following in the tradition of #7012.
2024-09-18 14:10:53 -04:00
Charlie Marsh
fe4e39a230
Add socks support (#7503)
## Summary

This adds about 50 KB to the binary:

```
❯ du ./target/release/socks
44736	./target/release/socks

❯ du ./target/release/uv
44632	./target/release/uv
```

So need some input on whether it's worth supporting.

Closes https://github.com/astral-sh/uv/issues/7484.
2024-09-18 11:46:06 -04:00
Zanie Blue
8b830de94d
Do not use a user-facing warning for "Waiting to acquire lock..." message (#7502)
Closes https://github.com/astral-sh/uv/issues/7489
2024-09-18 15:34:27 +00:00
Zanie Blue
4611412757
Allow Python pre-releases to be used if they are first on the PATH (#7470)
Closes https://github.com/astral-sh/uv/issues/7469
2024-09-18 10:19:10 -05:00
Luca Bruno
67cfb4a9c0
Use a single buffer for hints on resolver errors (#7497)
This changes the structure of the hints generator in the resolver when
encountering solution errors, so that it re-uses a single output buffer
owned by the caller.
It avoids repeated allocations of a temporary buffer within each
recursive function call.
2024-09-18 16:16:22 +02:00
Charlie Marsh
039b68367e
Add test for uv cache prune --ci with source distributions (#7500)
## Summary

See: https://github.com/astral-sh/uv/issues/7485. The test was using `uv
pip sync` which doesn't require fetching metadata, and the failure was
in fetching metadata.
2024-09-18 10:01:07 -04:00
Zanie Blue
2545bca692
Bump version to 0.4.12 (#7499) 2024-09-18 08:50:04 -05:00
samypr100
5e49f21adf
docs: add warning note on self-hosted github runners (#5757)
## Summary

Related discussion: #5731

This adds a warning section for caching on non-ephemeral (e.g. ec2) self
hosted github runners.

## Test Plan

Prettier was ran on the file.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-09-18 13:34:25 +00:00
Charlie Marsh
97ae811b86
Avoid fatal error when searching for egg-info with missing directory (#7498)
## Summary

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

## Test Plan

```
$ cargo run cache clean
$ cargo run venv
$ cargo run pip install django-allauth==0.51.0
$ cargo run venv
$ cargo run pip install django-allauth==0.51.0
```
2024-09-18 09:33:11 -04:00
konsti
f942561158
Cache ecosystem tests (#7432) 2024-09-18 11:30:59 +02:00
Luca Bruno
969b4a2222
uv-tool/install: ignore existing environments on interpreter mismatch (#7451)
This changes `uv tool install` behavior with regards to re-using
existing environments.
In particular, this replaces the existing version-matching logic with a
tighter one, enforcing
a same-interpreter match.
This allows to properly switch between system and managed interpreter,
at the cost of
more eagerly invalidating existing environments every time there is an
interpreter change.

Closes: https://github.com/astral-sh/uv/issues/7320
2024-09-18 08:37:41 +02:00
Charlie Marsh
fda227616c
Allow users to provide pre-defined metadata for resolution (#7442)
## Summary

This PR enables users to provide pre-defined static metadata for
dependencies. It's intended for situations in which the user depends on
a package that does _not_ declare static metadata (e.g., a
`setup.py`-only sdist), and that is expensive to build or even cannot be
built on some architectures. For example, you might have a Linux-only
dependency that can't be built on ARM -- but we need to build that
package in order to generate the lockfile. By providing static metadata,
the user can instruct uv to avoid building that package at all.

For example, to override all `anyio` versions:

```toml
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["anyio"]

[[tool.uv.dependency-metadata]]
name = "anyio"
requires-dist = ["iniconfig"]
```

Or, to override a specific version:

```toml
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["anyio"]

[[tool.uv.dependency-metadata]]
name = "anyio"
version = "3.7.0"
requires-dist = ["iniconfig"]
```

The current implementation uses `Metadata23` directly, so we adhere to
the exact schema expected internally and defined by the standards. Any
entries are treated similarly to overrides, in that we won't even look
for `anyio@3.7.0` metadata in the above example. (In a way, this also
enables #4422, since you could remove a dependency for a specific
package, though it's probably too unwieldy to use in practice, since
you'd need to redefine the _rest_ of the metadata, and do that for every
package that requires the package you want to omit.)

This is under-documented, since I want to get feedback on the core ideas
and names involved.

Closes https://github.com/astral-sh/uv/issues/7393.
2024-09-18 03:18:05 +00:00
kyoto7250
e5dd67f58e
Add support for --with-editable to uv tool (#6744)
<!--
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? -->
close #6272 

## Test Plan
<!-- How was it tested? -->
As in https://github.com/astral-sh/uv/pull/6262

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-09-17 20:51:34 +00:00
Charlie Marsh
6c52f36655
Bump version to v0.4.11 (#7478) 2024-09-17 19:48:37 +00:00
Charlie Marsh
adbd99a1d6
Document store_credentials_from_workspace (#7477) 2024-09-17 19:19:45 +00:00
Charlie Marsh
c2ad31aa58
Respect pyproject.toml credentials from user-provided requirements (#7474)
## Summary

When syncing a lockfile, we need to respect credentials defined in the
`pyproject.toml`, even if they won't be used for resolution.
Unfortunately, this includes credentials in `tool.uv.sources`,
`tool.uv.dev-dependencies`, `project.dependencies`, and
`project.optional-dependencies`.

Closes https://github.com/astral-sh/uv/issues/7453.
2024-09-17 15:09:11 -04:00
Zanie Blue
08a7c708d1
Do not allow local versions in Python version requests either (#7468)
Accidentally squashed https://github.com/astral-sh/uv/pull/7465 into the
wrong target.
2024-09-17 16:10:38 +00:00