Commit graph

3611 commits

Author SHA1 Message Date
konsti
c2088af78d
Hint at missing quote in marker (#6414)
For https://github.com/astral-sh/uv/issues/6379#issuecomment-2303074836.

Input: `name; python_version == 3.10`
Error:
```
Expected a quoted string or a valid marker name, found '3.10'
name; python_version == 3.10
                        ^^^^
```
2024-08-22 08:15:47 +00:00
Charlie Marsh
681d605bd9
Treat invalid extras as false in marker evaluation (#6395)
## Summary

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

Closes https://github.com/astral-sh/uv/pull/6395.
2024-08-22 01:03:39 +00:00
Charlie Marsh
02f5416bda
Fix extra newline in args (#6396) 2024-08-22 00:44:48 +00:00
Zanie Blue
720814c8f6
Fix duplicate changelog section (#6390) 2024-08-21 23:26:31 +00:00
Charlie Marsh
be17d132ad
Bump version to v0.3.1 (#6385) 2024-08-21 19:07:50 -04:00
Charlie Marsh
19a7f3ec07
Collapse extras on dev dependencies (#6383)
## Summary

It turns out we weren't applying the collapse logic here, so dev deps
with extras were repeated. This was generally ok... unless we ended up
_dropping_ an extra, in which case, you now have a duplicate.

Closes https://github.com/astral-sh/uv/issues/6380.
2024-08-21 22:36:51 +00:00
Zanie Blue
7d90c29552
Fix priority for .python-versions files in uv python install (#6382)
In https://github.com/astral-sh/uv/pull/6359, I accidentally made `uv
python install` prefer `.python-version` files over `.python-versions`
files -.-, kind of niche but it's a regression.
2024-08-21 22:17:14 +00:00
Zanie Blue
7140cdec79
Respect .python-version files and pyproject.toml in uv python find (#6369)
I was surprised to find we didn't do this — we should find Python
versions as we do everywhere else.
2024-08-21 22:08:29 +00:00
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