Commit graph

3294 commits

Author SHA1 Message Date
konsti
c7ff70b281
Block Python <3.7 not only on linux (#7266)
There's no reason for this check to be limited to linux.
2024-09-10 15:15:41 -05:00
Zanie Blue
0e9870078e
Add support for managed Python 3.13 and update CPython versions (#7263)
Adds support for CPython 3.13.0rc2

Also bumps to the latest patch version of all the other CPython minor
versions we support.
2024-09-10 14:36:16 -05:00
Zanie Blue
0dc1f5db21
Improve error message when requested Python version is unsupported (#7269)
Follows test cases in #7265 and validation removal in
https://github.com/astral-sh/uv/pull/7264

It turns out we don't have good error messages for these as-is.
2024-09-10 19:01:36 +00:00
Zanie Blue
948071b2f2
Add test cases for finding unsupported versions (#7265)
Loosely testing for regressions in
https://github.com/astral-sh/uv/pull/7265
2024-09-10 13:49:30 -05:00
Zanie Blue
aa52952512
Deduplicate implementation for python_installation_from_directory (#7267) 2024-09-10 18:41:31 +00:00
Zanie Blue
533c7e3bfd
Drop Python version range enforcement from PythonVersion::from_str (#7264)
This caused some problems earlier, as it prevented us from _listing_
Python versions <3.7 which seems weird (see
https://github.com/astral-sh/uv/pull/7131#issuecomment-2334929000)

I'm worried that without this the changes to installation key parsing in
https://github.com/astral-sh/uv/pull/7263 would otherwise be too
restrictive.

I think if we want to enforce these ranges, we should do so separately
from the parse step.
2024-09-10 13:34:18 -05:00
Ibraheem Ahmed
4f03d204df
Run benchmarks with --profile profiling (#5927)
## Summary

The CodSpeed flamegraphs are currently useless after
https://github.com/astral-sh/uv/pull/5745.
2024-09-10 14:25:53 -04:00
Charlie Marsh
cfa9299d09
Avoid updating pyproject.toml offsets on non-add edits (#7262)
## Summary

Closes https://github.com/astral-sh/uv/issues/7259.
2024-09-10 17:43:58 +00:00
Ahmed Ilyas
bbccee8bee
Allow setting a target version for uv self update (#7252)
## Summary

Resolves #6642 

## Test Plan

```console
❯ cargo build --bin uv --features self-update
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.78s
❯ cp target/debug/uv ~/.cargo/bin
❯ uv self update 0.3.4
info: Checking for updates...
success: Upgraded uv from v0.4.8 to v0.3.4! https://github.com/astral-sh/uv/releases/tag/0.3.4
❯ uv --version
uv 0.3.4 (39f3cd2a9 2024-08-26)
❯ cp target/debug/uv ~/.cargo/bin
❯ uv self update
info: Checking for updates...
success: Upgraded uv from v0.3.4 to v0.4.8! https://github.com/astral-sh/uv/releases/tag/0.4.8
❯ uv --version
uv 0.4.8 (956cadd1a 2024-09-09)
```
2024-09-10 13:35:31 +00:00
konsti
2b3890f2b4
Extract METADATA reading into a crate (#7231)
This is preparatory work for the upload functionality, which needs to
read the METADATA file and attach its parsed contents to the POST
request: We move finding the `.dist-info` from `install-wheel-rs` and
`uv-client` to a new `uv-metadata` crate, so it can be shared with the
publish crate.

I don't properly know if its the right place since the upload code isn't
ready, but i'm PR-ing it now because it already had merge conflicts.
2024-09-10 13:31:01 +00:00
Charlie Marsh
95a4beeed3
Remove workspace root for single-member workspace with uv export (#7254)
## Summary

If we have a single-member workspace, we actually don't write it to
`members`.

Closes https://github.com/astral-sh/uv/issues/7241.
2024-09-10 09:27:45 -04:00
Charlie Marsh
53a722cc09
Add a dedicated error for packages that fail due to distutils deprecation (#7239)
## Summary

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

## Test Plan

![Screenshot 2024-09-09 at 9 33
45 PM](https://github.com/user-attachments/assets/ffe896cc-d5dd-4ec8-96c9-c37a964489e3)
2024-09-09 22:51:17 -04:00
Charlie Marsh
a8bd0211e0
Invalidate cache when --config-settings change (#7139)
## Summary

If `--config-settings` are provided, we cache the built wheels under one
more subdirectory.

We _don't_ invalidate the actual source (i.e., trigger a re-download) or
metadata, though -- those can be reused even when `--config-settings`
change.

Closes https://github.com/astral-sh/uv/issues/7028.
2024-09-10 01:49:16 +00:00
Charlie Marsh
fdf2ff5a51
Break up uv-build/src/lib.rs (#7238) 2024-09-09 21:36:45 -04:00
Charlie Marsh
956cadd1a6
Bump version to v0.4.8 (#7233) 2024-09-09 17:19:40 -04:00
Charlie Marsh
fe8880bf3c
Surface dedicated errors for .python-version conflict with requires-python (#7218)
## Summary

I got confused because I had a `.python-version` file that conflicted
with my `requires-python`.
2024-09-09 17:12:53 -04:00
Bartosz Sławecki
5905f40f50
Use type hints in code from uv init (#7225)
Let's promote type hints!

<!--
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? -->
The generated script now annotates the return type of the dummy function
`hello()`.

## Test Plan

<!-- How was it tested? -->
All existing tests have been synced with this update.
2024-09-09 15:37:21 -05:00
Andrew Gallant
74c6e53727 pep508: small fixes for debug marker graph output
This responds to some feedback left on #7130.
2024-09-09 16:20:23 -04:00
Charlie Marsh
4f2349119c
Add support for dynamic cache keys (#7136)
## Summary

This PR adds a more flexible cache invalidation abstraction for uv, and
uses that new abstraction to improve support for dynamic metadata.

Specifically, instead of relying solely on a timestamp, we now pass
around a `CacheInfo` struct which (as of now) contains
`Option<Timestamp>` and `Option<Commit>`. The `CacheInfo` is saved in
`dist-info` as `uv_cache.json`, so we can test already-installed
distributions for cache validity (along with testing _cached_
distributions for cache validity).

Beyond the defaults (`pyproject.toml`, `setup.py`, and `setup.cfg`
changes), users can also specify additional cache keys, and it's easy
for us to extend support in the future. Right now, cache keys can either
be instructions to include the current commit (for `setuptools_scm` and
similar) or file paths (for `hatch-requirements-txt` and similar):

```toml
[tool.uv]
cache-keys = [{ file = "requirements.txt" }, { git = true }]
```

This change should be fully backwards compatible.

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

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

Closes https://github.com/astral-sh/uv/issues/6860.
2024-09-09 20:19:15 +00:00
Charlie Marsh
9a7262c360
Avoid batch prefetching for un-optimized registries (#7226)
## Summary

We now track the discovered `IndexCapabilities` for each `IndexUrl`. If
we learn that an index doesn't support range requests, we avoid doing
any batch prefetching.

Closes https://github.com/astral-sh/uv/issues/7221.
2024-09-09 15:46:19 -04:00
Charlie Marsh
970bd1aa0c
Respect exclusion when collecting workspace members (#7175)
## Summary

We were only applying exclusions when discovering the root, apparently.

Our logic now matches the original intent, which is...

- `exclude` always post-filters `members`.
- We don't treat globs any differently than non-globs.

The one confusing setup that falls out of this is that given:

```toml
members = ["foo/bar/baz"]
exclude = ["foo/bar"]
```

`foo/bar/baz` **would** be included. To exclude it, you would need:

```toml
members = ["foo/bar/baz"]
exclude = ["foo/bar/*"]
```

Closes https://github.com/astral-sh/uv/issues/7071.
2024-09-09 12:08:06 -04:00
Charlie Marsh
d9cd2829fa
Fix typo in name normalization (#7217) 2024-09-09 14:29:28 +00:00
Charlie Marsh
dcbaa1f486
Avoid iteration for singleton selections (#7195)
## Summary

If we have a singleton `Range`, we don't need to iterate over the map of
available ranges; instead, we can just get the singleton directly.

Closes #6131.
2024-09-09 13:43:57 +00:00
Charlie Marsh
dafa3596c5
Avoid distribution clones in requirements.txt graph (#7210) 2024-09-09 13:31:13 +00:00
Charlie Marsh
b738b35910
Prune unreachable packages from --universal output (#7209)
## Summary

Closes https://github.com/astral-sh/uv/issues/7196.
2024-09-09 09:20:25 -04:00
bluss
fdde92b539
Use path file instead of sitecustomize.py (#7161)
## Summary

Use a path file (`.pth`) instead of `sitecustomize.py` for configuring
path in emphemeral virtualenvs, overlaying the ephemeral venv on top of
the base `.venv`.

`sitecustomize.py` is a module in the python installation and as such a
unique resource - homebrew pythons on macos already install such a file
and thus uv's `sitecustomize.py`, placed in the ephemeral env, did not
have any effect.

I don't find any documentation explicitly saying that addsitedir is
valid in `.pth` files but from trial it seems to be - and there is the
precedent of the existing _virtualenv.pth _virtualenv.py pair that do
nontrivial operations.

## Test Plan

- Testing on ephemeral venv, resolving to base venv including editable
install in base: done (py3.7, 3.12)
- Testing on homebrew python/macos: done (py3.11)
- tests: run_editable

Fixes #7152
2024-09-09 09:19:55 -04:00
Charlie Marsh
947619657c
Allow .dist-info names with dashes for post releases (#7208)
## Summary

Closes https://github.com/astral-sh/uv/issues/7155.
2024-09-09 09:12:53 -04:00
Soof Golan
14ebc393fc
treat .tgz the same as .tar.gz (#7201)
## Summary

Fixes #7081 

Treats source distribution `.tgz` the same as `.tar.gz` plans

## Test Plan

Quick Version

```bash
cd $(mktemp -d)
uv init
uv add --dev build
.venv/bin/python -m build -s .
mv -v dist/*tar.gz dist/"$(basename dist/*.tar.gz .tar.gz)".tgz
uv pip install dist/*.tgz
```

Can add a proper test to the branch if requested
2024-09-08 23:09:39 +00:00
Charlie Marsh
64e03ad56c
Direct users towards uv venv to create a virtual environment (#7188)
## Summary

Closes https://github.com/astral-sh/uv/issues/7123.
2024-09-08 22:33:34 +00:00
Shantanu
022e41327a
Improve error message for uv init already init-ed (#7198)
Someone in
1282411049
found this confusing

Could maybe improve further, e.g. what the user should do next might
depend if there are [project] or [tool.uv] sections

---------

Co-authored-by: Charlie Marsh <crmarsh416@gmail.com>
2024-09-08 18:28:27 -04:00
Charlie Marsh
4466402214
DRY up exclusion checks in selector (#7194) 2024-09-08 17:42:41 +00:00
Charlie Marsh
f11eebd735
Bump Rust toolchain to 1.81 (#7187) 2024-09-08 15:09:49 +00:00
konsti
aca01f80ef
Clearer registry Python sort (#7178)
Change the registry Python sorting implementation to be easier to
follow, making it clearer what it does and that it is a total order. No
functional changes.
2024-09-07 15:57:01 -04:00
Mathieu Kniewallner
8341d810b2
docs: list supported sdist formats (#7168)
## Summary

Explicitly list the formats and extensions that uv supports, based on
[this
list](86ee8d2c01/crates/distribution-filename/src/extension.rs (L70-L77)).
Not a huge fan of adding the section in `concepts/resolution.md`, but I
did not find a better place. Alternatively we could maybe add a
dedicated page that shortly explains Python package types (wheels,
sdists), where such a section could live?

## Test Plan

Local run of the documentation.
2024-09-07 19:16:12 +00:00
Charlie Marsh
e8a26a43f5
Avoid extra newlines in debug logging for source builds (#7174)
## Summary

@henryiii brought this up and I noticed it too:

![Screenshot 2024-09-06 at 4 09
32 PM](https://github.com/user-attachments/assets/a2849a0e-0515-4856-a9fe-14c713ed9b75)

## Test Plan

`uv build`:

![Screenshot 2024-09-07 at 2 08
39 PM](https://github.com/user-attachments/assets/841db9b7-1fd1-4964-aa57-58b479a255ff)

`uv pip install -e . --verbose`:

![Screenshot 2024-09-07 at 2 08
52 PM](https://github.com/user-attachments/assets/30b2817a-d4a3-4437-b47d-2bc037f5afa4)
2024-09-07 14:34:00 -04:00
Andrew Gallant
f6bc701ac3 uv-resolver: use new simplify/complexify marker routines
This finally gets rid of our hack for working around "hidden"
state. We no longer do a roundtrip marker serialization and
deserialization just to avoid the hidden state.
2024-09-07 13:46:02 -04:00
Andrew Gallant
2c139d6fca pep508: implement marker simplification/complexification
This adds new routines to `MarkerTree` for "simplifying" and
"complexifying" a tree with respect to lower and upper Python version
bounds.

In effect, "simplifying" a marker is what you do when you write it to a
lock file. Namely, since `uv.lock` includes a `requires-python` bound at
the top, one can say that it acts as a bound on the supported Python
versions. That is, it establishes a context in which one can assume that
bound is true. Therefore, the markers we write can be simplified using
this assumption.

The reverse is "complexifying" a marker, and it's what you do when you
read a marker from the lock file. Namely, once a marker is read, it can
be very difficult in code to keep the corresponding requires-python
context from the lock file. If you lose track of it and decide to
operate on the "simplified" marker, then it's trivial for that to
produce an incorrect result.
2024-09-07 13:46:02 -04:00
Andrew Gallant
8bb0a55ff5 pep508: remove hidden state from MarkerTree
I split this change into its own commit because I'm hoping it
crystalizes what it means when we say "a `MarkerTree` has hidden state."
That is, it isn't so much that there is some explicit member of a
`MarkerTree` that is omitted, but rather, the lower and upper version
bounds on `python_full_version` are are rewritten as "unbounded" when
traversing the ADD for display.

We will actually retain this functionality, but rejigger it so that it's
explicit when we do this. In particular, this simplification has been
problematic for us because it fundamentally changes the truth tables of
a marker expression *unless* you are extremely careful to interpret it
only under the original context in which it was simplified. This is
quite difficult to do generally, and in prior work in #6268, we
completed a refactor where we worked around this type of simplification
and moved it to the edges of uv.

In subsequent commits, we'll re-implement this form of simplification as
a more explicit step.
2024-09-07 13:46:02 -04:00
Charlie Marsh
a3e9610a54
Add build isolation logging to build operations (#7169)
## Summary

Closes https://github.com/astral-sh/uv/issues/7154.
2024-09-07 14:32:25 +00:00
Charlie Marsh
a178051e81
Bump version to v0.4.7 (#7150) 2024-09-07 02:18:15 +00:00
Charlie Marsh
6179b65e37
Avoid removing entries during read_dir (#7151)
I think this is the source of the test flakiness.
2024-09-07 02:10:28 +00:00
Charlie Marsh
7d49fbc753
Skip metadata fetch for --no-deps and pip sync (#7127)
## Summary

I think a better tradeoff here is to skip fetching metadata, even though
we can't validate the extras.

It will help with situations like
https://github.com/astral-sh/uv/issues/5073#issuecomment-2334235588 in
which, otherwise, we have to download the wheels twice.
2024-09-06 21:26:28 -04:00
Janosh Riebesell
e96eb946f9
Fix typo aaarch64->aarch64 (#7141)
copy pasted `--python-platform aaarch64-unknown-linux-gnu` [from the
docs](https://docs.astral.sh/uv/reference/cli/#uv-pip-compile) and got

> error: invalid value 'aaarch64-unknown-linux-gnu' for
'--python-platform <PYTHON_PLATFORM>'
> [possible values: windows, linux, macos, x86_64-pc-windows-msvc,
i686-pc-windows-msvc, x86_64-unknown-linux-gnu, aarch64-apple-darwin,
x86_64-apple-darwin, aarch64-unknown-linux-gnu,
aarch64-unknown-linux-musl, x86_64-unknown-linux-musl,
x86_64-manylinux_2_17, x86_64-manylinux_2_28, x86_64-manylinux_2_31,
aarch64-manylinux_2_17, aarch64-manylinux_2_28, aarch64-manylinux_2_31]
> 
>   tip: a similar value exists: 'aarch64-unknown-linux-gnu'
2024-09-06 23:25:46 +00:00
Zanie Blue
8eff8aab0b
Avoid panicking when encountering an invalid Python version during uv python list (#7131)
Closes https://github.com/astral-sh/uv/issues/7129

Not entirely sure about the best approach yet.
2024-09-06 19:23:16 -04:00
Charlie Marsh
8a0e1fde33
Write trailing newline to .python-version files (#7140)
## Summary

Closes https://github.com/astral-sh/uv/issues/7135.
2024-09-06 18:03:52 -04:00
Amos Wenger
5e1b9b1964
chore: Remove dep on derivative (#7133)
(This is part of #5711)

## Summary

@BurntSushi and I spotted that the `derivative` crate is only used for
one enum in the entire codebase — however, it's a proc macro, and we pay
for the cost of (re)compiling it in many different contexts.

This replaces it with a private `Inner` core which uses the regular std
derive macros — inlining and optimizations should make this equivalent
to the other implementation, and not too hard to maintain hopefully
(versus a manual impl of `PartialEq` and `Hash` which have to be kept in
sync.)

## Test Plan

Trust CI?
2024-09-06 17:46:56 -04:00
Ibraheem Ahmed
22c0be6664 pep508: add graph debug representation for MarkerTree
This PR revives #6129, but is less bold:

* It doesn't rename anything. (I think the rename is probably right
  though.)
* It doesn't change the _default_ `Debug` impl. Instead, it offers this
  as a new `MarkerTree::debug_graph` method.

I found this pretty useful for debugging since it gives a display format
that is more faithful to the internal representation of a `MarkerTree`.
So I think it's worth having around. But making it available in `Debug`
is perhaps a bridge too far since it isn't as familiar as the typical
PEP 508 representation and isn't as succinct.

I did consider printing this when using `{:#?}` (i.e., the "alternate"
debug representation), but too many things use that (like `insta` I
think) to make it practical.

Closes #6129
2024-09-06 16:47:51 -04:00
Charlie Marsh
72b73a506b
Add distinctive logging for cache prune phases (#7114) 2024-09-05 23:09:29 -04:00
Charlie Marsh
93fe3e83be
Prune unused source distributions from the cache (#7112)
## Summary

This has bothered me for a while and should be fairly impactful for
users. It requires a weird implementation, since the
distribution-building crate depends on the cache, and so the prune
operation can't live in the cache, since it needs to access internals of
the distribution-building crate.

Closes https://github.com/astral-sh/uv/issues/7096.
2024-09-05 21:40:51 -04:00
Zanie Blue
1422e18674
Fixup comment for export --output-file (#7111) 2024-09-05 20:18:39 -05:00