Commit Graph

3360 Commits

Author SHA1 Message Date
Charlie Marsh dd1bcf8ab9
Ignore local configuration in tool commands (#5923)
## Summary

If you're running a user-level command, we shouldn't respect the local
`pyproject.toml` or `uv.toml`.
2024-08-08 14:25:12 -04:00
Zanie Blue f4576fe4a7
Improve the `uv tree` CLI documentation (#5917)
Some small follow-ups.
2024-08-08 18:21:46 +00:00
Zanie Blue d2681320d3
Improve the CLI documentation for `uv remove` (#5916)
Also, renames a `requirements` variable to `packages` for clarity and
fixes the definition of `frozen` for `uv add`.
2024-08-08 13:12:49 -05:00
Charlie Marsh dc3f498f58
Make repeated `uv add` operations simpler (#5922)
## Summary

Closes #5913.
2024-08-08 13:55:07 -04:00
Charlie Marsh 2789830ac2
Fix failing lockfile tests (#5919) 2024-08-08 16:37:05 +00:00
Charlie Marsh 32f09d86b3
Prefetch metadata in `--no-deps` mode (#5918)
## Summary

This _used_ to be true but we now require fetching metadata for all
distributions even with `--no-deps` since, e.g., we validate that any
declared extras exist.
2024-08-08 12:35:15 -04:00
Zanie Blue eb6251e0ed
Improve the CLI documentation for `uv add` (#5914) 2024-08-08 10:52:38 -05:00
Zanie Blue e9dd4876b8
Skip git tests on Windows (#5891)
Might be pushing it on test coverage, but these are some of our slowest
tests we might get a significant speedup here.

Part of #5713
2024-08-08 10:37:24 -05:00
Charlie Marsh cb62440aea
Show build and install summaries in `uv run` and `uv tool run` (#5899)
## Summary

Initially, we showed _all_ resolver and installer output in `uv run` and
`uv tool run`, since it was way too much for workhorse commands. Then,
we moved to showing _no_ output by default, which was way too little --
you had no idea why anything was happening, and commands appeared to
hang.

This PR adds a more nuanced middle-ground. With `--verbose`, we continue
to show everything. But by default, in `uv run` and `uv tool run`...

- During resolution, we show any "Building" and "Build" messages, if you
need to build a source distribution. But we don't show any other output.
(This _could_ be too little for expensive resolutions; we may want to
show a spinner.)
- If there are no changes to be made after resolving, we don't show any
other output.
- If we have to install, we show the progress bars for downloads (which
disappear on completion) followed by a single summary line stating the
number of packages installed.

This feels pretty good, in my limited testing. When everything is built
/ cached, you don't get _any_ additional output. When there's work to
do, you have a sense for what's happening, and we leave you with a
single summary line ("Installed X packages") at the end.

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

## Test Plan

Notice that the first `tool run` ends with an install line; the second
shows no additional output:

![Screenshot 2024-08-07 at 8 33
21 PM](https://github.com/user-attachments/assets/6b0c7824-f14f-4d0b-86d0-a334ba486ce4)

If you run `uv run` in a package for the first time, we _do_ tell you
that we're building / built it:

![Screenshot 2024-08-07 at 8 34
02 PM](https://github.com/user-attachments/assets/6a4c7b05-3aa5-410e-af5d-916eb6e745b0)

But on the second run, there's no output:

![Screenshot 2024-08-07 at 8 34
10 PM](https://github.com/user-attachments/assets/2b32f83e-0370-45fa-9e8f-407d9b93d468)

If you add a `--with`, we'll show you all the installer progress bars
(which disappear once they're done), and then a single summary line:

![Screenshot 2024-08-07 at 8 34
39 PM](https://github.com/user-attachments/assets/e975d75c-01d2-4eb6-b3ff-e4d25d5ea9e2)
2024-08-08 11:26:41 -04:00
konsti 4038c9a6af
Rename `distribution` to `packages` in lockfile (#5861)
Currently, the entry for a package+version+source table is called
`distribution`. That is incorrect, the `sdist` and `wheel` fields inside
of that table are distributions, the table itself is for a package. We
also align ourselves closer with PEP 751.

I went through `lock.rs` and renamed all occurrences of "distribution"
that actually referred to a "package".

This change invalidates all existing lockfiles.

Bikeshedding: Do we call it `package` or `packages`? See also
https://github.com/python/peps/pull/3877

`package` is nice because it looks like a header:

```toml
[[package]]
name = "anyio"
version = "4.3.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
    { name = "idna" },
    { name = "sniffio" },
]
sdist = { url = "3970183622d484d08e3285104333d3/anyio-4.3.0.tar.gz", hash = "sha256:f75253795a87df48568485fd18cdd2a3fa5c4f7c5be8e5e36637733fce06fed6", size = 159642 }
wheels = [
    { url = "2f20c40b45242c0b33774da0e2e34f/anyio-4.3.0-py3-none-any.whl", hash = "sha256:048e05d0f6caeed70d731f3db756d35dcc1f35747c8c403364a8332c630441b8", size = 85584 },
]
```

`packages` is nice because the field is not a single entry, but a list.

2/3 for https://github.com/astral-sh/uv/issues/4893

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-08-08 11:25:06 -04:00
Zanie Blue 4fd9b115d5
Add missing "git" feature to various tests (#5910) 2024-08-08 09:49:25 -05:00
konsti ae6b59365f
Only textwrap json packse scenarios with packse 0.3.32 (#5810)
Companion change to https://github.com/astral-sh/packse/pull/205 to
correctly format lock scenario doc comments.

Updates packse to 0.3.32.
2024-08-08 15:49:50 +02:00
Charlie Marsh 03797b0724
Respect `--upgrade-package` when resolving from lockfile (#5907)
## Summary

Closes https://github.com/astral-sh/uv/issues/5900.
2024-08-08 13:07:02 +00:00
Charlie Marsh 9f32c41552
Fix reuse of Git commits in lockfile (#5908)
## Summary

See: https://github.com/astral-sh/uv/pull/5886/files#r1709430408
2024-08-08 13:01:59 +00:00
Adrian Sampson 61b0a88107
Docs: Fix link to tools concept page (#5906)
This link previously went to the wrong "concept" page; it now goes to
the one the page intended.
2024-08-08 12:38:24 +00:00
davfsa cac3c4dfa5
Enable LTO optimizations in release builds to reduce binary size (#5904)
## Summary

In the same spirit as #5745, release builds could be a bit slightly more
size efficient by enabling LTO, which removes dead code (either in uv
through fully inlined functions or the libraries it depends on). Also
has the side-effect (more what LTO was created for) of slighly speeding
up uv.

In this case, I have measured a 5MB size decrease!.

Unfortunately, this change also comes with the disadvantage of more than
doubling the build time of a clean build on my machine (see "Test
Plan"). I have opened this pull request to show my findings and suggest
this as an option.

*I have also started looking into what effects optimizing for size
rather than speed could have, but that calls for another pr*

## Test Plan

Comparing the binary size before and after (starting off in just a
simple clone of the repository)

System info:
```
CPU: AMD Ryzen 7 3700X (16) @ 3.600GHz
Memory: 32GB @ 3200 MT/s
Uname: Linux galaxy 6.6.44-1-MANJARO #1 SMP PREEMPT_DYNAMIC Sat Aug  3 10:09:33 UTC 2024 x86_64 GNU/Linux
```

Before:
```
$ cargo build --release
<snip>
Finished `release` profile [optimized] target(s) in 1m 29s

$ du target/release/uv -h
30M	target/release/uv
```

After:
```
$ cargo build --release
<snip>
Finished `release` profile [optimized] target(s) in 3m 43s

$ du target/release/uv -h
25M	target/release/uv
```
2024-08-08 08:23:48 -04:00
Ahmed Ilyas acbd367ead
Support `no-build-isolation-package` (#5894)
## Summary

Resolves #5831 

## Test Plan

`cargo test`
2024-08-08 01:35:56 +00:00
Charlie Marsh f7110e0a07
Enable mirror for `python-build-standalone` downloads (#5719)
## Summary

This came up again recently, so decided to do it real quick.

Closes https://github.com/astral-sh/uv/issues/5224.
2024-08-07 21:34:19 -04:00
Charlie Marsh 9081509715
Avoid requires-python warning in virtual-only workspace (#5895)
## Summary

There's no way for the user to address this, so we shouldn't show it.
2024-08-07 20:43:19 -04:00
Charlie Marsh 4b2b2d2870
Use cached environments for `--with` layers (#5897)
## Summary

I think this will make the logging changes a little easier by having
more consistency between codepaths.
2024-08-07 23:31:43 +00:00
Charlie Marsh bc1d7764e2
Combine fetch and resolve steps in Git resolver (#5886)
## Summary

Whenever we call `resolve`, we immediately call `fetch` after. And in
some cases `resolve` actually calls `fetch` internally. It seems a lot
simpler to just merge these into one method that returns a `Fetch`
(which itself contains the fully-resolved URL).

Closes https://github.com/astral-sh/uv/issues/5876.
2024-08-07 22:35:05 +00:00
Zanie Blue 7523673f39
Setup Rust after restoring the cache (#5892)
This saves about 10-20s

Part of #5713
2024-08-07 16:33:12 -05:00
Charlie Marsh c681c5a33c
Bump version to v0.2.34 (#5889) 2024-08-07 16:33:53 -04:00
Zanie Blue 766d0788b0
Fix lock test cases (#5885) 2024-08-07 13:45:16 -05:00
Zanie Blue 858d75d0af
Use a larger runner for Linux test jobs (#5883)
From 8 to 16 cores, 32 to 64 GB RAM for a 2x per minute cost increase.

As in:

- #5874 
- #5873
2024-08-07 18:39:31 +00:00
konsti a3569b5b96
Group resolver options in lockfile (#5853)
There are three options that determine resolver behavior:

* resolution mode
* prerelease mode
* exclude newer

They are different from the other top level options: If they mismatch,
we recreate the resolution. To distinguish them from the rest of the
lockfile, we group them under an `[options]` header.

1/3 for #4893
2024-08-07 14:11:59 -04:00
Charlie Marsh 8c6b667eeb
Add `uv add --no-sync` and `uv remove --no-sync` (#5881)
## Summary

Closes https://github.com/astral-sh/uv/issues/5867.
2024-08-07 14:09:10 -04:00
Charlie Marsh 9bb55c4ac0
Add `--locked` coverage to lock tests (#5880)
Closes https://github.com/astral-sh/uv/issues/5875.
2024-08-07 13:39:51 -04:00
Zanie Blue c77f213acd
Use a larger runner for macOS test jobs (#5874)
From 3 to 6 (+8 GPU) cores, 7 to 14 GB ram.

Related:
- https://github.com/astral-sh/uv/pull/5873
2024-08-07 12:32:08 -05:00
Zanie Blue 8dad1ac2d4
Use a larger runner for Windows test jobs (#5873)
From 8 to 16 cores, 32 to 64 GB ram. Testing on Windows first because
it's the bottleneck.

Previously tested in #2515 to no effect, maybe better now that we have a
development drive?
2024-08-07 12:31:59 -05:00
Zanie Blue c95bf76dfe
Replace `uv help python` references in CLI documentation with links (#5871)
Following #5869, the documentation has some less-than-helpful
suggestions to use `uv help python` for details — we should link to the
`uv python` section instead.
2024-08-07 12:21:09 -05:00
Zanie Blue fe2849af6a
Improve CLI documentation for `uv tree` (#5870) 2024-08-07 16:59:27 +00:00
Zanie Blue 2df2092084
Improve `--python` CLI documentation (#5869)
Closes #4400
2024-08-07 16:37:10 +00:00
Zanie Blue 32d8ea1698
Improve documentation for `uv init` CLI (#5862) 2024-08-07 11:26:00 -05:00
Charlie Marsh f29bdcb9e3
Fix `add_git_implicit` test (#5872) 2024-08-07 16:23:47 +00:00
Charlie Marsh 9a80dfeed4
Assume `git+` prefix when URLs end in `.git` (#5868)
## Summary

Right now, this applies _everywhere_, so the following also works:

```
pip install "elmer-circuitbuilder @ https://github.com/ElmerCSC/elmer_circuitbuilder.git"
```

I actually think that's ok?

Closes https://github.com/astral-sh/uv/issues/5866.
2024-08-07 15:50:36 +00:00
Charlie Marsh dceba77ff7
Avoid mismatch in `--locked` with Git dependencies (#5865)
## Summary

We were dropping the query and fragment in the wrong place, so the URLs
didn't match up after resolving from an existing lockfile.

Closes https://github.com/astral-sh/uv/issues/5851.
2024-08-07 15:47:48 +00:00
Charlie Marsh e4ec6e4025
Avoid panic when re-locking with precise commit (#5863)
## Summary

Very subtle bug. The scenario is as follows:

- We resolve: `elmer-circuitbuilder = { git =
"https://github.com/ElmerCSC/elmer_circuitbuilder.git" }`

- The user then changes the request to: `elmer-circuitbuilder = { git =
"https://github.com/ElmerCSC/elmer_circuitbuilder.git", rev =
"44d2f4b19d6837ea990c16f494bdf7543d57483d" }`

- When we go to re-lock, we note two facts:

1. The "default branch" resolves to
`44d2f4b19d6837ea990c16f494bdf7543d57483d`.
2. The metadata for `44d2f4b19d6837ea990c16f494bdf7543d57483d` is
(whatever we grab from the lockfile).

- In the resolver, we then ask for the metadata for
`44d2f4b19d6837ea990c16f494bdf7543d57483d`. It's already in the cache,
so we return it; thus, we never add the
`44d2f4b19d6837ea990c16f494bdf7543d57483d` ->
`44d2f4b19d6837ea990c16f494bdf7543d57483d` mapping to the Git resolver,
because we never have to resolve it.

This would apply for any case in which a requested tag or branch was
replaced by its precise SHA. Replacing with a different commit is fine.

It only applied to `tool.uv.sources`, and not PEP 508 URLs, because the
underlying issue is that we aren't consistent about "automatically"
extracting the precise commit from a Git reference.

Closes https://github.com/astral-sh/uv/issues/5860.
2024-08-07 10:56:15 -04:00
Charlie Marsh 3ae75a21aa
Support empty dependencies in PEP 723 scripts (#5864)
## Summary

Closes https://github.com/astral-sh/uv/issues/5859.
2024-08-07 10:56:05 -04:00
Zanie Blue 8998149ac1
Improve CLI documentation for `uv run` (#5841)
Adds more long-form help to `uv run`, which renders in `uv help run` and
the CLI reference on the website.
2024-08-07 13:26:24 +00:00
Zanie Blue c34681a74c
Use uv installer during build (#5854) 2024-08-07 08:25:26 -05:00
konsti 54989f1376
Replace unreachable `todo!()` with `unreachable!()` in locking (#5857)
Replace a `todo!()` that was unreachable with an `unreachable!()` and a
proper comment.
2024-08-07 13:22:56 +00:00
konsti 68f186c409
Resolver internals docs touchups (#5850) 2024-08-07 08:32:31 +00:00
samypr100 2cd63f06dc
feat: more rust in trampoline (#5750)
## Summary

This is an experimental PR to replace more unsafe calls with more rust
while still trying to keep the binary size small enough. These changes
roughly increase the size of the trampolines to about 40kb~. This is a
alternate PR to https://github.com/astral-sh/uv/pull/5751.

The primary changes here include
* Switch to use rust path components for ease of path management
* Leverage `std::process::exit` for process exit and cleanup
* Use `std::io::Error::last_os_error` for IO Errors to remove
`FormatMessage` complexity
* Use `std::env::current_exe` to get the current executable instead of
`GetModuleFileNameA`

## Test Plan

Added one more existing test case to trampoline tests.
Still need to verify dunce::canonicalize is desired or not on
find_python_exe.

---------

Co-authored-by: konstin <konstin@mailbox.org>
2024-08-07 08:19:38 +00:00
Charlie Marsh d0b16f9018
Ensure `python`-to-`pythonX.Y` symlink exists in downloaded Pythons (#5849)
## Summary

After installing:

```
❯ readlink "/Users/crmarsh/Library/Application Support/uv/python/cpython-3.12.4-macos-aarch64-none/bin/python"
python3.12

❯ readlink "/Users/crmarsh/Library/Application Support/uv/python/cpython-3.9.5-macos-aarch64-none/bin/python"
python3.9
```

Closes https://github.com/astral-sh/uv/issues/5838.
2024-08-06 23:03:22 -04:00
Charlie Marsh e58c503f65
Reuse existing virtualenvs with `--no-project` (#5846)
## Summary

Closes https://github.com/astral-sh/uv/issues/5840.
2024-08-07 02:52:15 +00:00
Zanie Blue 345c167774
Fix GitHub cache integration link (#5847)
Unclear why mkdocs does not error on this 404
2024-08-07 02:08:45 +00:00
Zanie Blue d1614c8f10
Improve CLI documentation for global options (#5834)
Slowly auditing our CLI help text
2024-08-06 20:50:29 -05:00
Charlie Marsh 0f63173400
Add `--python` argument to benchmark script (#5844)
## Summary

Makes it easy to benchmark on different Python versions. Used this for
transformers, where some projects don't support Python 3.12.
2024-08-06 21:45:46 -04:00
Charlie Marsh cccb6820db
Avoid reusing incompatible distributions across lock and sync (#5845)
## Summary

We need to avoid using incompatible versions for build dependencies that
are also part of the resolved
environment. This is a very subtle issue, but: when locking, we don't
enforce platform
compatibility. So, if we reuse the resolver state to install, and the
install itself has to
preform a resolution (e.g., for the build dependencies of a source
distribution), that
resolution may choose incompatible versions.

The key property here is that there's a shared package between the build
dependencies and the
project dependencies.

Closes https://github.com/astral-sh/uv/issues/5836.
2024-08-07 00:54:51 +00:00