Commit graph

641 commits

Author SHA1 Message Date
Charlie Marsh
8c0ad5b75e
Add OptionsMetadata macro to uv (#5063)
## Summary

The bulk of the change is copied directly from Ruff:

-
dc8db1afb0/crates/ruff_workspace/src/options_base.rs
-
dc8db1afb0/crates/ruff_macros/src/config.rs
2024-07-15 19:24:08 +00:00
konsti
e34ab96e80
Remove special casing from no solution error (#5067)
The only pubgrub error that can occur is a `NoSolutionError`, and the
only place it can occur is `unit_propagation`, all other variants if
`PubGrubError` are unreachable. By changing the return type on pubgrub's
side (https://github.com/astral-sh/pubgrub/pull/28), we can remove the
pattern matching and the `unreachable!()` asserts on `PubGrubError`.

Our pubgrub error wrapper used to have a two phased initialization,
first mostly stubs in `solve[_tracked]()` and then adding the actual
context in `resolve()`. When constructing the error in `solve` we
already have all this context, so we can unify this to a regular
constructor and remove the special casing in `resolve()` and `hints()`.
2024-07-15 17:43:35 +02:00
renovate[bot]
cc0983a8db
Update Rust crate toml_edit to v0.22.15 (#5055) 2024-07-14 20:40:23 -04:00
renovate[bot]
865ba6db10
Update Rust crate tracing-tree to 0.4.0 (#5059) 2024-07-14 20:39:56 -04:00
renovate[bot]
97d2a7c567
Update Rust crate tikv-jemallocator to 0.6.0 (#5058) 2024-07-14 20:39:50 -04:00
renovate[bot]
4d14a1a371
Update Rust crate clap_complete_command to 0.6.0 (#5057) 2024-07-14 20:39:43 -04:00
renovate[bot]
d230323241
Update Rust crate thiserror to v1.0.62 (#5054) 2024-07-14 20:39:26 -04:00
renovate[bot]
27247029c9
Update Rust crate target-lexicon to v0.12.15 (#5053) 2024-07-14 20:39:21 -04:00
renovate[bot]
517487e2d0
Update Rust crate syn to v2.0.71 (#5052) 2024-07-14 20:39:15 -04:00
Charlie Marsh
4eb19c76bd
Add Windows path updates for uv tool (#5029)
## Summary

Largely based on rustup's implementation (linked in the source).

Closes #5027.

## Test Plan

- Changed the executable directory to `uv/foo`.
- Ran script; verified that I could access executables in `foo`.
2024-07-13 01:55:05 +00:00
Charlie Marsh
a61464e802
Move shell manipulation into its own crate (#5028)
## Summary

This is going to get a little more complex as we support Windows, so
carving it out.
2024-07-12 21:12:58 -04:00
Charlie Marsh
a4cb21e081
Add a command to append uv's binary directory to PATH (#4975)
## Summary

I'll open follow-up tickets for Windows support.

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

## Test Plan

```
❯ cargo run tool install flask
Resolved 7 packages in 353ms
Prepared 7 packages in 392ms
Installed 7 packages in 17ms
 + blinker==1.8.2
 + click==8.1.7
 + flask==3.0.3
 + itsdangerous==2.2.0
 + jinja2==3.1.4
 + markupsafe==2.1.5
 + werkzeug==3.0.3
Installed 1 executable: flask
warning: /Users/crmarsh/.local/bin is not on your PATH. To use installed tools, run:
  export PATH="/Users/crmarsh/.local/bin:$PATH"
```

Then:

```
❯ which flask
flask not found
```

Then:

```
❯ cargo run tool ensurepath
warning: `uv tool ensurepath` is experimental and may change without warning.
Updated configuration file: /Users/crmarsh/workspace/puffin/bar
Restart your shell for the changes to take effect.
```

Then:
```
❯ which flask
/Users/crmarsh/.local/bin/flask
```
2024-07-12 22:09:34 +00:00
Zanie Blue
527b711bc7
Bump version to 0.2.24 (#4974) 2024-07-10 13:50:12 -05:00
Charlie Marsh
1fcc3c4797
Warn if tool binary directory is not on path (#4951)
## Summary

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

## Test Plan

```
❯ XDG_BIN_HOME="/Users/crmarsh/workspace/uv/foo bar" cargo run tool install black --force
Installed 2 executables: black, blackd
warning: `/Users/crmarsh/workspace/uv/foo bar` is not on your PATH. To use installed tools, run:
  export PATH="/Users/crmarsh/workspace/uv/foo bar:$PATH"
```
2024-07-10 15:24:16 +00:00
Charlie Marsh
23eb42deed
Allow constraints to be provided in --upgrade-package (#4952)
## Summary

Allows, e.g., `--upgrade-package flask<3.0.0`.

Closes https://github.com/astral-sh/uv/issues/1964.
2024-07-09 20:09:13 -07:00
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
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
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
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
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
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
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
Charlie Marsh
f5e84bbbab
Bump version to v0.2.22 (#4862) 2024-07-07 19:23:38 +00:00
Charlie Marsh
de40f798b9
Cache tool environments in uv tool run (#4784)
## Summary

The basic strategy:

- When the user does `uv tool run`, we resolve the `from` and `with`
requirements (always).
- After resolving, we generate a hash of the requirements. For now, I'm
just converting to a lockfile and hashing _that_, but that's an
implementation detail.
- Once we have a hash, we _also_ hash the interpreter.
- We then store environments in
`${CACHE_DIR}/${INTERPRETER_HASH}/${RESOLUTION_HASH}`.

Some consequences:

- We cache based on the interpreter, so if you request a different
Python, we'll create a new environment (even if they're compatible).
This has the nice side-effect of ensuring that we don't use environments
for interpreters that were later deleted.
- We cache the `from` and `with` together. In practice, we may want to
cache them separately, then layer them? But this is also an
implementation detail that we could change later.
- Because we use the lockfile as the cache key, we will invalidate the
cache when the format changes. That seems ok, but we could improve it in
the future by generating a stable hash from a lockfile that's
independent of the schema.

Closes https://github.com/astral-sh/uv/issues/4752.
2024-07-03 19:25:39 -04:00
Caíque Porfirio
c17761904e
feat: add tool version to list command (#4674)
<!--
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?
-->
Closes #4653

## Summary
Adds the tool version to the list command right beside the tool name

```
$ uv tool list
black v24.2.0
```

Following the proposed format discussed in #4653


## Test Plan
`cargo test tool_list`

<!-- How was it tested? -->

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-07-03 18:24:37 +00:00
Charlie Marsh
f980e3f4fc
Use already-installed tools in uv tool run (#4750)
## Summary

This doesn't cache the tool environment; rather, it just uses the `tool
install` environment if it satisfies the request.

Closes https://github.com/astral-sh/uv/issues/4742.
2024-07-03 16:35:11 +00:00
Zanie Blue
dd7da6af5f
Change "toolchain" to "python" (#4735)
Whew this is a lot.

The user-facing changes are:

- `uv toolchain` to `uv python` e.g. `uv python find`, `uv python
install`, ...
- `UV_TOOLCHAIN_DIR` to` UV_PYTHON_INSTALL_DIR`
- `<UV_STATE_DIR>/toolchains` to `<UV_STATE_DIR>/python` (with
[automatic
migration](https://github.com/astral-sh/uv/pull/4735/files#r1663029330))
- User-facing messages no longer refer to toolchains, instead using
"Python", "Python versions" or "Python installations"

The internal changes are:

- `uv-toolchain` crate to `uv-python`
- `Toolchain` no longer referenced in type names
- Dropped unused `SystemPython` type (previously replaced)
- Clarified the type names for "managed Python installations"
- (more little things)
2024-07-03 07:44:29 -05:00
Zanie Blue
ebfe6d8fcc
Bump version to 0.2.21 (#4757) 2024-07-03 04:27:00 +00:00
Zanie Blue
e88e1373e6
Bump version to 0.2.20 (#4745) 2024-07-02 22:30:43 +00:00
Zanie Blue
c5bf64abeb
Bump version to 0.2.19 (#4738) 2024-07-02 21:15:58 +00:00
Charlie Marsh
32dc9bef59
Respect tool upgrades in uv tool install (#4736)
## Summary

For now the semantics are such that if the requested requirements from
the command line don't match the receipt (or if any `--reinstall` or
`--upgrade` is requested), we proceed with an install, passing the
`--reinstall` and `--upgrade` to the underlying Python environment.

This may lead to some unintuitive behaviors, but it's simplest for now.
For example:

- `uv tool install black<24` followed by `uv tool install black
--upgrade` will install the latest version of `black`, removing the
`<24` constraint.
- `uv tool install black --with black-plugin` followed by `uv tool
install black` will remove `black-plugin`.

Closes https://github.com/astral-sh/uv/issues/4659.
2024-07-02 16:46:31 -04:00
konsti
4b19319485
Show when we retried requests (#4725)
In #3514 and #2755, users had intermittent network errors, but it was
not always clear whether we had already retried these requests or not.
Building upon https://github.com/TrueLayer/reqwest-middleware/pull/159,
this PR adds the number of retries to the error message, so we can see
at first glance where we're missing retries and where we might need to
change retry settings.

Example error trace:

```
Could not connect, are you offline?
  Caused by: Request failed after 3 retries
  Caused by: error sending request for url (https://pypi.org/simple/uv/)
  Caused by: client error (Connect)
  Caused by: dns error: failed to lookup address information: Name or service not known
  Caused by: failed to lookup address information: Name or service not known
```

This code is ugly since i'm missing a better pattern for attaching
context to reqwest middleware errors in
https://github.com/TrueLayer/reqwest-middleware/pull/159.
2024-07-02 19:04:11 +02:00
Charlie Marsh
8e935e2c17
Support unnamed requirements in uv tool install (#4716)
## Summary

This PR adds support for (e.g.) `uv tool install
git+https://github.com/psf/black`.

Closes https://github.com/astral-sh/uv/issues/4664.
2024-07-01 21:37:14 -04:00
Charlie Marsh
324e9fe5cf
Respect data scripts in uv tool install (#4693)
## Summary

Packages that provide scripts that _aren't_ Python entrypoints need to
respected in `uv tool install`. For example, Ruff ships a script in
`ruff-0.5.0.data/scripts`.

Unfortunately, the `.data` directory doesn't exist in the virtual
environment at all (it's removed, per the spec, after install). So this
PR changes the entry point detection to look at the `RECORD` file, which
is the only evidence that the scripts were installed.

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

## Test Plan

`cargo run uv tool install ruff` (snapshot tests to-come)
2024-07-01 12:22:37 -04:00
Charlie Marsh
bfadadefaf
Add PEP 723 support to uv run (#4656)
Closes #3096 

## Summary

Enables `uv run foo.py` to execute PEP 723-compatible scripts.

For example, given:

```python
# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "requests<3",
#   "rich",
# ]
# ///

import requests
from rich.pretty import pprint

resp = requests.get("https://peps.python.org/api/peps.json")
data = resp.json()
pprint([(k, v["title"]) for k, v in data.items()][:10])
```

![Screenshot 2024-06-29 at 7 23
52 PM](c60f2415-4874-4b15-b9f5-dd8c8c35382e)
2024-07-01 08:20:24 -04:00
renovate[bot]
8f881d4796
Update Rust crate dashmap to v6 (#4682) 2024-07-01 01:49:15 +00:00
renovate[bot]
36625465c1
Update Rust crate reqwest-retry to 0.6.0 (#4680) 2024-06-30 21:45:35 -04:00
renovate[bot]
56ecc4617a
Update Rust crate either to v1.13.0 (#4678) 2024-06-30 21:45:19 -04:00
renovate[bot]
8b5d979010
Update Rust crate serde_json to v1.0.119 (#4677) 2024-06-30 21:45:03 -04:00
renovate[bot]
87b7ccb37c
Update Rust crate reqwest-middleware to v0.3.2 (#4676) 2024-06-30 21:44:57 -04:00
renovate[bot]
4c8aaed532
Update Rust crate clap to v4.5.8 (#4675) 2024-06-30 21:40:23 -04:00
Charlie Marsh
13b0beb56f
Bump version to v0.2.18 (#4650) 2024-06-29 14:30:01 -04:00