Commit Graph

5352 Commits

Author SHA1 Message Date
Charlie Marsh 359ef288f8
Upgrade to the latest Ruff version (#10433) 2025-01-09 10:47:25 -05:00
Charlie Marsh 15ec830bea
Use `matches` rather than `contains` in `requirements.txt` parsing (#10423) 2025-01-09 02:32:09 +00:00
Charlie Marsh 58a81f7c47
Add `uv lock --script` to the docs (#10414) 2025-01-08 19:33:55 -05:00
Charlie Marsh 5551f9f3da
Remove unnecessary `.to_string()` call (#10419) 2025-01-08 23:59:13 +00:00
Charlie Marsh f65fcf23b3
Remove duplicated comment (#10416) 2025-01-08 23:06:09 +00:00
Charlie Marsh 2e0d7429ef
Add Lambda layer instructions to AWS Lambda guide (#10411)
## Summary

Closes https://github.com/astral-sh/uv/issues/10406.
2025-01-08 22:12:52 +00:00
Charlie Marsh 53dd554919
Update PEP 723 lockfile in `uv remove --script` (#10162)
## Summary

Counterpart to #10145 covering `uv remove` for PEP 723 scripts with
lockfiles.
2025-01-08 22:05:37 +00:00
Charlie Marsh 18b53c5b45
Add `--script` support to `uv export` for PEP 723 scripts (#10160)
## Summary

You can now run `uv export --script main.py` to show the dependency tree
for a given script. If a lockfile doesn't exist, it will create one.

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

Closes https://github.com/astral-sh/uv/issues/9657.
2025-01-08 21:48:53 +00:00
Charlie Marsh 9d5779b68c
Add `--script` support to `uv tree` for PEP 723 scripts (#10159)
## Summary

You can now run `uv tree --script main.py` to show the dependency tree
for a given script. If a lockfile doesn't exist, it will create one.

Closes https://github.com/astral-sh/uv/issues/7328.
2025-01-08 21:32:46 +00:00
Charlie Marsh 31b2d3f988
Update PEP 723 lockfile in `uv add --script` (#10145)
## Summary

`uv add --script main.py anyio` will now update the lockfile, _if_ it
already exists. (If no such lockfile exists, the behavior is unchanged.)
2025-01-08 21:19:12 +00:00
Charlie Marsh e22b728e3f
Respect PEP 723 script lockfiles in uv run (#10136)
## Summary

If a script has a lockfile, then `uv run` will now reuse it.

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

Closes https://github.com/astral-sh/uv/issues/9688.
2025-01-08 20:34:45 +00:00
Burak Varlı 391ab757b8
Add `ls` alias to `uv {tool, python, pip} list` (#10240)
## Summary

This PR adds `ls` alias to `uv {tool, python, pip} list` for
convenience.

Not sure if folks previously discussed this or have any opinion on
having aliases – but I have a muscle memory for `ls` for listing things
in commands I'm using (like `docker images ls`, `zellij ls`, `helm ls`
etc.) and thought having `ls` alias for `list` command would be useful.

## Test Plan

I simply compiled `uv` and manually checked `./target/release/uv {tool,
python, pip} ls`.
2025-01-08 14:09:20 -05:00
Zanie Blue 68bfa5b5b8
Avoid Docker rate limits by logging into DockerHub (#10400)
The latest release flaked failing to fetch the buildx image, which is
reportedly due to rate limits. Last I checked, DockerHub enforces much
stricter limits on unauthenticated requests. I added a bot account and a
corresponding read-only token.
2025-01-08 18:46:24 +00:00
renovate[bot] ad09070dd7
Update Rust crate petgraph to 0.7.1 (#10317) 2025-01-08 18:39:26 +00:00
Charlie Marsh 5d33b94c42
Add support for locking PEP 723 scripts (#10135)
## Summary

You can now run `uv lock --script main.py` to lock a given script
(though as of this PR, the script itself isn't used anywhere).

Closes https://github.com/astral-sh/uv/issues/6318.
2025-01-08 18:36:53 +00:00
Aria Desires 2f7f9ea571
improve shell compatibility of venv activate scripts (#10397)
The shellcheck action we uses misses some files, so they fell out of
spec for what we support. This PR first and foremost adds them to the
scanning list, and then fixes the issues found.

Fixes #7480
2025-01-08 13:12:29 -05:00
Charlie Marsh 4c161d284b
Respect `requires-python` when installing tools (#10401)
## Summary

This PR revives https://github.com/astral-sh/uv/pull/7827 to improve
tool resolutions such that, if the resolution fails, and the selected
interpreter doesn't match the required Python version from the solve, we
attempt to re-solve with a newly-discovered interpreter that _does_
match the required Python version.

For now, we attempt to choose a Python interpreter that's greater than
the inferred `requires-python`, but compatible with the same Python
minor. This helps avoid successive failures for cases like Posting,
where choosing Python 3.13 fails because it has a dependency that lacks
source distributions and doesn't publish any Python 3.13 wheels. We
should further improve the strategy to solve _that_ case too, but this
is at least the more conservative option...

In short, if you do `uv tool instal posting`, and we find Python 3.8 on
your machine, we'll detect that `requires-python: >=3.11`, then search
for the latest Python 3.11 interpreter and re-resolve.

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

## Test Plan

The following should succeed:

```
cargo run python uninstall --all
cargo run python install 3.8
cargo run tool install posting
```

In the logs, we see:

```
...
DEBUG No compatible version found for: posting
DEBUG Refining interpreter with: Python >=3.11, <3.12
DEBUG Searching for Python >=3.11, <3.12 in managed installations or search path
DEBUG Searching for managed installations at `/Users/crmarsh/.local/share/uv/python`
DEBUG Skipping incompatible managed installation `cpython-3.8.20-macos-aarch64-none`
DEBUG Found `cpython-3.13.1-macos-aarch64-none` at `/opt/homebrew/bin/python3` (search path)
DEBUG Skipping interpreter at `/opt/homebrew/opt/python@3.13/bin/python3.13` from search path: does not satisfy request `>=3.11, <3.12`
DEBUG Found `cpython-3.11.7-macos-aarch64-none` at `/opt/homebrew/bin/python3.11` (search path)
DEBUG Re-resolving with Python 3.11.7
DEBUG Using request timeout of 30s
DEBUG Solving with installed Python version: 3.11.7
DEBUG Solving with target Python version: >=3.11.7
DEBUG Adding direct dependency: posting*
DEBUG Searching for a compatible version of posting (*)
...
```
2025-01-08 12:38:17 -05:00
Charlie Marsh 333f03f112
Bump version to v0.5.16 (#10395) 2025-01-08 10:29:32 -05:00
konsti c5583b326f
Shrink `Dist` from 352 to 288 bytes (#10389)
Found this when looking at #10385. Since we're constructing a lot of
`Dist`s, we should keep it small.
2025-01-08 09:33:19 -05:00
konsti 15c81e9a02
Force a niche into `VersionSmall` (#10385) 2025-01-08 14:33:39 +01:00
konsti 68adadf806
Improve file pinning comments (#10387) 2025-01-08 11:42:25 +00:00
konsti fa305bd244
Fix `invalid_platform` test on main (#10388)
This test started failing on main.

I don't understand why this changed (there was a new release but exclude-newer is supposed to exclude those), but the error message improved.
2025-01-08 10:55:06 +00:00
Charlie Marsh 4c0922ee1b
Add AWS Lambda integration guide (#10278)
## Summary

This includes instructions to:

- Deploy a standalone application.
- Deploy an application that depends on local libraries (a workspace).
- Deploy via Docker.
- Deploy via zip.

There's an accompanying Git repository here:
https://github.com/astral-sh/uv-aws-lambda-example.

Closes https://github.com/astral-sh/uv/issues/8935.
2025-01-07 13:50:31 -05:00
Charlie Marsh 1ee17afd79
Avoid enforcing project-level required version for `uv self` (#10374)
## Summary

Closes https://github.com/astral-sh/uv/issues/10355.
2025-01-07 13:17:42 -05:00
Charlie Marsh 2ae0ed3b35
Re-enable zlib-ng on all platforms (except s390x, PowerPC, and FreeBSD) (#10370)
PowerPC seems to build without errors if we upgrade `zlib-ng`, but
upgrading `zlib-ng` causes Windows to break
(https://github.com/rust-lang/libz-sys/issues/225), and Cargo doesn't
let us include two different versions.

s390x fails because it can't find `stfle`. It's possible that we could
fix this by by upgrading our manylinux version and/or by upgrading GCC
(which may necessitate upgrading our manylinux version), but I don't
know if it's fixable without one of those things? And it's not worth
bumping compatibility for that reason. \cc @konstin
2025-01-07 13:04:34 -05:00
Kevin Marchais a2a2662d43
Fix ruff linting warnings from generated template files for extension modules (#10371)
## Summary

This PR fixes two ruff linting issues in the generated template files
when using: `uv init --build-backend` for extension modules.

1. Removes unnecessary `from __future__ import annotations` imports from
generated .pyi files
([PYI044](https://docs.astral.sh/ruff/rules/future-annotations-in-stub/))
2. Adds missing blank line after `hello_from_bin` import to comply with
isort formatting
([I001](https://docs.astral.sh/ruff/rules/unsorted-imports/))

## Test Plan

```bash
cargo run -- init --build-backend scikit-build-core example-ext
uvx ruff check example-ext --select ALL

cargo run -- init --build-backend maturin example-ext
uvx ruff check example-ext --select ALL
```

## Remaining warnings

There are still warnings remainings in the generated `__init__.py`
files:
- [D104](https://docs.astral.sh/ruff/rules/undocumented-public-package/)
Missing docstring in public package
-
[D103](https://docs.astral.sh/ruff/rules/undocumented-public-function/)
Missing docstring in public function
- [T201](https://docs.astral.sh/ruff/rules/print/) `print` found
2025-01-07 17:07:44 +00:00
Charlie Marsh c8b3e8523c
Re-enable `zlib-ng` on x86 platforms (#10365)
## Summary

Closes https://github.com/astral-sh/uv/issues/10363.
2025-01-07 11:00:32 -05:00
Andrew Gallant 043bdcec8b
uv-pep440: fix bad merge (#10368)
This happened as a result of #10345 and #10362 being merged
independently. The latter used the old `Version::release` API, but the
former changed the `Version::release` API. This PR tweaks the new test
to use the new API (i.e., force a deref on the proxy type).
2025-01-07 15:11:41 +00:00
konsti 373e34f5dd
Remove `[u64; 4]` from small version to move `Arc` to full version (#10345) 2025-01-07 14:25:32 +00:00
Andrew Gallant fb29445999
uv-pep440: adds an explicit test for trailing zeros (#10362)
Basically, this explicitly checks that parsing a `1.2.0` into a
`Version` will roundtrip back to a `1.2.0`, and that parsing a `1.2`
will roundtrip back to a `1.2`.

I think this case is included in the other tests in this module, but
this test makes the behavior more clearly intentional I think.

Ref #10345
2025-01-07 14:16:23 +00:00
konsti 14a9008e54
Avoid overcounting versions in batch prefetcher (#10350) 2025-01-07 14:12:18 +00:00
konsti 3cbf8ab7b1
Optimize `requirements_for_extra` (#10348) 2025-01-07 14:12:12 +00:00
konsti c6ac121ed0
Refactor batch prefetch (#10349) 2025-01-07 14:58:36 +01:00
konsti 3dc481b063
Speed up file pins (#10346)
Ref https://github.com/astral-sh/uv/issues/10344

Avoid the nested hashmap, file pinning is called in the version
selection hot loop.

```
$ hyperfine --warmup 1 --prepare "uv venv -p 3.12" "./uv-2 pip compile scripts/requirements/airflow.in" "./uv-1 pip compile scripts/requirements/airflow.in"
    Finished `profiling` profile [optimized + debuginfo] target(s) in 0.12s
Benchmark 1: ./uv-2 pip compile scripts/requirements/airflow.in
  Time (mean ± σ):     420.1 ms ±   4.7 ms    [User: 585.4 ms, System: 195.1 ms]
  Range (min … max):   413.1 ms … 429.2 ms    10 runs

Benchmark 2: ./uv-1 pip compile scripts/requirements/airflow.in
  Time (mean ± σ):     473.0 ms ±   4.9 ms    [User: 654.4 ms, System: 209.4 ms]
  Range (min … max):   468.0 ms … 481.1 ms    10 runs

Summary
  ./uv-2 pip compile scripts/requirements/airflow.in ran
    1.13 ± 0.02 times faster than ./uv-1 pip compile scripts/requirements/airflow.in
```
2025-01-07 08:51:08 -05:00
konsti d8fcf2a58f
Simplify `requirements_for_extra` (#10347)
Ref https://github.com/astral-sh/uv/issues/10344

Not a performance optimization, but the function had become too large.
No logic changes, just code moving around. Looks slightly better when
ignoring whitespace changes.

It's still too complex but i haven't found an apt simplification.
2025-01-07 08:50:13 -05:00
Charlie Marsh 0fcccb8994
Accept requirements in `uv remove` (#10338)
## Summary

This allows, e.g., `uv remove flask[dotenv]` to remove `flask`. Like
`pip install` and `uv pip install`, the content after the package name
has no effect.

Closes https://github.com/astral-sh/uv/issues/9764.
2025-01-07 08:47:05 -05:00
csteiner 788df24460
docs: github actions example: remove unneeded install step (#10356)
* Previously had uv python install, then uv sync --all-extras --dev
* If we are going to use sync for dev dependencies, then the install
step is unneccessary

<!--
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? -->

## Test Plan

<!-- How was it tested? -->
2025-01-07 08:46:44 -05:00
Andrew Tulloch 671e93816a
Buffer file reads in `serde_json::from_reader` (#10341)
<!--
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

https://docs.rs/serde_json/latest/serde_json/fn.from_reader.html
suggests that

> When reading from a source against which short reads are not
efficient, such as a
[File](https://doc.rust-lang.org/std/fs/struct.File.html), you will want
to apply your own buffering because serde_json will not buffer the
input. See
[std::io::BufReader](https://doc.rust-lang.org/std/io/struct.BufReader.html).

Without this buffering, we observe a sequence of single byte reads which
can be quite inefficient depending on the underlying filesystem.

This adds buffering with `std::io::BufReader` to resolve this.


<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan

Unit tests cover this code.

<!-- How was it tested? -->
2025-01-07 08:02:33 -05:00
konsti a1a4d820d5
Add `Send + 'static` bounds to cache deserialization (#10352) 2025-01-07 09:55:37 +00:00
konsti 180a138161
Deactivate tracing for choose version (#10351) 2025-01-07 09:55:06 +00:00
Zanie Blue eb6ad9a4fa
Bump version to 0.5.15 (#10337) 2025-01-06 18:04:25 -06:00
Charlie Marsh 0d57d298e6
Avoid downgrading packages when `--upgrade` is provided (#10097)
## Summary

When `--upgrade` is provided, we should retain already-installed
packages _if_ they're newer than whatever is available from the
registry.

Closes https://github.com/astral-sh/uv/issues/10089.
2025-01-06 17:41:43 -05:00
github-actions[bot] eaaf8896ed
Sync latest Python releases (#10333)
Automated update for Python releases.

---------

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-01-06 13:19:35 -06:00
Olav Rønnestad Birkeland 1b34859d7e
docs: installation.md add info about installing with Scoop (#10332)
<!--
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

Add info about uv being available in Scoop.

## Test Plan

`uvx --with-requirements .\docs\requirements.txt mkdocs serve
--config-file mkdocs.public.yml` worked.
2025-01-06 13:18:01 -06:00
Charlie Marsh 09de67039b
Tweak script `--no-project` comment (#10331) 2025-01-06 13:41:44 -05:00
Charlie Marsh 243d2f8d5d
Redact new index credentials in `uv add` (#10329)
## Summary

Closes https://github.com/astral-sh/uv/issues/10328.
2025-01-06 17:24:05 +00:00
Charlie Marsh 66a603b6c4
Use dynamic dispatch to simplify reporters (#10086)
## Summary

Sort of undecided on this. These are already stored as `dyn Reporter` in
each struct, so we're already using dynamic dispatch in that sense. But
all the methods take `impl Reporter`. This is sometimes nice (the
callsites are simpler?), but it also means that in practice, you often
_can't_ pass `None` to these methods that accept `Option<impl
Reporter>`, because Rust can't infer the generic type.

Anyway, this adds more consistency and simplifies the setup by using
`Arc<dyn Reporter>` everywhere.
2025-01-06 12:04:00 -05:00
Trevor Manz 54b9e8ff82
Clarify exclude-newer only allows full timestamps in settings docs (#9135)
<!--
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

Follow up to #8553

Clarifies that the `exclude-newer` setting must be a full timestamp and
not a date.

<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan

N/A

<!-- How was it tested? -->
2025-01-06 10:03:21 -05:00
vladislav doster 523b88edf0
docs(tools.md): remove hyphenation for consistency (#10321) 2025-01-06 09:33:46 -05:00
vladislav doster 27bc8dd3dc
docs(python-versions.md): fix spelling (#10322)
## Summary

Correct misspelling of `interopability` to `interoperability`.

## Test Plan

N/A
2025-01-06 07:41:48 +00:00