Commit graph

3057 commits

Author SHA1 Message Date
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
Charlie Marsh
c166e65ba6
Move lock.rs into its own module (#6775)
## Summary

Desperately need the ability to start splitting up code here.
2024-08-28 18:04:45 -04:00
Zanie Blue
4a98e1eceb
Avoid using debug representation for git source urls (#6779)
e.g.

> DEBUG Using existing Git source
`https://github.com/StarfishStorage/python-swiftclient.git`

instead of

> DEBUG Using existing git source `Url { scheme: "https",
cannot_be_a_base: false, username: "", password: None, host:
Some(Domain("github.com")), port: None, path:
"/StarfishStorage/gunicorn.git", query: None, fragment: None }`
2024-08-28 22:02:24 +00:00
Charlie Marsh
d9bd3bc7a5
Bump to v0.4.0 (#6764) 2024-08-28 17:29:16 +00:00
Ahmed Ilyas
9f0346592f
Add colors to the CLI help menu (#6280)
## Summary

Adds colors to the CLI output.

## Test Plan


<img width="526" alt="Screenshot 2024-08-21 at 00 06 40"
src="https://github.com/user-attachments/assets/88388272-659e-49d4-a641-83f64de55cf0">
<img width="879" alt="Screenshot 2024-08-21 at 00 06 57"
src="https://github.com/user-attachments/assets/26522bd3-c9cf-4359-a8d3-e5c9c72a54aa">
2024-08-28 11:43:52 -05:00
Charlie Marsh
cef3d35405
Support {package}@{version} in uv tool install (#6762)
## Summary

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

Closes https://github.com/astral-sh/uv/issues/6535.
2024-08-28 12:40:49 -04:00
Charlie Marsh
af323888ee
Accept either strings or structs for hosts (#6763)
## Summary

Technically a struct did work in the last release, so let's not break
it.
2024-08-28 16:36:12 +00:00
leaf-soba
71f5998752
Avoid showing duplicate paths in uv python list (#6740)
<!--
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
- Resolves issue #6690
<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan
```
$ cargo run python list
```
<!-- How was it tested? -->

---------

Co-authored-by: leaf-soba <leaf-soba@gmail.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-28 10:48:17 -05:00
Charlie Marsh
6a8da7dff8
Compare virtual members when invalidating lockfile (#6754)
## Summary

Whether a package is itself virtual isn't captured in the package
metadata, so we have to compare the sources.

Closes https://github.com/astral-sh/uv/issues/6749.
2024-08-28 15:11:16 +00:00
renovate[bot]
1309f24c43
Update Rust crate windows-sys to 0.59.0 (#5785)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [windows-sys](https://togithub.com/microsoft/windows-rs) |
workspace.dependencies | minor | `0.52.0` -> `0.59.0` |

---

### Release Notes

<details>
<summary>microsoft/windows-rs (windows-sys)</summary>

###
[`v0.59.0`](https://togithub.com/microsoft/windows-rs/releases/tag/0.59.0)

[Compare
Source](https://togithub.com/microsoft/windows-rs/compare/0.52.0...0.59.0)

This release includes an update to the
[windows-sys](https://crates.io/crates/windows-sys) crate only. The
`windows-sys` crate is updated very infrequently and only when there is
an explicit need to do so. The 0.59.0 release includes a rollup of API
fixes, updates, and additions since the
[0.52.0](https://togithub.com/microsoft/windows-rs/releases/tag/0.52.0)
release nine months ago. Notably:

- This update introduces support for Arm64EC
([#&#8203;2957](https://togithub.com/microsoft/windows-rs/issues/2957))
- Updated bindings for the latest APIs
https://github.com/microsoft/windows-rs/tree/0.59.0/crates/libs/bindgen/default
- Derive standard traits
([#&#8203;3041](https://togithub.com/microsoft/windows-rs/issues/3041))
-   Updates to code generation to handle newer Rust warnings and lints
- Overall smaller crate and more efficient code gen to reduce build time
- Support for feature search
https://microsoft.github.io/windows-rs/features/#/0.59.0
-   MSRV is updated to 1.60

**Full Changelog**:
https://github.com/microsoft/windows-rs/compare/0.52.0...0.59.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/astral-sh/uv).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM4LjU2LjAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbImludGVybmFsIl19-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-28 08:43:59 -05:00
Charlie Marsh
53ef633c6d
Do not require workspace members to sync with --frozen (#6737)
## Summary

Closes https://github.com/astral-sh/uv/issues/6685.
2024-08-28 07:58:50 -04:00
Charlie Marsh
485e0d2748
Avoid including non-excluded members in parent workspaces (#6735)
## Summary

If you're in a directory, and there's workspace above it, we check if
the directory is excluded from the workspace members... But not if it's
_included_ in the first place.

Closes https://github.com/astral-sh/uv/issues/6732.
2024-08-28 01:39:46 +00:00
Charlie Marsh
56cc0c9b3c
Avoid using editable tag in lockfile for non-package dependencies (#6728)
## Summary

Use a dedicated source type for non-package requirements. Also enables
us to support non-package `path` dependencies _and_ removes the need to
have the member `pyproject.toml` files available when we sync _and_
makes it explicit which dependencies are virtual vs. not (as evidenced
by the snapshot changes). All good things!
2024-08-28 01:19:05 +00:00
Charlie Marsh
8fdb3a882e
Read hash from URL fragment if --hashes are omitted (#6731)
## Summary

Like pip, if `--hashes` are omitted but there's a valid hash in the URL
fragment, we should respect it.

Closes https://github.com/astral-sh/uv/issues/6701.
2024-08-28 00:03:01 +00:00
Charlie Marsh
b01c16a666
Recommend [project] table in uv add for non-project directories (#6725) 2024-08-27 23:51:15 +00:00
Charlie Marsh
3ee6ca31f4
Rename virtual workspace roots to non-project workspace roots (#6717)
## Summary

Closes https://github.com/astral-sh/uv/issues/6709.
2024-08-27 21:36:40 +00:00
Amos Wenger
2c5cc62106
ci: Make Windows tests ~27% faster by putting temp folder in dev drive (#6680)
## Summary

This PR makes `cargo test | windows` faster in CI.

### Before

![Windows tests take
5m44s](https://github.com/user-attachments/assets/8dd9c619-9b7b-4ebd-a027-56e7967b6d34)

### After

![Windows tests take
5m12s](https://github.com/user-attachments/assets/7702fdba-3034-4db8-b211-85207a1feffa)

## Also

This PR disables the `brotli` feature of `async-compression` since it's
not strictly needed, but this has little to do with the improvements
(it's still less code to build).

This PR introduces additional code in uv tool uninstall to ignore errors
(that only seem to happen on ReFS, ie. on Dev Drives) akin to "the thing
we're trying to delete cannot be deleted because it's already being
deleted".

If `raw_os_error` was stable we could do u32 matching instead of that
`.to_string().contains()` abomination.
2024-08-27 15:25:05 -05:00
Charlie Marsh
ffb0c304d1
Implement deserialization for trusted host (#6716) 2024-08-27 19:30:44 +00:00
Charlie Marsh
14074f8775
Avoid reading stale .egg-info from mutable sources (#6714)
## Summary

In theory this problem already existed for `PKG-INFO`, but `egg-info`
would be more common, I think, since it's built in the source tree.

Closes https://github.com/astral-sh/uv/issues/6712.
2024-08-27 19:23:26 +00:00
Charlie Marsh
a999303d2f
Use PathBuf types in Source enum (#6708) 2024-08-27 14:46:39 -04:00
Zanie Blue
bc5b069a61
Add --app and --lib options to uv init (#6689)
Changes the `uv init` experience with a focus on working for more
use-cases out of the box.

- Adds `--app` and `--lib` options to control the created project style
- Changes the default from a library with `src/` and a build backend
(`--lib`) to an application that is not packaged (`--app`)
- Hides the `--virtual` option and replaces it with `--package` and
`--no-package`
- `--no-package` is not allowed with `--lib` right now, but it could be
in the future once we understand a use-case
- Creates a runnable project
- Applications have a `hello.py` file which you can run with `uv run
hello.py`
- Packaged applications, e.g., `uv init --app --package` create a
package and script entrypoint, which you can run with `uv run hello`
- Libraries provide a demo API function, e.g., `uv run python -c "import
name; print(name.hello())"` — this is unchanged

Closes #6471
2024-08-27 18:08:09 +00:00
Charlie Marsh
8d466db080
Avoid writing invalid PEP 723 scripts on tool.uv.sources (#6706)
## Summary

We were writing empty lines between the dependencies and the
`tool.uv.sources` table, which led to the `/// script` tag being
unclosed and thus not recognized.

Closes https://github.com/astral-sh/uv/issues/6700.
2024-08-27 17:49:08 +00:00
Charlie Marsh
a8f4e08d5b
Warn on unclosed script tags (#6704)
Should this be user-facing by default? It seems annoying because then
it's unavoidable if you (for whatever reason) have an intentionally
unclosed tag.

Motivated by https://github.com/astral-sh/uv/issues/6700.
2024-08-27 17:47:11 +00:00