Commit graph

4903 commits

Author SHA1 Message Date
Jo
bb0fb8e9bf
uv run supports python zipapp (#7289)
## Summary

`python` supports running a zipfile containing a `__main__.py` file, for
example `python ./pre-commit-3.8.0.pyz`.

See https://docs.python.org/3/using/cmdline.html#interface-options:

> <script> Execute the Python code contained in script, which must be a
filesystem path (absolute or relative) referring to either a Python
file, a directory containing a __main__.py file, or a zipfile containing
a __main__.py file.

and https://docs.python.org/3/library/zipapp.html.

Similar to #7281, this PR allows `uv run ./pre-commit-3.8.0.pyz` to
work.

## Test Plan

```console
$ curl -O https://github.com/pre-commit/pre-commit/releases/download/v3.8.0/pre-commit-3.8.0.pyz
$ cargo run -- run ./pre-commit-3.8.0.pyz
```
2024-09-11 14:34:29 -05:00
Zanie Blue
b05217e624
Show verbose output during system install in test (#7304)
We do this for the other installs and it is helpful for debugging

This is missing in
3001185524
2024-09-11 14:31:51 -05:00
Charlie Marsh
58a157a0ad
Support globs as cache keys in tool.uv.cache-keys (#7268)
## Summary

This has been asked for a few times. There are risks that these checks
could be slow, but they're buyer-beware.

Closes https://github.com/astral-sh/uv/issues/7246.
2024-09-11 15:30:59 -04:00
Zanie Blue
d7ec546e71
Add Python 3.13 system test for Linux (#7302)
Previously we only had coverage on Windows

e.g. for more test coverage in cases like
https://github.com/astral-sh/uv/pull/7300#discussion_r1755343870

I picked Linux over macOS because the 3.13 prereleases are not available
via HomeBrew?
2024-09-11 14:25:09 -05:00
Charlie Marsh
1a3ec9d04f
Avoid enforcing platform compatibility when validating lockfile (#7305)
## Summary

We have to call `to_dist` to get metadata while validating the lockfile,
but some of the distributions won't match the current platform -- and
that's fine!
2024-09-11 19:17:07 +00:00
Charlie Marsh
575eb65a20
Avoid treating .whl sources as source distributions (#7303)
## Summary

The error messages here are incorrect.

Closes https://github.com/astral-sh/uv/issues/7284.
2024-09-11 15:10:04 -04:00
Charlie Marsh
cafc1f986a
Support relative paths in uv add --script (#7301)
## Summary

Closes https://github.com/astral-sh/uv/issues/7292.
2024-09-11 14:36:41 -04:00
Charlie Marsh
15792a3775
Apply --no-install options when constructing resolution (#7277)
## Summary

We need to apply the `--no-install` filters earlier, such that we don't
error if we only have a source distribution for a given package when
`--no-build` is provided but that package is _omitted_.

Closes #7247.
2024-09-11 14:31:24 -04:00
Tom
7021b15a42
Fix PPC64 page size in binary builds. (#7298)
## Summary

Add maturin build flag to set 64kb page size on PPC64 and PPC64LE
architectures. Not aware of modern systems that use 4kb pages.

Resolves #6528

## Test Plan

ppc64le gnu dynamic-linked and musl static-linked binary builds were
tested successfully on an IBM Power9 system running RHEL 8.8. I do not
have access to other types of PPC64 systems for testing.
2024-09-11 14:13:49 -04:00
Jo
38c7c5fdd1
uv run supports python package (#7281)
## Summary

Allow `uv run ./package` runs a Python package with a `__main__.py`
script.

Resolves #7275
2024-09-11 08:18:00 -05:00
Zanie Blue
77d278f68a
Avoid selecting pre-releases for Python downloads without a version request (#7278)
Following #7263 the 3.13.0rc2 releases are at the top of the download
list but we should not select them unless 3.13 is actually requested.

Prior to this, `uv python install` would install `3.13.0rc2`. 

```
❯ cargo run -- python install --no-config
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s
     Running `target/debug/uv python install --no-config`
Searching for Python installations
Installed Python 3.12.6 in 1.33s
 + cpython-3.12.6-macos-aarch64-none
```

```
❯ cargo run -- python install --no-config 3.13
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s
     Running `target/debug/uv python install --no-config 3.13`
Searching for Python versions matching: Python 3.13
Installed Python 3.13.0rc2 in 1.18s
 + cpython-3.13.0rc2-macos-aarch64-none
```
2024-09-10 22:20:18 +00:00
Zanie Blue
f5891e3296
Bump version to 0.4.9 (#7274) 2024-09-10 16:44:39 -05:00
Charlie Marsh
3f011f3b7b
Add uv run --no-sync (#7192)
## Summary

When `--no-sync` is provided, we won't lock or sync, but we will run the
command in the project environment.

Closes https://github.com/astral-sh/uv/issues/7165.
2024-09-10 17:29:43 -04:00
Michał Górny
4b7fed84eb
Replace tokio-tar with krata-tokio-tar fork (#7271)
## Summary

Replace the unmaintained `tokio-tar` crate with the `krata-tokio-tar`
fork. The latter just merged a fix necessary for the crate to work on
PowerPC, and has better chances of future maintenance.

Fixes #3423

## Test Plan

`cargo test`
2024-09-10 17:28:53 -04:00
Ibraheem Ahmed
cc3259be5f
Revert Cargo.lock changes (#7276)
## Summary

Reverts accidental changes in https://github.com/astral-sh/uv/pull/5927.
2024-09-10 21:20:50 +00:00
Zanie Blue
b5cc913d5c
Create py.typed files during uv init --lib (#7232) 2024-09-10 15:16:00 -05:00
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
Vivien Maisonneuve
e87d8e719d
Fix typo in docs: cache-key -> cache-keys (#7244)
## Summary

The new entry is `tool.uv.cache-keys` (with an `s`), not
`tool.uv.cache-key`.
2024-09-10 09:25:25 -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
renovate[bot]
4979d84e5d
Update pre-commit dependencies (#7205) 2024-09-09 00:46:19 +00:00
renovate[bot]
ee74d74605
Update peter-evans/create-pull-request action to v7 (#7206) 2024-09-08 20:37:18 -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
Soof Golan
bf33a7cf13
ignore macOS .DS_Store files (#7200)
Just ignoring macOS generated files. 

Would respectfully accept that would might not be merged.
2024-09-08 21:29:18 +00:00