Commit graph

3079 commits

Author SHA1 Message Date
Michal Čihař
01f4beeafe
Differentiate startup and compile timeouts (#6958)
<!--
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

Separate exceptions for different timeouts to make it easier to debug
issues like #6105.

<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan

<!-- How was it tested? -->
Not tested at all.
2024-09-03 10:32:43 +02:00
konsti
9e34c42cec
Move unreachable wheels check (#6957)
Prep for fixing #6512. No functional changes.
2024-09-03 07:48:54 +00:00
Charlie Marsh
ccdf2d793b
Add --no-hashes to uv export (#6954)
## Summary

Closes https://github.com/astral-sh/uv/issues/6944.
2024-09-02 22:12:29 -04:00
eth3lbert
ad82b94856
Support file:// URLs for UV_PYTHON_INSTALL_MIRROR (#6950)
## Summary

Closes #6319.

## Test Plan

I tested with `file:///mirror`, `file://localhost/mirror`, and
`http://mirror` to confirm that it was working as expected.

``` shell-session
/private/tmp/mirror-local                                                                                                                                                                      07:08:18
:)  tree mirror 
mirror/
└── 20240814/
   └── cpython-3.12.5+20240814-aarch64-apple-darwin-install_only_stripped.tar.gz
```

<img width="626" alt="image"
src="https://github.com/user-attachments/assets/9c04224d-305c-47ee-a524-4a6abeb79da4">
2024-09-03 01:20:01 +00:00
Charlie Marsh
7c37bae8f1
Avoid canonicalizing cache directory (#6949)
Taking a look at #6948.
2024-09-03 00:11:44 +00:00
Charlie Marsh
47f4ca24b3
Bump version to v0.4.3 (#6947) 2024-09-02 17:18:57 -04:00
Charlie Marsh
f9c04581e6
Allow uv sync --package without copying member pyproject.toml (#6943)
## Summary

Closes https://github.com/astral-sh/uv/issues/6935.
2024-09-02 21:01:50 +00:00
Charlie Marsh
6897001fee
Stream build backend output to debug! (#6903)
## Summary

We need to decide whether we want this in `debug!` or `tracing!`. We
also _probably_ (?) want to show this by default in `uv build`.

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

Closes https://github.com/astral-sh/uv/issues/5893.
2024-09-02 19:46:09 +00:00
Charlie Marsh
8eef1a2314
Use lower-bound semantics for all Python compatibility comparisons (#6882)
## Summary

Right now, we have slightly different `requires-python` semantics for
`-p 3.11` vs. `-p 3.11 --universal`, and slightly different (wrong)
semantics for how we compare against the _installed_ Python version
(which doesn't ignore upper bounds, but should).

This PR rips it all out and replaces it with consistent semantics across
`uv lock`, `uv pip compile -p 3.11`, and `uv pip compile -p 3.11
--universal`. We now always ignore upper bounds.

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

Closes https://github.com/astral-sh/uv/issues/5045.
2024-09-02 18:23:42 +00:00
Charlie Marsh
cbe2827e97
Avoid updating incorrect dependencies for sorted uv add (#6939)
## Summary

The indexes stored in the edits is wrong now that we add dependencies
out-of-order.

Closes https://github.com/astral-sh/uv/issues/6933.
2024-09-02 14:21:25 -04:00
Charlie Marsh
42a4d80a63
Add source distribution support to uv-build crate (#6896)
## Summary

Just exposes the correct PEP 517 hooks.
2024-09-02 18:14:49 +00:00
konsti
9edf2d8132
Avoid panic with missing temporary directory (#6929)
Forward an error for missing temp directories:

```
$ env TMPDIR=.tmp uv-debug pip install httpx
  error: No such file or directory (os error 2) at path "/home/konsti/projects/uv/.tmp/.tmpgIBhhh"
```

Fixes #6878
2024-09-02 07:32:42 +00:00
Charlie Marsh
7e6df8ffd4
Remove canonicalize calls (#6919)
## Summary

A few of these should use `absolute` instead of `canonicalize`; and
apparently we no longer need to strip the `CANONICAL_CWD` to get tests
passing.
2024-09-01 18:23:11 +00:00
Chao Ning
ae3f35cfe2
fix: replace std::fs::canonicalize with Simplified::simple_canonicaliz… (#6776)
## Summary
This PR addresses an issue on Windows where `std::fs::canonicalize` can
fail or panic when resolving paths on mapped network drives. By
replacing it with `Simplified::simple_canonicalize`, we aim to improve
the robustness and cross-platform compatibility of path resolution.

### Changes
* Updated `CANONICAL_CWD` in `path.rs` to use
`Simplified::simple_canonicalize` instead of `std::fs::canonicalize`.

### Why
* `std::fs::canonicalize` has known issues with resolving paths on
mapped network drives on Windows, which can lead to panics or incorrect
path resolution.
* `Simplified::simple_canonicalize` internally uses
`dunce::canonicalize`, which handles these cases more gracefully,
ensuring better stability and reliability.

## Test Plan
Since `simple_canonicalize` has already been tested in a prior PR, this
change is expected to work without introducing any new issues. No
additional tests are necessary beyond ensuring existing tests pass,
which will confirm the correctness of the change.
2024-09-01 13:59:15 -04:00
Charlie Marsh
736ccb950a
Bump version to v0.4.2 (#6916) 2024-09-01 13:37:27 -04:00
Charlie Marsh
049c73d09e
Remove dangling archives in uv cache clean ${package} (#6915)
## Summary

Closes https://github.com/astral-sh/uv/issues/6909.
2024-09-01 13:27:13 -04:00
Ed Morley
a5f1e1c765
Fix typos in docs, error messages and comments (#6910) 2024-09-01 11:37:43 +00:00
Charlie Marsh
3e647b139e
Fix is_disjoint check for supported environments (#6902) 2024-08-31 19:01:47 -04:00
Charlie Marsh
83467f0a51
Fix typos (#6891) 2024-08-30 19:45:33 -04:00
Vikas
b441678cf6
Adding support for .pyc files in uv run (#6886)
## Summary
- The change relates to #6635 is to include compiled python files (.pyc)
in the uv run command.
- After this change `uv run foo.pyc` should spawn `python foo.pyc`.


## Test Plan
- There is a test that uses TestContext to compile and run a simple
python file that prints "Hello World".
- I built the project locally and tried the same with a simple python
file that I had compiled.
2024-08-30 19:45:24 -04:00
Charlie Marsh
a4bd875973
Remove unnecessary wheel from test dependencies (#6889) 2024-08-30 16:43:09 -04:00
konsti
00c98a82b0
Use from_range_bounds (#6879)
Not the most ergonomic api pubgrub has to offer, but better than rolling
our own.
2024-08-30 16:06:55 -04:00
Charlie Marsh
34435d7d9d
Error when discovered Python is incompatible with --isolated workspace (#6885)
## Summary

We should have consistent errors with and without `--isolated`.
2024-08-30 19:40:38 +00:00
Charlie Marsh
f21f1f29c6
Warn when discovered Python is incompatible with PEP 723 script (#6884)
## Summary

Closes https://github.com/astral-sh/uv/issues/6883.
2024-08-30 19:26:49 +00:00
Charlie Marsh
fa1498396e
Treat missing top_level.txt as non-fatal (#6881)
## Summary

Closes https://github.com/astral-sh/uv/issues/6872.
2024-08-30 19:02:06 +00:00
Charlie Marsh
823f23e225
Bump version to v0.4.1 (#6870) 2024-08-30 10:07:06 -04:00
Charlie Marsh
50c5fe96ec
Avoid stripping root for user path display (#6865)
## Summary

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

## Test Plan

```
❯ ~/workspace/uv/target/debug/uv pip list --verbose
DEBUG uv 0.4.0
DEBUG Searching for Python interpreter in system path
DEBUG Found `cpython-3.12.3-macos-aarch64-none` at `/Users/crmarsh/.local/share/rtx/installs/python/3.12.3/bin/python3` (search path)
DEBUG Using Python 3.12.3 environment at /Users/crmarsh/.local/share/rtx/installs/python/3.12.3/bin/python3
```
2024-08-30 09:50:22 -04:00
Charlie Marsh
95416ad52e
Take unowned request in PythonInstallation::find_or_download (#6868) 2024-08-30 13:49:17 +00:00
Charlie Marsh
a1805d175e
Allow @ references in uv tool install --from (#6842)
## Summary

Closes https://github.com/astral-sh/uv/issues/6796.
2024-08-30 13:00:17 +00:00
Amos Wenger
3e207da3bc
ci(windows): Introduce setup-dev-drive.ps1, maximize dev drive usage (#6858)
As suggested by @samypr100 on #6680:
https://github.com/astral-sh/uv/pull/6680#issuecomment-2313607984

## Summary

Instead of using `UV_INTERNAL__TEST_DIR`, it simply exports `TEMP` when
running Windows jobs.

## Test Plan

I'm going to run this manually under ProcMon on my Windows machine and
see where uv writes temp files, hopefully to the dev drive and not
`%(LOCAL)APPDATA%` or something.

I'm going to commit a dummy code change and look at build time changes
in CI.
2024-08-30 08:54:25 -04:00
samypr100
8674968a17
fix: adjust trampoline close_handles invalid to be safer (#6792)
## Summary

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

On cases like the ones described in
https://github.com/astral-sh/uv/issues/6699, `lpReserved2` somehow seems
to report multiple file descriptors that were not tied to any valid
handles. The previous implementation was faulting as it would try to
dereference these invalid handles. This change moves to using `HANDLE`
directly and check if its is_invalid instead before attempting to close
them.

## Test Plan

Manually tested and verified using `busybox-w32` like described in the
issue.

---------

Co-authored-by: konstin <konstin@mailbox.org>
2024-08-30 08:55:27 +00:00
Charlie Marsh
9f8ebca941
Error when user-provided environments are disjoint with Python (#6841) 2024-08-29 20:18:30 -04:00
Zanie Blue
97e6861b35
Fix uv init --no-project alias (#6837) 2024-08-29 17:40:19 -05:00
konsti
2215448a8e
Normalize specifiers by sorting (#6333)
We currently normalize package and extra names and drop the whitespace
from version specifiers, but we were not normalizing the order of the
specifiers. By sorting them we match the behavior of `packaging` and
become independent of build backends reordering specifiers (#6332).

Surprisingly, the snapshot diff isn't large - most people were already
writing sorted specifiers. Still, this will lead to observable
differences in lockfiles between releases in cases where there are
entries in `requires-dist` that were not previously sorted (while the
total number of `requires-dist` is already small compared to the overall
lockfile).
2024-08-29 21:06:19 +00:00
konsti
9814852295
Discover Microsoft Store Pythons (#6807)
Microsoft Store Pythons do not always register themselves in the
registry, so we port
<58ce131037/PC/launcher2.c (L1744)>
and look them up on the filesystem in known locations.

## Test Plan

So far I've confirmed that we find a store Python when I use `cargo run
python list`, can we make this a part of any of the platform tests
maybe?
2024-08-29 20:56:41 +00:00
konsti
a39eb61ade
Use windows registry to discover python (#6761)
Our current strategy of parsing the output of `py --list-paths` to get
the installed python versions on windows is brittle (#6524, missing
`py`, etc.) and it's slow (10ms last time i measured).

Instead, we should behave spec-compliant and read the python versions
from the registry following PEP 514.

It's not fully clear which errors we should ignore and which ones we
need to raise.

We're using the official rust-for-windows crates for accessing the
registry.

Fixes #1521
Fixes #6524
2024-08-29 22:48:22 +02:00
Zanie Blue
206b136f13
Improve logging for locked file acquisition (#6777)
Consistency etc. when debugging a deadlock
2024-08-29 20:35:39 +00:00
Charlie Marsh
0ce6d75752
Expand tildes when matching against PATH (#6829)
## Summary

Closes https://github.com/astral-sh/uv/issues/6802.
2024-08-29 19:50:09 +00:00
konsti
0b16d10b27
Don't build uv-dev by default (#6827)
Most times we compile with `cargo build`, we don't actually need
`uv-dev`. By making `uv-dev` dependent on a new `dev` feature, it
doesn't get built by default anymore, but only when passing `--features
dev`.

Hopefully a small improvement for compile times or at least system load.
2024-08-29 15:44:13 -04:00
Charlie Marsh
34d74501ac
Respect the user's upper-bound in requires-python (#6824)
## Summary

We now respect the user-provided upper-bound in for `requires-python`.
So, if the user has `requires-python = "==3.11.*"`, we won't explore
forks that have `python_version >= '3.12'`, for example.

However, we continue to _only_ compare the lower bounds when assessing
whether a dependency is compatible with a given Python range.

Closes https://github.com/astral-sh/uv/issues/6150.
2024-08-29 18:37:05 +00:00
Zanie Blue
a17c1e8e40
Add test coverage for Python version discovery with prereleases (#6823)
Coverage for https://github.com/astral-sh/uv/pull/6813 — reverting that
commit causes the 3.11.0b0 test case to fail.
2024-08-29 13:29:22 -05:00
Andrew Gallant
9ea03ceb38
uv-cli: add worktree support to build.rs (#6825)
Previously, we were always asking Cargo to rebuild `uv-cli` if
`.git/HEAD` had changed. But in a worktree, `.git` is a file, not a
directory. And the file contains the path to git's internal worktree
state, which also has its own `HEAD` file. So in the case of a worktree,
we read the file and tell Cargo to watch the worktree-specific `HEAD`
file instead of `.git/head`.

The main thing this fixes is that, previously, in a worktree, `cargo
build` would *always* re-compile `uv` even if nothing changed.

This doesn't impact or fix anything in "typical" clones of uv though.
Only in worktrees.

Closes #6196, Closes #6197
2024-08-29 14:11:50 -04:00
Charlie Marsh
cbfc928a9c
Add uv export --format requirements.txt (#6778)
## Summary

The interface here is intentionally a bit more limited than `uv pip
compile`, because we don't want `requirements.txt` to be a system of
record -- it's just an export format. So, we don't write annotation
comments (i.e., which dependency is requested from which), we don't
allow writing extras, etc. It's just a flat list of requirements, with
their markers and hashes.

Closes #6007.

Closes #6668.

Closes #6670.
2024-08-29 17:46:42 +00:00
Charlie Marsh
d62952ec21
Hint at --no-workspace in uv init failures (#6815)
## Summary

We now both (1) include the `pyproject.toml` (which we were doing
sometimes, but inconsistently) and (2) hint at `--no-workspace`).

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

## Test Plan

Looks like this now:

![Screenshot 2024-08-29 at 10 44
55 AM](https://github.com/user-attachments/assets/a7c4cbff-704b-4dac-b0e4-e8e12a2b1f5d)
2024-08-29 12:57:09 -04:00
Charlie Marsh
f046e54c64
Ignore pre-release segments when discovering via requires-python (#6813)
## Summary

`3.13.0b0` should be allowed by `>=3.13`.

Closes #6798.
2024-08-29 11:45:29 -05:00
Zanie Blue
e3d5d3d26d
Avoid deadlocks when multiple uv processes lock resources (#6790)
This is achieved by updating the `LockedFile::acquire` API to be async —
as in some cases we were attempting to acquire the lock synchronously,
i.e., without yielding, which blocked the runtime.

Closes https://github.com/astral-sh/uv/issues/6691 — I tested with the
reproduction there and a local release build and no longer reproduce the
deadlock with these changes.

Some additional context in the [internal Discord
thread](1278478941)
2024-08-29 11:16:14 -05:00
Chan Kang
4f5356ed55
sort dependencies in pyproject.toml (#6388)
## Summary
resolves https://github.com/astral-sh/uv/issues/6203

## Test Plan
added a test fixing the bug described in the issue.

---------

Co-authored-by: konstin <konstin@mailbox.org>
2024-08-29 16:55:03 +02:00
my1e5
f956ab8fae
Update default hello.py to pass ruff format (#6811)
Closes https://github.com/astral-sh/uv/issues/6808
2024-08-29 10:31:52 -04:00
github-actions[bot]
3be4fe59d7
Sync latest Python releases (#6784) 2024-08-29 03:41:07 +00:00
Charlie Marsh
933d4ef3b6
Support inline optional tables in uv add and uv remove (#6787)
## Summary

Closes https://github.com/astral-sh/uv/issues/6785.
2024-08-29 02:08:31 +00:00