Commit Graph

5715 Commits

Author SHA1 Message Date
Zanie Blue 1f963d1b89
Move content from the `mkdocs.public.yml` into the template (#11246)
Closes https://github.com/astral-sh/uv/issues/11242
2025-02-05 16:13:46 +00:00
Zanie Blue acbbb2b82a
Add `--bare` option to `uv init` (#11192)
People are looking for a less opinionated version of `uv init`. The goal
here is to create a `pyproject.toml` and nothing else. With the `--lib`
or `--package` flags, we'll still configure a build backend but we won't
create the source tree. This disables things like the default
`description`, author behavior, and VCS.

See

- https://github.com/astral-sh/uv/issues/8178
- https://github.com/astral-sh/uv/issues/7181
- https://github.com/astral-sh/uv/issues/6750
2025-02-05 10:12:27 -06:00
Zanie Blue 989b103171
Add support for respecting `VIRTUAL_ENV` in project commands via `--active` (#11189)
I think `UV_PROJECT_ENVIRONMENT` is too complicated for use-cases where
the user wants to sync to the active environment. I don't see a
compelling reason not to make opt-in easier. I see a lot of questions
about how to deal with this warning in the issue tracker, but it seems
painful to collect them here for posterity.

A notable behavior here — we'll treat this as equivalent to
`UV_PROJECT_ENVIRONMENT` so... if you point us to a valid virtual
environment that needs to be recreated for some reason (e.g., new Python
version request), we'll happily delete it and start over.
2025-02-05 10:12:19 -06:00
Jo 6f8d9b85d8
Remove `cachedir` dependency (#11240)
## Summary

Vendor the `HEADER` constant too so we can eliminate the dependency on
`cachedir`.
2025-02-05 08:54:02 -05:00
Charlie Marsh ee2bdc21fa
Disable wheel testing for `powerpc64le-unknown-linux-gnu` (#11229)
## Summary

I need to look into this later, but the test step is failing to install
Python:
https://github.com/astral-sh/uv/actions/runs/13148286589/job/36694160839.
We already disable this for the non-`le` variant, so this seems ok to
revisit.
2025-02-04 22:46:08 -05:00
Charlie Marsh fea00dcdd5
Bump version to v0.5.28 (#11228) 2025-02-04 20:28:43 -05:00
Charlie Marsh f615e81ad5
Clear ephemeral overlays when running tools (#11141)
## Summary

This PR removes the ephemeral `.pth` overlay when using a cached
environment. This solution isn't _completely_ safe, since we could
remove the `.pth` file just as another process is starting the
environment... But that risk already exists today, since we could
_overwrite_ the `.pth` file just as another process is starting the
environment, so I think what I've added here is a strict improvement.

Ideally, we wouldn't write this file at all, and we'd instead somehow
(e.g.) pass a file to the interpreter to run at startup? Or find some
other solution that doesn't require poisoning the cache like this.

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

# Test Plan

Ran through the great reproduction steps from the linked issue.

Before:

![Screenshot 2025-01-31 at 2 11
31 PM](https://github.com/user-attachments/assets/d36e1db5-27b1-483a-9ced-bec67bd7081d)

After:

![Screenshot 2025-01-31 at 2 11
39 PM](https://github.com/user-attachments/assets/1f963ce0-7903-4acd-9fd6-753374c31705)
2025-02-04 22:45:45 +00:00
Charlie Marsh 2fad82c735
Set base executable when returning virtual environment (#11209)
## Summary

I'm not sure that this has much of an effect in practice, but currently,
when we return a virtual environment, the `sys_base_executable ` of the
parent ends up being retained as `sys_base_executable` of the created
environment. But these can be, like, subtly different? If you have a
symlink to a Python, then for the symlink, `sys_base_executable` will be
equal to `sys_executable`. But when you create a virtual environment for
that interpreter, we'll set `home` to the resolved symlink, and so
`sys_base_executable` will be the resolved symlink too, in general.
Anyway, this means that we should now have a consistent value between
(1) returning `Virtualenv` from the creation routine and (2) querying
the created interpreter.
2025-02-04 22:32:47 +00:00
Charlie Marsh 34552e2d3d
Use base Python for cached environments (#11208)
## Summary

It turns out that we were returning slightly different interpreter paths
on repeated `uv run --with` commands. This likely didn't affect many (or
any?) users, but it does affect our test suite, since in the test suite,
we use a symlinked interpreter.

The issue is that on first invocation, we create the virtual
environment, and that returns the path to the `python` executable in the
environment. On second invocation, we return the `python3` executable,
since that gets priority during discovery. This on its own is
potentially ok. The issue is that these resolve to different
`sys._base_executable` values in these flows... The latter gets the
correct value (since it's read from the `home` key), but the former gets
the incorrect value (since it's just the `base_executable` of the
executable that created the virtualenv, which is the symlink).

We now use the same logic to determine the "cached interpreter" as in
virtual environment creation, to ensure consistency between those paths.
2025-02-04 17:23:06 -05:00
Zanie Blue ec480bd3ee
Allow discovering virtual environments from the first interpreter found on the `PATH` (#11218)
Closes https://github.com/astral-sh/uv/issues/11214

Special-cases the first Python executable we find on the `PATH`,
allowing it to be considered during searches for virtual environments.

For some context, there are two stages to Python interpreter discovery

1. We find possible Python executables in various sources
2. We query the executables to determine canonical metadata about the
interpreter

We can't really be "sure" if an executable is a complaint virtual
environment during (1), we need to query the interpreter first. This
means that if you're only allowed to installed into virtual
environments, we'll query every interpreter on your PATH. This is not
performant, and causes confusion for users. Notably, I recently improved
error messaging when we can't find any valid interpreters, by showing
the error message we encounter while querying an interpreter (if any).
However, this is problematic when there's an error for an interpreter
that is not relevant to your search. In
https://github.com/astral-sh/uv/pull/11143, I added filtering to avoid
querying additional interpreters, but that regressed some user
experiences where they were relying on us finding implicitly active
virtual environments via the PATH.
2025-02-04 15:41:37 -06:00
Martijn Pieters 04374b03cc
Docs on how to verify uv docker image attestations (#11140)
As [requested by
@zanieb](https://github.com/astral-sh/uv/pull/8685#issuecomment-2627556992).
2025-02-04 15:38:19 -06:00
konsti ac1004284a
Fix hardlinks in tar unpacking (#11221)
In https://github.com/astral-sh/tokio-tar/pull/2, we accidentally
changed the `target_base` from the target base to the parent of the
file. This would cause hardlink unpacking to fail.

Example: A hardlink at `hardlinked-0.1.0/pyproject.toml` pointing to
`hardlinked-0.1.0/pyproject.toml.real` would try pointing to
`hardlinked-0.1.0/hardlinked-0.1.0/pyproject.toml.real` instead and fail
the unpacking.

The actual fix is in astral-tokio-tar, on the uv side there are only tests.

Fixes #11213
2025-02-04 17:38:22 +00:00
Charlie Marsh 748582ee6f
Disable SSL in Git commands for `--allow-insecure-host` (#11210)
## Summary

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

## Test Plan

- Created a self-signed certificate.
- Ran `openssl s_server -cert cert.pem -key key.pem -WWW -port 8443`.
- Verified that `cargo run pip install
git+https://localhost:8443/repo.git` failed with:

```
error: Git operation failed
  Caused by: failed to fetch into: /Users/crmarsh/.cache/uv/git-v0/db/0773914b3ec4a56e
  Caused by: process didn't exit successfully: `/usr/bin/git fetch --force --update-head-ok 'https://localhost:8443/repo.git' '+HEAD:refs/remotes/origin/HEAD'` (exit status: 128)
--- stderr
fatal: unable to access 'https://localhost:8443/repo.git/': SSL certificate problem: self signed certificate
```

- Verified that `cargo run pip install
git+https://localhost:8443/repo.git --allow-insecure-host
https://localhost:8443` continued further.
2025-02-04 10:57:57 -05:00
konsti d9907f6fda
Update resolver internals docs (#11098)
Since the resolver internals docs were written, we added a lot more
features to the resolver, which should be documented.

As usual, these docs are not targeted at regular users, but should give
interested readers an insight into the internals of uv and help advanced
users with especially hard resolver problems.
2025-02-04 13:06:27 +00:00
konsti 1d9db68511
Move wheel helper function to wheel module (#11212)
No functional changes.
2025-02-04 12:03:38 +00:00
Matthieu Ancellin 241561979f
Fix typo "dependency-group" in error message and comments (#11211)
<!--
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 got a bit confused when testing `[dependency-groups]` because uv's
error message had the same typo I did in my `pyproject.toml`.
I tried to fix it, as well as a few comment I found along the way.
2025-02-04 12:16:05 +01:00
FishAlchemist 49b85d2e65
Add ``last updated`` for document (#11164)
## Summary

![image](https://github.com/user-attachments/assets/75431f9f-debe-435d-a02e-d216be7a3a01)

![image](https://github.com/user-attachments/assets/2d1b895e-4878-410e-90ff-ff8e932cbf24)
Display the last document update time, excluding any automatically
generated parts of the document, while ensuring that Google can
accurately read and recognize the webpage's time.

Note that I do not have permission to update
``requirements-insiders.txt``


Google time info
*
https://developers.google.com/search/blog/2019/03/help-google-search-know-best-date-for
*
https://developers.google.com/search/docs/appearance/structured-data/article#amp

Similar https://github.com/astral-sh/uv/pull/11162
Closes #11148
## Test Plan
uvx --with-requirements docs/requirements.txt -- mkdocs serve -f
mkdocs.public.yml --strict

![image](https://github.com/user-attachments/assets/6e8cd609-2e60-489c-97cc-fb28aa3204e0)
The correct format is actually ``2024-08-08T22:01:08Z``, but Google
Search happens to be lenient and accepts this format.

![image](https://github.com/user-attachments/assets/2ec8ce98-49ea-403b-bbd2-3d0d5630a562)
2025-02-03 22:28:47 -05:00
Zanie Blue 73e9928d40
Bump version to 0.5.27 (#11201) 2025-02-03 16:55:36 -06:00
Gregory Power f54979f2bc
add instructions for deactivating an environment (#11200)
## Summary

Add instructions for deactivating a virtual environment.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-02-03 22:16:41 +00:00
Zanie Blue bb3ffcfe52
Improve error messages for `uv pip install` with `--extra` or `--all-extras` and invalid sources (#11193)
Closes https://github.com/astral-sh/uv/issues/11190
Closes https://github.com/astral-sh/uv/issues/7845

This error message was copied over from `uv pip compile` (presumably)
but makes way more sense there than here.
2025-02-03 16:12:39 -06:00
Zanie Blue dd7cd2e86a
Remove warnings for missing lower bounds (#11195)
These are noisy relative to the effect they have on the user. It seems
better to prioritize hints on poor resolutions. Notably, it seems hard
to make these "not noisy" ref #11091.

Does not include the "lowest" resolution mode, in which lower bounds are
critical.
2025-02-03 16:03:31 -06:00
Charlie Marsh efbc77bc37
Use wire JSON schema for conflict items (#11196)
## Summary

Closes https://github.com/astral-sh/uv/issues/11180.
2025-02-03 21:22:13 +00:00
Zanie Blue 1be8ba7df1
Add best-practice flags to `pip install` example in troubleshooting guide (#11194) 2025-02-03 20:13:55 +00:00
Charlie Marsh 85461c2c90
Avoid setting permissions during tar extraction (#11191)
## Summary

As in our zip operation (and like pip), we want to explicitly avoid
setting permissions during unpacking -- apart from setting the
executable bit.

This depends on https://github.com/astral-sh/tokio-tar/pull/8.

Closes https://github.com/astral-sh/uv/issues/11188.
2025-02-03 19:29:11 +00:00
Charlie Marsh 7b43baf251
Use Astral-maintained `tokio-tar` fork (#11174)
## Summary

I shipped one security fix here along with several significant
performance improvements for large TAR files:

- https://github.com/astral-sh/tokio-tar/pull/2
- https://github.com/astral-sh/tokio-tar/pull/4
- https://github.com/astral-sh/tokio-tar/pull/5

I also PR'd the security fix to `edera-dev`
(https://github.com/edera-dev/tokio-tar/pull/4).
2025-02-03 17:51:35 +00:00
konsti 56684e4c24
Respect concurrency limits in parallel index fetch (#11182)
With the parallel simple index fetching, we would only acquire one
download concurrency token, meaning that we could in the worst case make
times the number of indexes more requests than the user requested limit.
We fix this by passing the semaphore down to the simple API method.
2025-02-03 16:41:17 +01:00
konsti c54dbcbcc2
Use dev drive for trampoline CI to avoid timeout (#11015)
Sometimes that job is just slow:
https://github.com/astral-sh/uv/actions/runs/12996921221/job/36247398606
2025-02-03 15:38:56 +01:00
konsti f7c3f30a16
Update pubgrub to set-based outdated priority tracking (#11169)
Looks like the set based prioritize tracking from
https://github.com/pubgrub-rs/pubgrub/pull/313 is a slight speedup.

I assume the changed derivation tree in the error snapshot is due to
out-of-sync virtual package priorities, while the main package priority
defining the solution remains stable.

```
$ hyperfine --warmup 2 "./uv-main pip compile --no-progress scripts/requirements/airflow.in --universal" "./uv-branch pip compile --no-progress scripts/requirements/airflow.in --universal"
  Benchmark 1: ./uv-main pip compile --no-progress scripts/requirements/airflow.in --universal
    Time (mean ± σ):     115.0 ms ±   4.8 ms    [User: 131.0 ms, System: 113.6 ms]
    Range (min … max):   108.1 ms … 125.8 ms    25 runs

  Benchmark 2: ./uv-branch pip compile --no-progress scripts/requirements/airflow.in --universal
    Time (mean ± σ):     105.4 ms ±   2.6 ms    [User: 118.5 ms, System: 113.5 ms]
    Range (min … max):   101.1 ms … 111.9 ms    28 runs

  Summary
    ./uv-branch pip compile --no-progress scripts/requirements/airflow.in --universal ran
      1.09 ± 0.05 times faster than ./uv-main pip compile --no-progress scripts/requirements/airflow.in --universal
```
2025-02-03 13:08:51 +01:00
konsti d27e41a43a
Fix relative paths in bytecode compilation (#11177)
Bytecode compilation would panic with a relative path such as `--target
target`.
2025-02-03 11:20:31 +01:00
renovate[bot] 4a88cdd6ee
Update Rust crate syn to v2.0.98 (#11172) 2025-02-02 20:47:35 -05:00
renovate[bot] d3dd91c78c
Update Rust crate jiff to v0.1.29 (#11171) 2025-02-02 20:33:43 -05:00
renovate[bot] 1ce158ca1d
Update pre-commit dependencies (#11173) 2025-02-03 01:28:26 +00:00
renovate[bot] 6f1578fa59
Update Rust crate async-trait to v0.1.86 (#11170) 2025-02-03 01:16:19 +00:00
konsti 1cfe5be355
uv-install-wheel: Split installation logic and link logic (#11166)
uv-install-wheel had the logic for laying out the installation and for
linking a directory in the same module. We split them up to isolate each
module's logic and tighten the crate's interface to only expose top
level members.

No logic changes, only moving code around.
2025-02-02 15:02:13 +00:00
Charlie Marsh cca1d34432
Optimize exclusion computation for markers (#11158)
## Summary

Oddly this showed up in a trace. I think the lack of memoization was
making it fairly expensive.
2025-02-02 08:21:31 -05:00
Charlie Marsh 2dfeafbaa4
Set `UV_PYTHON` in Jupyter kernels (#11155)
## Summary

It turns out activating the kernel does not change `VIRTUAL_ENV`, so we
still install into the environment the Jupyter environment, rather than
the project environment.

Unfortunately, after this change, we do still show a warning on `uv
add`:

```
warning: `VIRTUAL_ENV=/Users/crmarsh/.cache/uv/archive-v0/3bddKDdYXuX2w57Fu6itL` does not match the project environment path `.venv` and will be ignored
```

`uv pip install` works without warning.

Closes #11154.
2025-02-01 16:54:34 -05:00
renovate[bot] b0e9781da4
Update Rust crate miette to v7.5.0 (#9568) 2025-02-01 04:06:15 +00:00
Charlie Marsh 00ccc502c4
Don't expand self-referential extras in the build backend (#11142)
## Summary

See the linked issue for context.

Closes https://github.com/astral-sh/uv/issues/11137.
2025-01-31 20:58:51 -05:00
Zanie Blue 219c936d4e
Rotate GitHub test PATs (#11147)
As before, these are fine-grained PATs and will expire in 366 days.

They're generated by splitting the token into three parts (by `_`) and
base64 encoding.
2025-01-31 17:03:56 -06:00
Zanie Blue e6ead20aac
Refactor Python discovery iterators to use `filter_ok` and `map_ok` (#11145)
Because now I know those exist
2025-01-31 22:06:23 +00:00
Zanie Blue ba8504fe7a
Filter discovered Python executables by source before querying (#11143)
Closes https://github.com/astral-sh/uv/issues/11138

Though I think we could still have a better error message there.
2025-01-31 21:53:59 +00:00
Charlie Marsh 8adf4a8977
Migrate from `urlencoding` to `percent-encoding` (#11144)
## Summary

This lets us drop a dependency entirely. `percent-encoding` is used by
`url` and so is already in the graph, whereas `urlencoding` isn't used
by anything else.
2025-01-31 16:29:46 -05:00
Charlie Marsh 027db656aa
Run `cargo update` (#11146)
## Summary

Renovate only captures first-party dependencies, so it's good to run
this from time to time.
2025-01-31 16:07:36 -05:00
Zanie Blue ca5b840275
Add test case for `uv pip install` with incompatible virtual environment Python version (#11139)
Test case for https://github.com/astral-sh/uv/issues/11138
2025-01-31 14:54:46 -06:00
Charlie Marsh 26f84e5699
Percent-decode URLs in canonical comparisons (#11088)
## Summary

This PR adds an additional normalization step to `CanonicalUrl` whereby
we now percent-decode the path, to ensure that (e.g.)
`torch-2.5.1%2Bcpu.cxx11.abi-cp39-cp39-linux_x86_64.whl` and
`torch-2.5.1+cpu.cxx11.abi-cp39-cp39-linux_x86_64.whl` are considered
equal. Further, when generating the "reinstall" report, we use the
canonical URL rather than the verbatim URL.

In making this change, I also learned that we don't apply any of the
normalization passes to `file://` URLs. I inadvertently removed it in
93d606aba2,
since setting the password or URL on ` file://` URL errors -- but now
suppress those errors anyway.

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

## Test Plan

- Downloaded a [PyTorch
wheel](https://download.pytorch.org/whl/cpu-cxx11-abi/torch-2.5.1%2Bcpu.cxx11.abi-cp39-cp39-linux_x86_64.whl)
- `python3.9 -m pip install
torch-2.5.1+cpu.cxx11.abi-cp39-cp39-linux_x86_64.whl --platform
linux_x86_64 --target foo --no-deps`
- `cargo run pip install
torch-2.5.1+cpu.cxx11.abi-cp39-cp39-linux_x86_64.whl --python-platform
linux --python-version 3.9 --target foo --no-deps`
- Verified that the package had the `~` symbol for the reinstall.
2025-01-31 15:45:48 -05:00
Charlie Marsh 1fae8dbf17
Add Git SHA locking behavior to docs (#11125)
## Summary

Closes https://github.com/astral-sh/uv/issues/11090.
2025-01-31 12:11:04 -06:00
Martijn Pieters 47f80a62c4
Sign docker images using cosign (#8685)
cosign uses the GitHub action ID token to retrieve an ephemeral code
signing certificate from Fulcio, and store the signature in the Rekor
transparency log.

Once an image has been successfully signed, you should be able to verify
the signature with:

```sh
cosign verify ghcr.io/astral-sh/uv:latest --certificate-identity-regexp='.*' --certificate-oidc-issuer-regexp='.*'
```

Closes #8670
2025-01-31 09:00:23 -06:00
Charles Tapley Hoyt c6713f5751
Use explicit _GLibCVersion tuple in uv-python crate (#11122) 2025-01-31 11:52:38 +01:00
JackDyre 00eb9cc545
removed unneeded `.clone()` (#11127) 2025-01-31 11:12:18 +01:00
Zanie Blue 5ef3d51390
Bump version to 0.5.26 (#11119) 2025-01-30 15:37:00 -06:00