Commit Graph

2965 Commits

Author SHA1 Message Date
Zanie Blue ca50243174
Add `uv sync --no-install-workspace` to skip installation of all workspace members (#6539)
Extends #6538
See #4028

Another version of https://github.com/astral-sh/uv/pull/6398
2024-08-23 20:39:33 +00:00
Zanie Blue be1599ebf6
Add `uv sync --no-install-project` to skip installation of the project (#6538)
See #4028

A smaller version of https://github.com/astral-sh/uv/pull/6398

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-08-23 20:19:47 +00:00
Zanie Blue 80b5384a4d
Set `VIRTUAL_ENV` for `uv run` invocations (#6543)
If we don't do this, and `uv run` invokes something like `uv run
--isolated uv pip install foo` uv won't mutate the isolated environment,
it'll mutate whatever outer environment it finds.
2024-08-23 20:03:38 +00:00
Charlie Marsh 9d1cd8e48c
Add `UV_COMPILE_BYTECODE` environment variable (#6530)
## Summary

Closes https://github.com/astral-sh/uv/issues/6493.
2024-08-23 18:05:32 +00:00
T-256 d0dda3798d
docs: Use proper environment variables for Windows (#6433)
ref: https://github.com/astral-sh/uv/issues/6397#issuecomment-2304512872
2024-08-23 13:04:08 -05:00
Thomas Quillan 429e6e61a8
Revert changes to pyproject.toml when sync fails duing `uv add` (#6526)
## Summary

<!-- What's the purpose of the change? What does it do, and why? -->
This is a attempt at fixing https://github.com/astral-sh/uv/issues/6486.
It reverts changes made to `pyproject.toml` when sync fails during `uv
add`. This solution felt a little heavy handed and could probably be
improved but it is what happens when locking fails during `uv add` so I
thought it would be a good start.

## Test Plan

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

I have added a test case for this to `tests/edit.rs`. It uses
`pytorch==1.0.2` to achieve the desired failure.
2024-08-23 13:54:33 -04:00
Zanie Blue 4cdca06db2
Add `--no-project` alias for `uv python pin --no-workspace` (#6514)
This matches the other interfaces and seems like an oversight.
2024-08-23 16:08:27 +00:00
Charlie Marsh 57f833c302
Respect `-` as stdin channel for `uv run` (#6481)
## Summary

Closes https://github.com/astral-sh/uv/issues/6467.
2024-08-23 11:49:56 -04:00
Zanie Blue 01fc233dd0
Ignore `.python-version` files in `uv venv` with `--no-config` (#6513)
Dupe of  #6373 — merged into the wrong branch by accident.
2024-08-23 13:56:11 +00:00
Mathieu Kniewallner 7edd78c797
feat(self-update): show old version in update message (#6473)
## Summary

Indicate the previous version from which uv was upgraded when running
`uv self update`. Thought that it could be useful in some situations to
have a trace of the previous version that was installed.

## Test Plan

Did not find a way to test this, since this heavily relies on being able
to use the installation script and the ability to publish artifacts for
a specific tag.
2024-08-23 07:55:47 -05:00
Sofie Van Landeghem 665650fe2e
Two small typo fixes (#6500)
<!--
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

Two small typo fixes: one in the documentation and one in a comment in
the source code I happened to come across.
2024-08-23 12:13:36 +02:00
konsti d8c41481ec
Fix generated docs (#6496)
Follow-up to #6494
2024-08-23 07:45:39 +00:00
Charlie Marsh c5440001ce
Bump version to v0.3.2 (#6483) 2024-08-23 03:11:23 +00:00
Charlie Marsh 9b42142fe7
Avoid overwriting symlinks in `pip compile` output (#6487)
## Summary

Closes https://github.com/astral-sh/uv/issues/6485.
2024-08-23 02:54:45 +00:00
Charlie Marsh be8ad0c507
Restore `cache` suffix on Windows cache path (#6482)
## Summary

We accidentally changed the Windows cache directory from
`C:\Users\User\AppData\Local\uv\cache` to
`C:\Users\User\AppData\Local\uv` in v0.3.0. We're considering this a
bug, since it does _not_ match the documentation, and prior to v0.3.0,
we always used the former. This PR migrates back to the previous
location. It should be seamless for users, as we move the cache items to
the new location on startup.

Closes https://github.com/astral-sh/uv/issues/6417.
2024-08-22 22:04:57 -04:00
Zanie Blue 34dd8401ed
Fix retrieval of credentials for URLs from cache (#6452)
While working on https://github.com/astral-sh/uv/pull/6389 I discovered
we never checked `cache.get_url` here, which is wrong — though I don't
think it had much effect in practice since the realm would typically
match first. The main problem is that when we call `get_url` later we
hard-code the username to `None` because we assume we checked up here
with the username if present.
2024-08-22 19:00:58 -05:00
Charlie Marsh c743705dfb
Revert "Cache downloaded wheel when range requests aren't supported" (#6470)
## Summary

This reverts commit 7d92915f3d.

I thought this would be a net performance improvement, but we've now had
multiple reports that this made locking _extremely_ slow. I also tested
this today with a very large codebase against a registry that does not
support range requests, and the number of downloads was sort of wild to
watch. Reverting the reduced resolution time by over 50%.

Closes #6104.
2024-08-22 19:54:42 -04:00
Zanie Blue 7502a963e1
Add support for configuring `python-downloads` with `UV_PYTHON_DOWNLOADS` (#6436)
Part of https://github.com/astral-sh/uv/issues/6406

Replaces #6416
2024-08-22 23:19:03 +00:00
Zanie Blue 99d278f9f5
Treat `.pyw` files as scripts in `uv run` on Windows (#6453)
Closes https://github.com/astral-sh/uv/issues/6435
2024-08-22 23:07:30 +00:00
Charlie Marsh 9ee52e4e39
Deny invalid members in workspace schema (#6450)
## Summary

This has bitten me a few times.
2024-08-22 16:48:00 -04:00
Charlie Marsh 4591d0b4b2
Remove URI type from JSON Schema (#6449)
## Summary

Relative paths (like `./foo/bar`) are also welcome here!
2024-08-22 16:39:27 -04:00
Zanie Blue 0c8661340e
Add support for configuring the `python-preference` with `UV_PYTHON_PREFERENCE` (#6432)
Part of https://github.com/astral-sh/uv/issues/6406
2024-08-22 10:57:36 -05:00
Zanie Blue 3dd39e6d35
Fix references to `--python-downloads` (it is `--no-python-downloads`) (#6439)
Noticed in https://github.com/astral-sh/uv/pull/6409
2024-08-22 09:22:55 -05:00
Zanie Blue fc9fdd2dbb
Revert "Env variables for python downloads" (#6431)
This reverts commit bbd9adaa40 from #6416
— the Python download variable is not aligned with the setting.
2024-08-22 13:29:09 +00:00
Ahmed Ilyas bbd9adaa40
Env variables for python downloads (#6416)
## Summary

Resolves #6406

## Test Plan

```
❯ UV_PYTHON_PREFERENCE=only-managed cargo run -q -- sync --show-settings | rg python_preference
    python_preference: OnlyManaged,
❯ UV_PYTHON_PREFERENCE=system cargo run -q -- sync --show-settings | rg python_preference
    python_preference: System,
❯ UV_NO_PYTHON_DOWNLOADS=1 cargo run -q -- sync --show-settings | rg python_downloads
    python_downloads: Never,
❯ UV_ALLOW_PYTHON_DOWNLOADS=1 cargo run -q -- sync --show-settings | rg python_downloads
    python_downloads: Automatic,
```
2024-08-22 08:52:52 -04:00
Michał Górny 04e2ff57aa
Mark emit_marker_expression* tests as requiring python-patch (#6411)
## Summary

Mark the new tests requiring Python 3.12.1 specifically as requiring
python-patch feature. This makes the test suite pass again on systems
not having this specific version (and disabling the feature).

## Test Plan

`cargo test` on Gentoo :-).
2024-08-22 10:37:40 +02:00
konsti dc94b4836f
Use backticks in pep508-rs (#6415)
In accordance with the style guide, use backticks in pep508-rs error
messages.
2024-08-22 08:31:04 +00:00
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
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
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