Commit Graph

3635 Commits

Author SHA1 Message Date
Zanie Blue 4dd36b799f
Install versioned Python executables into the bin directory during `uv python install` (#8458)
Updates `uv python install` to link `python3.x` in the executable
directory (i.e., `~/.local/bin`) to the the managed interpreter path.

Includes

- #8569 
- #8571 

Remaining work

- #8663 
- #8650 
- Add an opt-out setting and flag
- Update documentation
2024-10-30 14:13:20 +00:00
konsti 94fc35edd9
Fix feature scoping for pep508 wasm32 support for ruff (#8694) 2024-10-30 12:21:23 +00:00
konsti c1a0fb35e8
Simplify pep440 -> version ranges conversion (#8683) 2024-10-30 13:10:48 +01:00
konsti d0afd10ca4
Update windows-registry to 0.3.0 (#8696) 2024-10-30 12:00:33 +00:00
konsti 4bf01ed337
Fix non-optional uv-pep440 features (#8693) 2024-10-30 09:20:56 +00:00
Pietro Zambelli 2b0e16cb75
Fix hard and soft float libc detection for managed Python distributions on ARM (#8498) 2024-10-29 23:46:21 +00:00
Zanie Blue 6d3de9a104
Sort errors during display in `uv python install` (#8684)
This is important for determinism
2024-10-29 22:40:39 +00:00
Charlie Marsh 2e14724224
Handle cycles in `uv pip tree` (#8689)
## Summary

Porting the improvements I made to `uv tree` over to `uv pip tree`.

Closes #8678.
2024-10-29 22:18:46 +00:00
Charlie Marsh cd408cbc51
Clarify relationship between specifiers and `requires-python` range (#8688) 2024-10-29 22:30:01 +01:00
Charlie Marsh dc5e35ee5d
Fix outdated documentation on `Requires-Python` (#8679)
## Summary

Closes https://github.com/astral-sh/uv/issues/8675.
2024-10-29 20:18:43 +00:00
konsti e5b8cdba70
Merge uv-pubgrub into uv-pep440 (#8669) 2024-10-29 20:15:18 +01:00
Charlie Marsh f903cd2cce
Simplify `pip tree` tests to improve performance (#8677)
## Summary

These use really heavy test packages, like SciPy, NumPy, scikit-learn --
and packages with large dependency trees, like packse.

I removed a few redundant tests, and replaced the tests with smaller
packages.

Closes https://github.com/astral-sh/uv/issues/8674.
2024-10-29 14:59:26 -04:00
Charlie Marsh ab00a82881
Fix flaky failure in `run_from_directory` (#8673)
## Summary

See, e.g.,
https://github.com/astral-sh/uv/actions/runs/11578473249/job/32232394993.

I suspect this is some sort of timing flakiness in the cache, so let's
just clear the environment for each run.
2024-10-29 17:44:59 +00:00
Andrew Gallant 9fcc21236e
uv-resolver: simplify case analysis in ForkMap::get (#8672)
Previously, when doing a `uv pip` resolution, we would only return the
first entry in the map. But there should only ever be one entry, or else
we would have incompatible dependencies. So we can collapse the case
with the "one universal fork" case.

(I found this while doing some refactoring of how we handle forking, and
collapsing these cases simplifies some of that refactoring work.)
2024-10-29 13:38:21 -04:00
Andrew Gallant e9d962ef36
uv/tests: try harder to isolate tests from parent git repositories (#8668)
Previously, when tests were run in `~/.local/share/uv`, the behavior of
some tests could be impacted by a git repository in `~` (as on my
system). To avoid this, we set `GIT_CEILING_DIRECTORIES` to forcefully
prevent git from climbing out of its test directory to look for parent
git repositories.
2024-10-29 13:16:02 -04:00
konsti 36102dbd0e
Start using the version ranges crate (#8667) 2024-10-29 16:39:50 +00:00
Andrew Gallant a56e521179
uv-resolver: use disjointness checks instead of marker equality (#8661)
When this code was written, we didn't have "proper" disjointness checks,
and so simple equality was used instead. Arguably disjointness checks
are
more correct, and this would also simplify some case analysis in an
ongoing
refactor.
2024-10-29 11:25:18 -04:00
Zanie Blue c335dc5e5d
Add a trampoline variant that just executes `python` (#8637)
Currently, our trampoline is used to convert `<command> [args]` to
`python <command> [args]` for script entrypoints installed into virtual
environments. For #8458, it'd be nice to convert a shim `python3.12
[args]` to `python [args]`. Here, we modify the trampolines to support
this use-case.

The only change we really need here is to avoid injecting `<command>`
into the child process. We change the "magic number" at the end of the
trampoline executables from `UVUV` to `UVSC` and `UVPY` which define
"script" and "python" variants to the trampoline. We then omit the
`<command>` injection in the latter case. We also omit writing the zip
script payload.

To support construction of the new variant, a new
`uv-trampoline-builder` crate is introduced — this avoids requirements
on `uv-install-wheel` in future work. I also use `uv-trampoline-builder`
to consolidate some of the test setup for `uv-trampoline`.

There should be no backwards compatibility concerns, since trampolines
are fully self-referential.

I rebased to fix the commits at the end, as this took many iterations to
get working via CI. This should roughly be reviewable by commit if you
prefer.
2024-10-29 09:21:15 -05:00
Zanie Blue 94ae79d90d
Add riscv64 to supported Python platform tags (#8660)
Closes #8657
2024-10-29 08:48:19 -05:00
Jo d9ea307615
uv init: `--virtual` should imply `--no-package` instead (#8595)
## Summary

`uv init --virtual` should create a non-package project.
2024-10-29 09:42:14 -04:00
Charlie Marsh bf14b6a282
Respect dependency group markers in `uv export` (#8659)
## Summary

Closes https://github.com/astral-sh/uv/issues/8658.
2024-10-29 13:41:27 +00:00
konsti 9fa4fea8f2
Fix tests on main (#8655) 2024-10-29 10:46:54 +00:00
Charlie Marsh debe67ffdb
Use `dev-dependencies` and `requires-dev` for lockfile compatibility (#8599)
## Summary

Unfortunately, it looks like we lost
https://github.com/astral-sh/uv/pull/8501 somewhere in a bad rebase.
This PR re-adds the change, with compatibility for those lockfiles
created in v0.4.27. I'm not certain we should actually merge this. It
might be less painful and confusing to just bite the bullet on the
change.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-10-28 22:08:33 +00:00
Zanie Blue 4c82561488
Bump version to 0.4.28 (#8648) 2024-10-28 16:38:59 -05:00
Zanie Blue dc23a60277
Add support for requesting free-threaded builds via `+freethreaded` (#8645)
e.g., `uv python install 3.13+freethreaded` which matches the
distribution keys.
2024-10-28 15:22:49 -05:00
konsti 0044000ed3
Better trusted publishing error story (#8633) 2024-10-28 21:13:43 +01:00
Zanie Blue 18c9bc1e70
Add note about local version segments (#8646) 2024-10-28 19:52:40 +00:00
Charlie Marsh 9e851c116f
Skip Python interpreter discovery for `uv export` (#8638)
## Summary

We can skip interpreter discovery with `--frozen` in a few cases: `uv
export`, `uv tree --universal`, etc.

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

## Test Plan

Before:

```
❯ uv export --python-preference only-managed --no-python-downloads
error: No interpreter found for Python 3.12 in managed installations
```

After:

```
❯ cargo run export --python-preference only-managed --no-python-downloads --frozen
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.16s
     Running `/Users/crmarsh/workspace/uv/target/debug/uv export --python-preference only-managed --no-python-downloads --frozen`
# This file was autogenerated by uv via the following command:
#    uv export --python-preference only-managed --no-python-downloads --frozen
blinker==1.8.2 \
    --hash=sha256:8f77b09d3bf7c795e969e9486f39c2c5e9c39d4ee07424be2bc594ece9642d83 \
    --hash=sha256:1779309f71bf239144b9399d06ae925637cf6634cf6bd131104184531bf67c01
click==8.1.7 \
    --hash=sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de \
    --hash=sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28
colorama==0.4.6 ; platform_system == 'Windows' \
    --hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
    --hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
flask==3.0.3 \
    --hash=sha256:ceb27b0af3823ea2737928a4d99d125a06175b8512c445cbd9a9ce200ef76842 \
    --hash=sha256:34e815dfaa43340d1d15a5c3a02b8476004037eb4840b34910c6e21679d288f3
itsdangerous==2.2.0 \
    --hash=sha256:e0050c0b7da1eea53ffaf149c0cfbb5c6e2e2b69c4bef22c81fa6eb73e5f6173 \
    --hash=sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef
jinja2==3.1.4 \
    --hash=sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369 \
    --hash=sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d
markupsafe==3.0.2 \
    --hash=sha256:ee55d3edf80167e48ea11a923c7386f4669df67d7994554387f84e7d8b0a2bf0 \
    --hash=sha256:9778bd8ab0a994ebf6f84c2b949e65736d5575320a17ae8984a77fab08db94cf \
    --hash=sha256:846ade7b71e3536c4e56b386c2a47adf5741d2d8b94ec9dc3e92e5e1ee1e2225 \
    --hash=sha256:1c99d261bd2d5f6b59325c92c73df481e05e57f19837bdca8413b9eac4bd8028 \
    --hash=sha256:e17c96c14e19278594aa4841ec148115f9c7615a47382ecb6b82bd8fea3ab0c8 \
    --hash=sha256:88416bd1e65dcea10bc7569faacb2c20ce071dd1f87539ca2ab364bf6231393c \
    --hash=sha256:2181e67807fc2fa785d0592dc2d6206c019b9502410671cc905d132a92866557 \
    --hash=sha256:52305740fe773d09cffb16f8ed0427942901f00adedac82ec8b67752f58a1b22 \
    --hash=sha256:ad10d3ded218f1039f11a75f8091880239651b52e9bb592ca27de44eed242a48 \
    --hash=sha256:0f4ca02bea9a23221c0182836703cbf8930c5e9454bacce27e767509fa286a30 \
    --hash=sha256:8e06879fc22a25ca47312fbe7c8264eb0b662f6db27cb2d3bbbc74b1df4b9b87 \
    --hash=sha256:ba9527cdd4c926ed0760bc301f6728ef34d841f405abf9d4f959c478421e4efd \
    --hash=sha256:f8b3d067f2e40fe93e1ccdd6b2e1d16c43140e76f02fb1319a05cf2b79d99430 \
    --hash=sha256:569511d3b58c8791ab4c2e1285575265991e6d8f8700c7be0e88f86cb0672094 \
    --hash=sha256:15ab75ef81add55874e7ab7055e9c397312385bd9ced94920f2802310c930396 \
    --hash=sha256:f3818cb119498c0678015754eba762e0d61e5b52d34c8b13d770f0719f7b1d79 \
    --hash=sha256:cdb82a876c47801bb54a690c5ae105a46b392ac6099881cdfb9f6e95e4014c6a \
    --hash=sha256:cabc348d87e913db6ab4aa100f01b08f481097838bdddf7c7a84b7575b7309ca \
    --hash=sha256:444dcda765c8a838eaae23112db52f1efaf750daddb2d9ca300bcae1039adc5c \
    --hash=sha256:bcf3e58998965654fdaff38e58584d8937aa3096ab5354d493c77d1fdd66d7a1 \
    --hash=sha256:e6a2a455bd412959b57a172ce6328d2dd1f01cb2135efda2e4576e8a23fa3b0f \
    --hash=sha256:b5a6b3ada725cea8a5e634536b1b01c30bcdcd7f9c6fff4151548d5bf6b3a36c \
    --hash=sha256:a904af0a6162c73e3edcb969eeeb53a63ceeb5d8cf642fade7d39e7963a22ddb \
    --hash=sha256:4aa4e5faecf353ed117801a068ebab7b7e09ffb6e1d5e412dc852e0da018126c \
    --hash=sha256:c0ef13eaeee5b615fb07c9a7dadb38eac06a0608b41570d8ade51c56539e509d \
    --hash=sha256:d16a81a06776313e817c951135cf7340a3e91e8c1ff2fac444cfd75fffa04afe \
    --hash=sha256:6381026f158fdb7c72a168278597a5e3a5222e83ea18f543112b2662a9b699c5 \
    --hash=sha256:3d79d162e7be8f996986c064d1c7c817f6df3a77fe3d6859f6f9e7be4b8c213a \
    --hash=sha256:131a3c7689c85f5ad20f9f6fb1b866f402c445b220c19fe4308c0b147ccd2ad9 \
    --hash=sha256:ba8062ed2cf21c07a9e295d5b8a2a5ce678b913b45fdf68c32d95d6c1291e0b6 \
    --hash=sha256:e444a31f8db13eb18ada366ab3cf45fd4b31e4db1236a4448f68778c1d1a5a2f
werkzeug==3.0.6 \
    --hash=sha256:a8dd59d4de28ca70471a34cba79bed5f7ef2e036a76b3ab0835474246eb41f8d \
    --hash=sha256:1bc0c2310d2fbb07b1dd1105eba2f7af72f322e1e455f2f93c993bee8c8a5f17
```
2024-10-28 15:00:08 -04:00
Charlie Marsh bfa84cd1ab
Fork when minimum Python version increases (#8628)
## Summary

This is a re-implementation of
https://github.com/astral-sh/uv/pull/4712, though is now seemingly much
simpler. This issue keeps coming up, and users have a workaround with
`tool.uv.environments`, but it's really a bug in the resolver.

Closes https://github.com/astral-sh/uv/issues/4668.
2024-10-28 09:48:04 -04:00
konsti 635223ef00
Hint about missing trusted publishing permission (#8632) 2024-10-28 11:26:46 +00:00
Simon Willison 572840dfe2
Update CLI documentation for `--cache-dir` (#8627)
Refs:
- #8626

## Summary

Current documentation incorrectly suggests that the macOS cache
directory location is `$HOME/Library/Caches/uv`, but that changed in:

- #5806

Updates docs to say this instead:

> <p>Defaults to <code>$HOME/.cache/uv</code> on macOS,
<code>$XDG_CACHE_HOME/uv</code> or <code>$HOME/.cache/uv</code> on
Linux, and <code>%LOCALAPPDATA%\uv\cache</code> on Windows. The <code>uv
cache dir</code> command will show the location of the cache
directory.</p>

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-28 02:01:21 +00:00
renovate[bot] be92a2bbef
Update Rust crate thiserror to v1.0.65 (#8618) 2024-10-28 01:06:22 +00:00
renovate[bot] 0a83f957fb
Update Rust crate anyhow to v1.0.91 (#8612) 2024-10-27 20:56:33 -04:00
Charlie Marsh 001d00ba26
Remove inverse-node tracking in `uv tree` (#8610)
## Summary

Just simplifying some of the representations.
2024-10-27 20:44:32 -04:00
Tim Chan 4caa1586fd
feat: add environment variable to disable progress output (#8600)
The changes in this commit introduce the `UV_NO_PROGRESS` environment
variable as an alternative way to control progress output suppression in
uv-cli, equivalent to using the `--no-progress` flag. This enhancement
simplifies configuration in CI environments and automated scripts by
eliminating the need to detect whether the script is running in a CI
environment.

Previously, disabling progress output required either passing the
`--no-progress` flag directly or implementing script logic to detect CI
environments and conditionally add the flag. With this change, users can
now simply set `UV_NO_PROGRESS=true` in their environment to achieve the
same effect.

The changes include:

- Adding the `UV_NO_PROGRESS` environment variable to the `EnvVars`
struct in `crates/uv-static/src/env_vars.rs`.
- Updating the `GlobalArgs` struct in `crates/uv-cli/src/lib.rs` to
include a new `no_progress` field that is bound to the `UV_NO_PROGRESS`
environment variable.
- Adding documentation for the new `UV_NO_PROGRESS` environment variable
in `docs/configuration/environment.md`.
## Test Plan

After creating a uv project using `uv init` in a temp directory in this
project:
```
cargo run cache clean && cargo run venv && UV_NO_PROGRESS=false cargo run sync 
cargo run cache clean && cargo run venv && cargo run sync  
```
produce the expected default behavior 

```
cargo run cache clean && cargo run venv && UV_NO_PROGRESS=false cargo run sync  
```
produces the same behavior as having the `--no-progress` flag.
2024-10-27 15:14:12 -04:00
Vivien Maisonneuve 1e1b6ce186
Set `LC_ALL=C` in test commands (#8606) 2024-10-27 14:24:41 +00:00
Vivien Maisonneuve c648150ff0
Remove unneeded `return` from Maturin project template (#8604)
## Summary

This PR removes an unnecessary `return` statement from Rust code in the
Maturin template. This makes the generated code more idiomatic and
prevents a Clippy warning.

## Test Plan

This change was tested both in unit tests and by manually creating a
Maturin project.
2024-10-27 09:15:27 -05:00
Zanie Blue a09415f008
Fix Python install path in tests (#8578)
The shared arguments were resetting the `UV_PYTHON_INSTALL_DIR`,
breaking the intent of the test.

Added some uninstall tests too, needed later for #8571
2024-10-26 20:56:51 -05:00
Charlie Marsh f23d9c1a21
Support cyclic dependencies in `uv tree` (#8564)
## Summary

Closes https://github.com/astral-sh/uv/issues/8551.
2024-10-26 13:30:42 -04:00
Charlie Marsh 5ef0e6c838
Ignore empty groups when validating lock (#8598)
## Summary

It turns out we were omitting empty dependency groups from the lockfile
metadata, which was then causing us to reject locks when empty groups
were defined.

We now include them (that section of the lock is meant to be a true
representation of the metadata, and an empty-but-defined group is
different from an absent group), though we can ignore them for
validation, since it doesn't affect any behavior.

Closes https://github.com/astral-sh/uv/issues/8581.
2024-10-26 17:29:07 +00:00
Magnus Markling 084ad2ed2b
Remove duplicate word in error message (#8589)
## Summary

Remove duplicate word ("because" ) in error message.

## Test Plan

I ran all the tests locally.
2024-10-26 11:10:00 -05:00
Jo 0b02a8c28b
uv init: Implies `--package` when using `--build-backend` (#8593)
## Summary

Closes #8568
2024-10-26 09:51:16 -05:00
Charlie Marsh d362e03a81
Add more tests for non-`[project]` groups (#8575) 2024-10-25 19:08:29 +00:00
Charlie Marsh 36b729e927
Add error message when `uv build` is used with non-packaged projects (#8537)
## Summary

Closes https://github.com/astral-sh/uv/issues/8530.
2024-10-25 15:06:46 -04:00
Zanie Blue 4727acbc62
Bump version to 0.4.27 (#8573) 2024-10-25 19:06:06 +00:00
Charlie Marsh dd0f696695
Allow `[dependency-groups]` in non-`[project]` projects (#8574)
## Summary

We already support `tool.uv.dev-dependencies` in the legacy
non-`[project]` projects. This adds equivalent support for
`[dependency-groups]`, e.g.:

```toml
[tool.uv.workspace]

[dependency-groups]
lint = ["ruff"]
```
2024-10-25 13:57:06 -05:00
Zanie Blue 73544098f3 Add a few more test cases for `default-groups` (#8572) 2024-10-25 13:27:37 -05:00
Zanie Blue 8262e91e2f Update reference documentation for PEP 735 (#8567)
Updates the CLI and setting documentation to reflect the PEP 735
changes.
2024-10-25 13:27:37 -05:00
Charlie Marsh 07b6887c08 Add to `dependency-groups.dev` in `uv add --dev` (#8570)
## Summary

`uv add --dev` now updates the `dependency-groups.dev` section, rather
than `tool.uv.dev-dependencies` -- unless the dependency is already
present in `tool.uv.dev-dependencies`.

`uv remove --dev` now removes from both `dependency-groups.dev` and
`tool.uv.dev-dependencies`.

`--dev` and `--group dev` are now treated equivalently in `uv add` and
`uv remove`.
2024-10-25 13:27:37 -05:00
Charlie Marsh 810b430031 Add `--no-group` support to CLI (#8477)
## Summary

Now that `default-groups` can include more than just `"dev"`, it makes
sense to allow users to remove groups with `--no-group`.
2024-10-25 13:27:37 -05:00