Commit Graph

2764 Commits

Author SHA1 Message Date
Zanie Blue 3228fc5f35
Improve the `uv venv` CLI documentation (#5963)
This was actually in pretty good shape already!
2024-08-09 12:15:22 -05:00
Ibraheem Ahmed ddb82a01c8
Add basic universal benchmarks to CI (#5938)
## Summary

Resolves https://github.com/astral-sh/uv/issues/4921.
2024-08-09 12:52:28 -04:00
Zanie Blue 7fdb878fd0
Display portable paths in posix venv activation commands (#5956)
Closes #5950
2024-08-09 11:28:00 -05:00
Zanie Blue 4330f9718b
Improve the `uv lock` CLI documentation (#5932) 2024-08-09 08:51:03 -05:00
Charlie Marsh cac1e7bcfc
Add `update` alias for `uv tool upgrade` (#5948)
## Summary

I always get this wrong with `brew`, it'd be nice for it to "just work"
either way.
2024-08-09 09:37:03 -04:00
konsti eed23be1bd
Discard forks when using `--upgrade` (#5905)
Fixes #5817

Needs https://github.com/astral-sh/packse/pull/213 for the test to pass.
2024-08-09 09:13:38 +00:00
konsti 1e6b021506
Update packse to 0.3.34 (#5954)
Preparation for #5905
2024-08-09 09:04:17 +00:00
Chan Kang 441d57fa29
use exclude newer env var instead of the flag (#5946)
## Summary
resolves https://github.com/astral-sh/uv/issues/5879
<!-- What's the purpose of the change? What does it do, and why? -->
2024-08-09 09:53:06 +02:00
Charlie Marsh 21408c1f35
Enforce extension validity at parse time (#5888)
## Summary

This PR adds a `DistExtension` field to some of our distribution types,
which requires that we validate that the file type is known and
supported when parsing (rather than when attempting to unzip). It
removes a bunch of extension parsing from the code too, in favor of
doing it once upfront.

Closes https://github.com/astral-sh/uv/issues/5858.
2024-08-08 21:39:47 -04:00
Charlie Marsh ba7c09edd0
Respect subdirectories when locating Git workspaces (#5944)
## Summary

We were discovering the workspace from the Git repository root, so
attempting to build any subdirectories would fail.

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

## Test Plan

```
cargo run pip install \
	git+https://github.com/flyteorg/flytekit.git@master#subdirectory=plugins/flytekit-flyteinteractive
```
2024-08-08 20:13:17 -04:00
Charlie Marsh fd1d508108
Make `--upgrade` imply `--refresh` (#5943)
## Summary

I think this seems reasonable... Otherwise, we might not go back to PyPI
to revalidate the list of available versions despite the user passing
`--upgrade`.
2024-08-08 20:11:31 -04:00
Charlie Marsh 3701b60f61
Respect `--upgrade-package` in tool install (#5941)
## Summary

`--upgrade-package` is useful as you can set a constraint. `--upgrade`
will just warn for now.
2024-08-08 19:22:14 -04:00
Charlie Marsh a5ccc3288c
Add conversion to fill default settings (#5933)
## Summary

This paves the way for some future work around the installer receipt. No
behavior changes intended.
2024-08-08 21:05:38 +00:00
Charlie Marsh 88ece8b791
Search beyond workspace root when discovering configuration (#5931)
## Summary

Previously, we wouldn't respect configuration files in directories
_above_ a workspace root. But this is somewhat problematic, because any
`pyproject.toml` will define a workspace root...

Instead, I think we should _start_ the search at the workspace root, but
go above it if necessary.

Closes: #5929.

See: https://github.com/astral-sh/uv/pull/4295.
2024-08-08 17:05:02 -04:00
Ahmed Ilyas cbc3274848
Add `uv tool upgrade` command (#5197)
## Summary

Resolves #5188. Most of the changes involve creating a new function in
`tool/common.rs` to contain the common functionality previously found in
`tool/install.rs`.

## Test Plan

`cargo test`

```console
❯ ./target/debug/uv tool upgrade black
warning: `uv tool upgrade` is experimental and may change without warning.
Resolved 6 packages in 25ms
Uninstalled 1 package in 3ms
Installed 1 package in 19ms
 - black==23.1.0
 + black==24.4.2
Installed 2 executables: black, blackd
```
2024-08-08 16:48:14 -04:00
Zanie Blue bf0497e652
Add CLI flags to reference documentation (#5926)
Oopsies, options are only arguments that take values in Clap-land

Closes https://github.com/astral-sh/uv/issues/5924
2024-08-08 18:51:27 +00:00
Zanie Blue 0d21ff8b5f
Deprecate `--system` and `--no-system` in `uv venv` (#5925)
e.g.

```
❯ cargo run -- venv --no-system
    Blocking waiting for file lock on build directory
   Compiling uv v0.2.34 (/Users/zb/workspace/uv/crates/uv)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 19.85s
     Running `target/debug/uv venv --no-system`
warning: The `--no-system` flag has no effect, a system Python interpreter is always used in `uv venv`
Using Python 3.12.4 interpreter at: /opt/homebrew/opt/python@3.12/bin/python3.12
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate

❯ cargo run -- venv --system
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.15s
     Running `target/debug/uv venv --system`
warning: The `--system` flag has no effect, a system Python interpreter is always used in `uv venv`
Using Python 3.12.4 interpreter at: /opt/homebrew/opt/python@3.12/bin/python3.12
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate
```
2024-08-08 18:32:00 +00:00
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
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
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
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
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 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