Commit graph

2857 commits

Author SHA1 Message Date
Charlie Marsh
540ff24302
Perform lock in uv sync by default (#4839)
## Summary

- `uv sync` will now lock by default.
- `uv sync --locked` will lock, and error if the generated lock does not
match `uv.lock` on-disk.
- `uv sync --frozen` will skip locking and just use `uv.lock`.

Closes https://github.com/astral-sh/uv/issues/4812.
Closes https://github.com/astral-sh/uv/issues/4803.
2024-07-09 15:18:30 -07:00
Ibraheem Ahmed
8c9bd70c71
Avoid serializing if lockfile does not change (#4945)
## Summary

Avoid serializing and writing the lockfile if a cheap comparison shows
that the contents have not changed.

## Test Plan

Shaves ~10ms off of https://github.com/astral-sh/uv/issues/4860 for me.

```
➜  transformers hyperfine "../../uv/target/profiling/uv lock" "../../uv/target/profiling/baseline lock" --warmup 3
Benchmark 1: ../../uv/target/profiling/uv lock
  Time (mean ± σ):     130.5 ms ±   2.5 ms    [User: 130.3 ms, System: 85.0 ms]
  Range (min … max):   126.8 ms … 136.9 ms    23 runs
 
Benchmark 2: ../../uv/target/profiling/baseline lock
  Time (mean ± σ):     140.5 ms ±   5.0 ms    [User: 142.8 ms, System: 85.5 ms]
  Range (min … max):   133.2 ms … 153.3 ms    21 runs
 
Summary
  ../../uv/target/profiling/uv lock ran
    1.08 ± 0.04 times faster than ../../uv/target/profiling/baseline lock
```
2024-07-09 17:08:27 -04:00
Zanie Blue
dc80fdba2c
Do not use pager for root uv help and improve after help hint (#4936)
Adds a nice hint at the bottom of `uv help` output indicating how to get
more details about a specific command, roughly matching Cargo's
interface.

We use the short help and skip the pager for the root `uv help` since
it's intended to be a landing page for the help interface more than an
in-depth display. This also matches Cargo, though I like that they have
the global options above the commands and I've not changed that here.
2024-07-09 14:38:28 -05:00
Charlie Marsh
55e1a7e011
Enable --all to uninstall all managed tools (#4937)
## Summary

Like #4932 but for tools.
2024-07-09 19:26:17 +00:00
Charlie Marsh
bb703b8343
Reinstall and recreate environments when interpreter is removed (#4935)
## Summary

We now recreate the environment in `uv sync`, `uv tool install`, and `uv
tool run` if the underlying interpreter has been removed.

Closes https://github.com/astral-sh/uv/issues/4933.
2024-07-09 19:25:23 +00:00
konsti
53db63f6dd
Apply extra to overrides and constraints (#4829)
This is an attempt to solve https://github.com/astral-sh/uv/issues/ by
applying the extra marker of the requirement to overrides and
constraints.

Say in `a` we have a requirements
```
b==1; python_version < "3.10"
c==1; extra == "feature"
```

and overrides
```
b==2; python_version < "3.10"
b==3; python_version >= "3.10"
c==2; python_version < "3.10"
c==3; python_version >= "3.10"
```

Our current strategy is to discard the markers in the original
requirements. This means that on 3.12 for `a` we install `b==3`, but it
also means that we add `c` to `a` without `a[feature]`, causing #4826.
With this PR, the new requirement become,

```
b==2; python_version < "3.10"
b==3; python_version >= "3.10"
c==2; python_version < "3.10" and extra == "feature"
c==3; python_version >= "3.10" and extra == "feature"
```

allowing to override markers while preserving optional dependencies as
such.

Fixes #4826
2024-07-09 20:37:24 +02:00
Charlie Marsh
0a04108a15
Enable --all to uninstall all managed Pythons (#4932)
## Summary

Allows `--all` as an alternative to specifying specific targets.

## Test Plan

Verified that `cargo run python uninstall` still fails.

```
❯ cargo run python uninstall --all
   Compiling uv-cli v0.0.1 (/Users/crmarsh/workspace/puffin/crates/uv-cli)
   Compiling uv v0.2.23 (/Users/crmarsh/workspace/puffin/crates/uv)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.86s
     Running `target/debug/uv python uninstall --all`
warning: `uv python uninstall` is experimental and may change without warning.
Searching for Python installations
Found existing installation: cpython-3.9.18-macos-aarch64-none
Found existing installation: cpython-3.8.18-macos-aarch64-none
Found existing installation: cpython-3.8.12-macos-aarch64-none
Found existing installation: cpython-3.12.1-macos-aarch64-none
Found existing installation: cpython-3.11.7-macos-aarch64-none
Found existing installation: cpython-3.10.13-macos-aarch64-none
Uninstalled cpython-3.10.13-macos-aarch64-none
Uninstalled cpython-3.11.7-macos-aarch64-none
Uninstalled cpython-3.12.1-macos-aarch64-none
Uninstalled cpython-3.8.12-macos-aarch64-none
Uninstalled cpython-3.8.18-macos-aarch64-none
Uninstalled cpython-3.9.18-macos-aarch64-none
Uninstalled 6 versions in 479ms
```
2024-07-09 18:15:16 +00:00
Zanie Blue
bd7a25f604
Use paging for uv help display when available (#4909)
Extends https://github.com/astral-sh/uv/pull/4906

Adds paged display of "long' help to `uv help` invocations when `less`
or `more` is available.
2024-07-09 18:06:27 +00:00
Janosh Riebesell
8da91f5a97
Remove confusing punctuation in readme (#4929)
admittedly, nitpick PR but i initially misread the trailing dot in

```
# Create a virtual environment at .venv.
```

as part of the directory name, i.e. that the env would be placed in
`.venv.`
2024-07-09 13:01:07 -05:00
Charlie Marsh
92290d8dcb
Respect resolver settings in uv remove (#4930)
## Summary

Closes https://github.com/astral-sh/uv/issues/4925
2024-07-09 17:46:31 +00:00
Zanie Blue
5f20bdb2ee
Implement uv help manually instead of using Clap default (#4906)
Extends #4772 

Implements `uv help` ourselves so we can do things like #4909 
Adds hints to use `uv help` for more details during short help display.
2024-07-09 17:43:13 +00:00
Charlie Marsh
2e307d9081
Avoid inferring package name for GitHub Archives (#4928)
## Summary

Closes https://github.com/astral-sh/uv/issues/4917.
2024-07-09 17:30:43 +00:00
Zanie Blue
0bf562f197
Display short help menu when --help is used (#4772)
I feel like I'm always drowning in the help output from `uv` because we
have so many options.

I basically agree with the commentary in
https://github.com/clap-rs/clap/issues/4687 that having different
behaviors for `-h` and `--help` is surprising. I think `--help` is more
obvious for users and I want to optimize for that experience.

This roughly matches the help menus in Cargo and pip.

The `uv help` command can be used for long help. In #4906 and #4909 we
improve that command.

Extends #4904 which adds test cases for the existing behavior.
2024-07-09 17:12:01 +00:00
Charlie Marsh
72dd34b225
Filter out markers based on Python requirement (#4912)
## Summary

In marker normalization, we now remove any markers that are redundant
with the `requires-python` specifier (i.e., always true for the given
Python requirement).

For example, given `iniconfig ; python_version >= '3.7'`, we can remove
the `python_version >= '3.7'` marker when resolving with
`--python-version 3.8`.

Closes #4852.
2024-07-09 09:15:58 -07:00
renovate[bot]
ef120dcc54
Update Rust crate hyper to v1.4.1 (#4877) 2024-07-09 09:08:10 -07:00
Zanie Blue
babb1e3ec2
Upgrade clap (#4927)
For https://github.com/clap-rs/clap/pull/5574 for #4772
2024-07-09 16:06:53 +00:00
Charlie Marsh
a046d23f79
Avoid AND-ing multi-term specifiers in marker normalization (#4911)
## Summary

Given `python_version != '3.8' and python_version < '3.10'`, the first
term was expanded to `python_version < '3.8'` and `python_version >
'3.8'`. We then AND'd all three terms together. We don't seem to have a
way to differentiate between the terms to AND and the terms to OR in the
normalization code (it all gets flattened together), so instead this PR
expands the expressions at the leaf level and then flattens them at the
level above when appropriate.

Closes https://github.com/astral-sh/uv/issues/4910.
2024-07-09 16:04:26 +00:00
Zanie Blue
b4a7d96d4e
Add test cases for the CLI help menu (#4904)
No changes in behavior here, adding these test cases to demonstrate
changes to come.
2024-07-09 09:07:43 -05:00
Charlie Marsh
72982c1bff
Add command-separation for Python discovery display (#4916)
## Summary

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

```
error: No interpreter found for Python 3.12.4 in virtual environments, managed installations, or system path
```
2024-07-09 05:51:30 +00:00
Charlie Marsh
f862457f05
Avoid debug error for uv run with unknown Python version (#4913)
## Summary

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

## Test Plan

```
> cargo run -- run -vv --preview --isolated --python 3.12.4 python -V
error: No interpreter found for Python 3.12.4 in virtual environments or managed installations or system path
```
2024-07-09 05:29:55 +00:00
Ibraheem Ahmed
ed4234d52e
Filter and flatten markers (#4639)
## Summary

More marker simplification:
- Filters out redundant subtrees based on outer expressions, e.g. `a and (a or
b)` simplifies to `a`.
- Flattens nested trees internally, e.g. `(a and b) and c`

Resolves https://github.com/astral-sh/uv/issues/4536.
2024-07-08 18:59:21 +00:00
Ibraheem Ahmed
dc7ad3abdb
Implement uv tree (#4708)
## Summary

Implements the `uv tree`, which displays dependencies from the lockfile
as a tree. Resolves https://github.com/astral-sh/uv/issues/4699.
2024-07-08 18:07:48 +00:00
Zanie Blue
4bc36c0cb8
Bump version to 0.2.23 (#4903) 2024-07-08 12:29:37 -05:00
Andrew Gallant
857d2e8f1e uv-resolver: partially revert Requires-Python version narrowing
The PR #4707 introduced the notion of "version narrowing," where a
Requires-Python constraint was _possibly_ narrowed whenever the
universal resolver created a fork. The version narrowing would occur
when the fork was a result of a marker expression on `python_version`
that is *stricter* than the configured `Requires-Python` (via, say,
`pyproject.toml`).

The crucial conceptual change made by #4707 is therefore that
`Requires-Python` is no longer an invariant configuration of resolution,
but rather a mutable constraint that can vary from fork to fork. This in
turn can result in some cases, such as in #4885, where different
versions of dependencies are selected. We aren't sure whether we can fix
those or not, with version narrowing, so for now, we do this revert to
restore the previous behavior and we'll try to address the version
narrowing some other time.

This also adds the case from #4885 as a regression test, ensuring that
we don't break that in the future. I confirmed that with version
narrowing, this test outputs duplicate distributions. Without narrowing,
there are no duplicates.

Ref #4707, Fixes #4885
2024-07-08 09:56:59 -07:00
Charlie Marsh
ac3a085084
Respect requires-python when prefetching (#4900)
## Summary

This is fallout from https://github.com/astral-sh/uv/pull/4705. We need
to respect `requires-python` in the prefetch code to avoid building
unsupported distributions.

Closes https://github.com/astral-sh/uv/issues/4898.
2024-07-08 16:32:09 +00:00
Charlie Marsh
71c6a9fad3
Sort dependencies before wheels and source distributions (#4897)
Closes https://github.com/astral-sh/uv/issues/4889.
2024-07-08 14:25:05 +00:00
Charlie Marsh
b9d661012d
Initialize all --prefix subdirectories (#4895)
## Summary

We need to initialize the same directories that we create in `bare.rs`,
since the installer expects them to exist.

Closes #4892.
2024-07-08 14:15:25 +00:00
Charlie Marsh
2d651fe264
Add some text decoration to toolchain CLI (#4882)
## Summary

Attempts to make the CLI output a little more consistent with the `pip`
interface. I opted to make the Python versions, requests, and filenames
blue, and the keys green, but open to opinions on that. (We use blue for
filenames elsewhere.)

Closes #4813.
Closes https://github.com/astral-sh/uv/issues/4814.

![Screenshot 2024-07-07 at 9 18
48 PM](8518b559-196b-4cd0-bc16-8e79e66460bb)
2024-07-08 10:03:38 -04:00
konsti
57cfe1e229
Small forking log improvements (#4894)
I found the current messages insufficient when tracking down a bug.
2024-07-08 13:56:57 +00:00
Charlie Marsh
4f340580c7
Show user-facing warning when falling back to copy installs (#4880)
## Summary

This has come up a few times including in a recent email to me.
2024-07-08 13:35:58 +00:00
Charlie Marsh
947cfa13a8
Add some decoration to tool CLI (#4865)
Mostly small things. I added entrypoint counts and bolded the executable
names.

Closes https://github.com/astral-sh/uv/issues/4815.
2024-07-08 09:21:05 -04:00
Andrew Gallant
fb19372a00 uv/tests: fix tool_install_home test
This test was, I believe, relying on the XDG_DATA_HOME environment
variable not being set. When it is set, as is the case in my
environment, `uv tool run` will respect it and install `black` for this
particular test into my actual XDG_DATA_HOME directory. We fix this by
setting `XDG_DATA_HOME` explicitly.
2024-07-08 06:12:53 -07:00
Charlie Marsh
ffcc05240e
Add user-facing output to indicate PEP 723 script (#4881) 2024-07-08 02:05:13 +00:00
Charlie Marsh
ae242c3b8f
Ensure Pythons are aligned in uv python list (#4884)
## Summary

The existing tab input sometimes leads to misalignment on my machine, I
think it has to do with breakpoints?

![Screenshot 2024-07-07 at 9 22
43 PM](c95c5d26-3acb-48a6-8cce-d76f219f5afe)

This PR computes the width explicitly, and then pads each line. I also
added some colors to the RHS. I think it makes it easier to scan, but
don't feel strongly.

![Screenshot 2024-07-07 at 9 36
56 PM](1c89c83b-9562-4597-a892-021573c48f8d)
2024-07-07 21:52:30 -04:00
Charlie Marsh
98a720ec08
Skip installing --with requirements if present in base environment (#4879)
## Summary

Closes #4547.
2024-07-08 01:23:59 +00:00
konsti
a76d04b159
Box::pin(run()) and 2MB test stack (#4851)
By using `Box::pin(run())` we can reduce the artificial stack size for
running tests on windows in debug mode from 8MB to 2MB. I've checked and
1MB/no custom stack size still fail tests, e.g.
`add_workspace_editable`.
2024-07-07 20:50:36 -04:00
renovate[bot]
b21f3226a6
Update pre-commit dependencies (#4876) 2024-07-08 00:31:24 +00:00
renovate[bot]
889f4efd21
Update Rust crate syn to v2.0.69 (#4875) 2024-07-08 00:26:58 +00:00
renovate[bot]
7a914b900c
Update Rust crate serde_json to v1.0.120 (#4874) 2024-07-07 20:25:18 -04:00
renovate[bot]
621e0e9df8
Update Rust crate serde to v1.0.204 (#4873) 2024-07-07 20:25:13 -04:00
renovate[bot]
f07f1006d9
Update Rust crate reflink-copy to v0.1.19 (#4872) 2024-07-07 20:25:08 -04:00
renovate[bot]
08c544ddd5
Update Rust crate hyper-util to v0.1.6 (#4871) 2024-07-07 20:25:00 -04:00
renovate[bot]
28e71eba99
Update Rust crate axoupdater to v0.6.8 (#4870) 2024-07-07 20:24:52 -04:00
renovate[bot]
12a922261f
Update Rust crate async-trait to v0.1.81 (#4869) 2024-07-07 20:24:46 -04:00
konsti
1a31938626
Update windows binaries, again (#4864)
https://github.com/astral-sh/uv/pull/4850#issuecomment-2212557050
2024-07-07 18:58:22 -04:00
Charlie Marsh
389582a37e
Avoid creating cache directories in tool directory (#4868)
Closes https://github.com/astral-sh/uv/issues/4867.
2024-07-07 21:19:07 +00:00
Charlie Marsh
a302d704c5
Fix always-plural message in uv python install (#4866) 2024-07-07 20:29:19 +00:00
Jo
f4c4b69cc7
Add progress bar when downloading python (#4840)
## Summary

Resolves #4825 

## Test Plan

```sh
$ cargo run -- python install --force --preview
$ cargo run -- venv -p 3.12 --python-preference only-managed
$ cargo run -- tool install --preview -p 3.12 --python-preference only-managed --force black
````

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-07-07 20:01:35 +00:00
konsti
9e50864508
Ignore compile_invalid_pyc_invalidation_mode on all platforms (#4863)
This test is failing most times for me when running nextest locally,
failing the overall test run, so i'm deactivating it for now. I'm still
not sure what the root cause here is. It seems to have something to do
with python stdin not being ready immediately after we spawn the process
and us being too fast.
2024-07-07 19:46:41 +00:00
Charlie Marsh
f5e84bbbab
Bump version to v0.2.22 (#4862) 2024-07-07 19:23:38 +00:00