Commit graph

4903 commits

Author SHA1 Message Date
Zanie Blue
9a14e028df
Fix test cases for syncing from the lockfile when credentials are required (#6378) 2024-08-21 16:51:16 -05:00
Zanie Blue
787f2a7bca
Always invoke found interpreter when uv run python is used (#6363)
Alternative to https://github.com/astral-sh/uv/pull/6362

Resolves the error mentioned in #6361
2024-08-21 16:41:35 -05:00
Zanie Blue
fa0c20d5b1
Respect .python-version files in uv run outside projects (#6361)
Closes https://github.com/astral-sh/uv/issues/6285

Introduces a new problem if the user says `python` but it doesn't exist
with that name:

```
❯ cargo run -q -- -v run python --version
DEBUG uv 0.3.0
DEBUG Found project root: `/Users/zb/workspace/uv`
DEBUG Project `uv` is marked as unmanaged
DEBUG No project found; searching for Python interpreter
DEBUG Reading requests from `/Users/zb/workspace/uv/.python-version`
DEBUG Searching for Python 3.11 in managed installations or system path
DEBUG Found `cpython-3.12.4-macos-aarch64-none` at `/Users/zb/workspace/uv/.venv/bin/python3` (virtual environment)
DEBUG Searching for managed installations at `/Users/zb/Library/Application Support/uv/python`
DEBUG Found `cpython-3.11.9-macos-aarch64-none` at `/opt/homebrew/bin/python3.11` (search path)
DEBUG Using Python 3.11.9 interpreter at: /opt/homebrew/opt/python@3.11/bin/python3.11
DEBUG Running `python --version`
error: Failed to spawn: `python`
  Caused by: No such file or directory (os error 2)
```

I'll fix this separately.
2024-08-21 16:41:27 -05:00
Zanie Blue
2fbe12ee1b
Refactor .python-version discovery (#6359)
In preparation for more comprehensive discovery
2024-08-21 16:41:20 -05:00
Jo
1377c6807d
Avoid adding extra newline for script with non-empty prelude (#6366)
Closes #6364
2024-08-21 16:57:08 -04:00
Charlie Marsh
7fdd26c81f
Respect --no-build-isolation in uv add (#6368)
## Summary

We still had the default encoded here.

Closes https://github.com/astral-sh/uv/issues/6367.
2024-08-21 19:03:21 +00:00
konsti
e7fb452552
Don't drop download error source (#6338)
Part of #6331
2024-08-21 13:15:57 -05:00
Charlie Marsh
45894e074c
Use sys_executable for uv run invocations (#6354)
## Summary

Ensures that we read the correct `python` from the _interpreter_, rather
than assuming `python`.

Closes https://github.com/astral-sh/uv/issues/6348.
2024-08-21 13:14:29 -04:00
Charlie Marsh
fd408c4ffa
Remove anyhow dependency in uvx (#6347)
## Summary

This is now unused.
2024-08-21 16:47:41 +00:00
Charlie Marsh
90df56feab
Handle Ctrl-C properly in uvx invocations (#6346)
## Summary

This follows Rye's approach, and solves
https://github.com/astral-sh/uv/issues/6334.
2024-08-21 16:39:11 +00:00
Charlie Marsh
a9d2238357
Update dev_dependencies reference in source code (#6351)
See: https://github.com/astral-sh/uv/pull/6344
2024-08-21 16:29:55 +00:00
Charlie Marsh
70dba6f954
Avoid treating uv add -r as --raw-sources (#6287)
## Summary

I suspect this was added because there's no way for users to pass (e.g.)
`--tag`, so the references are ambiguous. I think it's better to write
them as `rev` than to fail, though. It's just less efficient when we
fetch.

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

Closes https://github.com/astral-sh/uv/issues/6275.
2024-08-21 11:28:02 -05:00
ldacey
d8095b1fb8
fix(docs): replace underscore with dash for dev-dependencies (#6344)
Docs show an underscore which should be a dash in dev-dependencies:
`dev_dependencies = ["ruff==0.5.0"]`


## Summary
I followed the example in the references settings and used
dev_dependencies in my pyproject.toml but it seems like this needs to be
a dash instead of an underscore:

=> ERROR [stage-0 5/5] RUN uv sync 6.9s
------
 > [stage-0 5/5] RUN uv sync:
0.085 warning: Failed to parse `pyproject.toml` during settings
discovery:
0.085   TOML parse error at line 65, column 1
0.085      |
0.085   65 | [tool.uv]
0.085      | ^^^^^^^^^
0.085   unknown field `dev_dependencies`
0.085
2024-08-21 15:52:57 +00:00
Charlie Marsh
c5cf3afba0
Use consistent logic for deserializing short revisions (#6341)
## Summary

Closes https://github.com/astral-sh/uv/issues/6336.
2024-08-21 15:34:03 +00:00
Charlie Marsh
c485727e00
Remove duplicated lockfile invalidation logs (#6340)
## Summary

These got moved to the caller, so they're all duplicated right now.
2024-08-21 15:29:33 +00:00
Charlie Marsh
d627dea51e
Preserve Git username for SSH dependencies (#6335)
## Summary

We're gonna work on a more comprehensive review of whether we should
preserve the username here, but for now, `git@` is effectively a
convention for GitHub and GitLab etc.

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

## Test Plan

I guess we don't have infrastructure for testing SSH private keys right
now, but...

```
❯ cargo run init foo
❯ cd foo
❯ cargo run add git+ssh://git@github.com/astral-sh/mkdocs-material-insiders.git
```
2024-08-21 11:22:45 -04:00
konsti
cabca7bf23
Fix metadata cache instability (#6332)
For a path dep such as the root project, uv can read metadata statically
from `pyproject.toml` or dynamically from the build backend.

Python's `packaging`
[sorts](cc938f984b/src/packaging/specifiers.py (L777))
specifiers before emitting them, so all build backends built on top of
it - such as hatchling - will change the specifier order compared to
pyproject.toml. The core metadata spec does say "If a field is not
marked as Dynamic, then the value of the field in any wheel built from
the sdist MUST match the value in the sdist", but it doesn't specify if
"match" means string equivalent or semantically equivalent, so it's
arguable if that spec conformant. This change means that the specifiers
have a different ordering when coming from the build backend than when
read statically from pyproject.toml.

Previously, we tried to read path dep metadata in order:
* From the (built wheel) cache (`packaging` order)
* From pyproject.toml (verbatim specifier)
* From a fresh build (`packaging` order)

This behaviour is unstable: On the first run, we cache is cold, so we
read the verbatim specifier from `pyproject.toml`, then we build and
store the metadata in the cache. On the second run, we read the
`packaging` sorted specifier from the cache.

Reproducer:

```shell
rm -rf newproj
uv init -q --no-config newproj
cd newproj/
uv add -q "anyio>=4,<5"
cat uv.lock | grep "requires-dist"
uv sync -q
cat uv.lock | grep "requires-dist"
cd ..
```

```
requires-dist = [{ name = "anyio", specifier = ">=4,<5" }]
requires-dist = [{ name = "anyio", specifier = "<5,>=4" }]
```

A project either has static metadata, so we can read from
pyproject.toml, or it doesn't, and we always read from the build through
`packaging`. We can use this to stabilize the behavior by slightly
switching the order.

* From pyproject.toml (verbatim specifier)
* From the (built wheel) cache (`packaging` order)
* From a fresh build (`packaging` order)

Potentially, we still want to sort the specifiers we get anyway, after
all, the is no guarantee that the specifiers from a build backend are
deterministic. But our metadata reading behavior should be independent
of the cache state, hence changing the order in the PR.

Fixes #6316
2024-08-21 17:18:42 +02:00
Jo
67360cf5f2
Update env vars doc about XDG_* variables on macOS (#6337)
After #5806, `uv` respects `XDG_*` env vars on macOS as well.
2024-08-21 10:09:26 -05:00
Charlie Marsh
42498c8c63
Ignore workspace discovery errors with --no-workspace (#6328)
## Summary

It's useful to try to discover the workspace, so we can warn, but it's
not good to fail.

Closes https://github.com/astral-sh/uv/issues/6320.
2024-08-21 14:30:01 +00:00
Boris Verkhovskiy
3355259ce6
Link to Trio (#6322) 2024-08-21 07:48:52 -05:00
Severen Redwood
72bd127162
Remove extraneous backtick in help message (#6307) 2024-08-21 07:53:54 +00:00
FishAlchemist
63c5e94726
Delete the preview default value of python-preference in the document. (#6301)
## Summary
I believe the default for the stable ``uv venv`` in [UV
v0.3.0](https://github.com/astral-sh/uv/releases/tag/0.3.0) is managed.
## Test Plan
Running a document server locally.

![image](https://github.com/user-attachments/assets/0f582f07-1332-424b-bb1b-82b19533e14e)
2024-08-21 08:38:50 +02:00
Sergey Filimonov
cd4855326c
Update README.md: Mention uvx is an alias for uv tool run (#6286)
<!--
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?
-->

## Summary

I think it's important to clarify that `uvx` is simply an alias for `uv
tool run`. This distinction helps avoid confusion about when to use `uv`
versus `uvx`. I thought the [blog
post](https://astral.sh/blog/uv-unified-python-packaging) explained this
well.

Just something that I ran into, I understand others may have a different
perspective!

## Test Plan

n/a

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-21 03:01:27 +00:00
Charlie Marsh
b21fa38909
Add export to copy warning (#6294) 2024-08-21 02:29:01 +00:00
Chan Kang
c9774e9c43
allow manylinux compatibility override via _manylinux module. (#6039)
## Summary
resolves https://github.com/astral-sh/uv/issues/5915, not entirely sure
if `manylinux_compatible` should be a separate field in the JSON
returned by the interpreter or there's some way to use the existing
`platform` for it.

## Test Plan
ran the below
```
rm -rf .venv
target/debug/uv venv
# commenting out the line below triggers the change..
# target/debug/uv pip install no-manylinux
target/debug/uv pip install cryptography --no-cache
```

is there an easy way to add this into the existing snapshot-based test
suite? looking around to see if there's a way that doesn't involve
something implementation-dependent like mocks.

~update: i think the output does differ between these two, so probably
we can use that.~ i lied - that "building..." output seems to be
discarded.
2024-08-21 01:57:42 +00:00
Charlie Marsh
2e02d579a0
Invalidate uv.lock when virtual dev-dependencies change (#6291)
## Summary

For non-virtual workspaces, these are covered by the _members_. But for
virtual workspaces, they aren't captured anywhere else in the lock. So,
we weren't invalidating `uv.lock` when the dev dependencies changed,
which led to a panic.

Closes https://github.com/astral-sh/uv/issues/6288
2024-08-21 01:25:38 +00:00
Charlie Marsh
6f34a251e6
Skip override resolution in lock (#6290) 2024-08-21 00:45:07 +00:00
Charlie Marsh
d954a76cb6
Make cache robust to removed archives (#6284)
## Summary

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

## Test Plan

- `cargo run pip install flask --no-binary flask --cache-dir foo
--reinstall`
- `rm -rf foo/archive-v0`
- `cargo run pip install flask --no-binary flask --cache-dir foo
--reinstall`
2024-08-20 19:56:23 -04:00
Charlie Marsh
9892a4ab50
Use atomic write for pip compile output (#6274)
## Summary

This ensures that we don't stream output to the `--output-file`, since
other processes may rely on reading it.

Closes https://github.com/astral-sh/uv/issues/6239.
2024-08-20 20:36:42 +00:00
Zanie Blue
f10ccc488e
Add --with-editable support to uv run (#6262)
Closes https://github.com/astral-sh/uv/issues/6254
2024-08-20 14:04:46 -05:00
Zanie Blue
c3c05c4602
Add blog post to changelog (#6263) 2024-08-20 13:16:54 -05:00
Zanie Blue
dd1934c9c3
Bump version to 0.3.0 (#6260)
[Rendered](https://github.com/astral-sh/uv/blob/zb/030/CHANGELOG.md#030)

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-08-20 12:29:58 -05:00
konsti
e740322549
Impl Ord for ADD MarkerTree (#6253)
The ADD `MarkerTree` was including the non-deterministic, unstable
`NodeId` in its `Ord` implementation since switching algebraic decision
diagrams. By replacing this with a correct `Ord` implementation, we fix
#6249.

Requires https://github.com/astral-sh/pubgrub/pull/31
2024-08-20 19:11:57 +02:00
Charlie Marsh
eb9c38fa33
Copy PREVIEW entries into CHANGELOG (#6261)
Optional change.
2024-08-20 13:05:34 -04:00
Zanie Blue
7742e060d2
Add link to benchmarks in documentation (#6257) 2024-08-20 12:54:46 -04:00
Zanie Blue
35a0896d58
Remove the preview changelog (#6259)
I'll link to the old file in Git from the release changelog for 0.3.0
2024-08-20 16:47:46 +00:00
Charlie Marsh
5ddd84683c
Update BENCHMARKS.md (#6258) 2024-08-20 16:42:57 +00:00
Zanie Blue
2d41973b65
Update the PyPI project description (#6248) 2024-08-20 16:35:06 +00:00
Zanie Blue
c64326255e Rename uv sync --no-clean to uv sync --inexact (#6241) 2024-08-20 11:31:46 -05:00
Zanie Blue
2f86c674a8 Update README for uv 0.3.0 (#6165)
🚀
[Rendered](https://github.com/astral-sh/uv/tree/zb/3-readme?tab=readme-ov-file#uv)
2024-08-20 11:31:46 -05:00
Zanie Blue
c892051aef Move pip compatibility guide to the documentation (#6213)
First, I synced the documents manually following the output of `diff`
then replaced the old one with a link.
2024-08-20 11:31:46 -05:00
Charlie Marsh
732d2fb0fb Remove --legacy-setup-py command-line argument (#4255)
This is a fallback mode that we supported when we decided to use PEP 517
builds by default. I can't find a single reference to it on GitHub or in
our issue tracker, so I want to drop support for it as part of v0.3.0.
2024-08-20 11:31:46 -05:00
Zanie Blue
47fb902104 Apply system Python filtering to executable name requests (#4309)
Executable name requests were being treated as explicit requests to
install into system environments, but I don't think it should be as it's
implicit what environment you'll end up in. Following #4308, we allow
multiple executables to be found so we can filter here.

Concretely, this means `--system` is required to install into a system
environment discovered with e.g. `--python=python`. The flag is still
not required for cases where we're not mutating environment.
2024-08-20 11:31:46 -05:00
Charlie Marsh
01fb41f5c4 Move concurrency settings to top-level (#4257)
These are global and non-specific to the `pip` API, so I think they
should be elevated.

- Ran `UV_CONCURRENT_DOWNLOADS=1 cargo run pip list`; verified that
`downloads` resolved to 1.
- Added `concurrent-downloads = 5` under `[tool.uv]` in
`pyproject.toml`; ran `cargo run pip list`; verified that `downloads`
resolved to 5.
- Ran `UV_CONCURRENT_DOWNLOADS=1 cargo run pip list`; verified that
`downloads` resolved to 1.
2024-08-20 11:31:46 -05:00
Charlie Marsh
e11bbb539a Migrate to XDG and Linux strategy for macOS directories (#5806)
This PR moves us to the Linux strategy for our global directories on
macOS. We both feel on the team _and_ have received feedback (in Issues
and Polls) that the `Application Support` directories are more intended
for GUIs, and CLI tools are correct to respect the XDG variables and use
the same directory paths on Linux and macOS.

Namely, we now use:

- `/Users/crmarsh/.local/share/uv/tools` (for tools)
- `/Users/crmarsh/.local/share/uv/python` (for Pythons)
- `/Users/crmarsh/.cache/uv` (for the cache)

The strategy is such that if the `/Users/crmarsh/Library/Application
Support/uv` already exists, we keep using it -- same goes for
`/Users/crmarsh/Library/Caches/uv`, so **it's entirely backwards
compatible**.

If you want to force a migration to the new schema, you can run:

- `uv cache clean`
- `uv tool uninstall --all`
- `uv python uninstall --all`

Which will clean up the macOS-specific directories, paving the way for
the above paths. In other words, once you run those commands, subsequent
`uv` operations will automatically use the `~/.cache` and `~/.local`
variants.

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

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-20 11:31:46 -05:00
Zanie Blue
04e3e7ce65 Remove preview labeling for uv 0.3.0 (#6166)
- Removes "experimental" labels from command documentation
- Removes preview warnings
- Removes `PreviewMode` from most structs and methods — we could keep it
around but I figure we can propagate it again easily where needed in the
future
- Enables preview behavior by default everywhere, e.g., `uv venv` will
download Python versions
2024-08-20 11:31:46 -05:00
Andrew Gallant
33480d61eb switch to jiff from chrono (#6205)
This PR migrates uv's use of `chrono` to `jiff`.

I did most of this work a while back as one of my tests to ensure Jiff
could actually be used in a real world project. I decided to revive
this because I noticed that `reqwest-retry` dropped its Chrono
dependency,
which is I believe the only other thing requiring Chrono in uv.
(Although, we use a fork of `reqwest-middleware` at present, and that
hasn't been updated to latest upstream yet. I wasn't quite sure of the
process we have for that.)

In course of doing this, I actually made two changes to uv:

First is that the lock file now writes an RFC 3339 timestamp for
`exclude-newer`. Previously, we were using Chrono's `Display`
implementation for this which is a non-standard but "human readable"
format. I think the right thing to do here is an RFC 3339 timestamp.

Second is that, in addition to an RFC 3339 timestamp, `--exclude-newer`
used to accept a "UTC date." But this PR changes it to a "local date."
That is, a date in the user's system configured time zone. I think
this makes more sense than a UTC date, but one alternative is to drop
support for a date and just rely on an RFC 3339 timestamp. The main
motivation here is that automatically assuming UTC is often somewhat
confusing, since just writing an unqualified date like `2024-08-19` is
often assumed to be interpreted relative to the writer's "local" time.
2024-08-20 11:31:46 -05:00
Zanie Blue
c8f27a3978
Increase the size of nav entries (#6233)
It's a common complaint that these are two small. I'm a bit on the fence
here, but we can make them bigger.

Before
<img width="1324" alt="Screenshot 2024-08-19 at 4 30 30 PM"
src="https://github.com/user-attachments/assets/a874b67a-cbd3-4e5c-a3f6-10a259f6b7dc">
After
<img width="1324" alt="Screenshot 2024-08-19 at 4 30 24 PM"
src="https://github.com/user-attachments/assets/9f1f3559-07a1-4926-b6ab-fa3acc44045c">

Before
<img width="602" alt="Screenshot 2024-08-19 at 4 30 59 PM"
src="https://github.com/user-attachments/assets/b9727b3a-cb33-41a5-8880-02b0c36025a2">
After
<img width="602" alt="Screenshot 2024-08-19 at 4 31 24 PM"
src="https://github.com/user-attachments/assets/edc2e66b-1e19-45fa-b658-1d0dc8b849bd">
2024-08-20 11:22:29 -05:00
Charlie Marsh
4e0e50b390
Show python find output with -q (#6256) 2024-08-20 15:44:15 +00:00
Zanie Blue
1e1d9f0e08
Special-case reinstalls in environment update summaries (#6243)
e.g.

```
❯ uv pip install httpx==0.26.0 --reinstall-package httpx
Resolved 7 packages in 67ms
Prepared 1 package in 0.95ms
Uninstalled 1 package in 2ms
Installed 1 package in 12ms
 ~ httpx==0.26.0
```

```
❯ uv add httpx==0.26.0
warning: `uv add` is experimental and may change without warning
warning: `uv.sources` is experimental and may change without warning
Resolved 15 packages in 23ms
   Built example @ file:///Users/zb/workspace/example
Prepared 2 packages in 187ms
Uninstalled 2 packages in 2ms
Installed 2 packages in 2ms
 ~ example==0.1.0 (from file:///Users/zb/workspace/example)
 - httpx==0.27.0
 + httpx==0.26.0
```

Motivated by trying to reduce the diff for project updates in `uv add`.
I think it makes sense in general though. We'll also want a special
output for upgrades in the future, e.g. reducing the `httpx` changes in
the second example to a single line indicating the original and
subsequent distribution versions.

I'd like to have

> Reinstalled 1 package in 2ms

but it seems non-trivial to show the timing for it? I think we'd need to
determine what we want to call a "Reinstall" during the operations and
split doing them from the rest of the uninstalls and installs.
2024-08-20 10:35:33 -05:00