Commit Graph

4629 Commits

Author SHA1 Message Date
Andrew Gallant acaed763b7 uv: use ResolverEnvironment instead of ResolverMarkers
This updates the surrounding code to use the new ResolverEnvironment
type. In some cases, this simplifies caller code by removing case
analysis. There *shouldn't* be any behavior changes here. Some test
snapshots were updated to account for some minor tweaks to error
messages.

I didn't split this up into separate commits because it would have been
too difficult/costly.
2024-11-04 11:09:06 -05:00
Andrew Gallant 44c9ef6aea uv-resolver: add new ResolverEnvironment type
This type is intended to replace `ResolverMarkers`. The main difference
between them is that this type encapsulates more decision making by
un-exporting the different cases. So instead of callers needing to do
explicit case analysis depending on the type of resolver environment,
callers instead use methods that know how to do the right thing. In the
next commit, there are at least a few cases where this greatly
simplifies case analysis on the caller side.

The motivation for this type is to centralize decision making about
forking. In particular, we want to expand forking to include conflicting
groups instead of just `MarkerTree`. So to a certain extent, the
refactor here is about removing bare use of `MarkerTree` in favor of a
more purpose built type that encapsulates the forking logic.

The encapsulation is not quite perfect here. I expect to improve on it a
bit once we add support for conflicting groups.

This is split off from the subsequent commit (that makes use of
`ResolverEnvironment`) so that it's a bit easier to review the addition
in isolation.
2024-11-04 11:09:06 -05:00
Andrew Gallant fccd48ce61 uv-normalize: add `as_str` method
`ExtraName` did implement `AsRef<str>`, but that should generally
only be used in a context with an `AsRef<str>` generic bound. If
you just want a `&str` from a concrete `ExtraName`, then a specific
method for that purpose should be used.
2024-11-04 11:09:06 -05:00
Zanie Blue 6250b900b7
Allow managed downloads with `--python-preference system` (#8808)
Closes https://github.com/astral-sh/uv/issues/8804
2024-11-04 07:45:24 -06:00
Tim de Jager d82607d038
Extend BaseClient to accept extra middleware (#8807)
This PR is a revival of #3502, albeit in a much simpler form.

This would allow for different middlewares like authentication and such,
useful for if you want to deviate from the keychain authentication
methods when using uv as a library.

@zanieb I hope I made the changes as you noted you wanted to see them :)

Happy to add/change anything you need.
2024-11-04 07:04:26 -06:00
Tim de Jager ef8724c979
Add `From` for `FlatDistributions` struct (#8800)
Co-authored-by: konsti <konstin@mailbox.org>
2024-11-04 08:41:39 +00:00
renovate[bot] a052418dcd
Update Rust crate which to v7 (#8794) 2024-11-03 21:15:17 -05:00
renovate[bot] e77ecfd2bd
Update Rust crate procfs to 0.17.0 (#8793) 2024-11-03 21:15:10 -05:00
renovate[bot] f234ec37d5
Update Rust crate axoupdater to 0.8.0 (#8792) 2024-11-03 21:15:04 -05:00
renovate[bot] 97763d2ade
Update pre-commit dependencies (#8791) 2024-11-03 21:14:58 -05:00
renovate[bot] 15d003a65f
Update Rust crate thiserror to v1.0.67 (#8790) 2024-11-03 21:14:54 -05:00
renovate[bot] aa96307273
Update Rust crate syn to v2.0.87 (#8789) 2024-11-03 21:14:51 -05:00
renovate[bot] a0cbf5d32b
Update Rust crate anyhow to v1.0.92 (#8787) 2024-11-03 21:14:31 -05:00
konsti fd6b6aca0f
Fix indentation level in test publish script (#8785) 2024-11-03 22:42:00 +01:00
konsti b2afcf2f2c
Retrying parsing in test_publish.py (#8784) 2024-11-03 20:56:19 +00:00
Charlie Marsh bf79d985ee
Allow incompatible `requires-python` for source distributions with static metadata (#8768)
## Summary

At present, when we have a Python requirement and we see a wheel, we
verify that the Python requirement is compatible with the wheel. For
source distributions, though, we verify that both the Python requirement
_and_ the currently-installed version are compatible, because we assume
that we'll need to build the source distribution in order to get
metadata. However, we can often extract source distribution metadata
_without_ building (e.g., if there's a `pyproject.toml` with no dynamic
keys).

This PR thus modifies the source distribution handling to defer that
incompatibility ("We couldn't get metadata for this project, because it
has no static metadata and requires a higher Python version to run /
build") until we actually try to build the package. As a result, you can
now resolve source distribution-only packages using Python versions
below their `requires-python`, as long as they include static metadata.

Closes https://github.com/astral-sh/uv/issues/8767.
2024-11-03 19:03:55 +00:00
samypr100 647494b998
docs: env var doc improvements (#8777)
## Summary

* Env docs now support anchors, which allows sending a link to someone
with a direct reference to an env var or cross-reference them in the
docs.
* Marked additional env vars as hidden from the docs due to their
internal use
* Updates some tests still using literals to use the static env vars

## Test Plan

<img width="1370" alt="env_var_anchors"
src="https://github.com/user-attachments/assets/52ae1caa-5199-4798-9eb5-81b8f5b57c24">
2024-11-03 13:56:17 -05:00
konsti f52814e729
Fix no_binary_only_binary test (#8776) 2024-11-03 15:52:14 +00:00
Jo 3dfedf1fef
Generate environment variables doc from code (#8493)
## Summary

Resolves #8417

I've just begun learning procedural macros, so this PR is more of a
proof of concept. It's still a work in progress, and I welcome any
assistance or feedback.
2024-11-03 08:31:38 -06:00
k_fukuchi 545a55f58f
Fix indentation in `projects.md` (#8772)
## Summary

Fix indentation in `projects.md`
2024-11-03 08:28:08 -06:00
Zanie Blue 2ed94745a2
Show full error chain on tool upgrade failures (#8753)
As reported in https://github.com/astral-sh/uv/issues/8555
2024-11-02 11:55:41 -05:00
Charlie Marsh d3e50a2376
Enable `--all-packages --frozen` in `uv sync` and `uv export` (#8760)
## Summary

This PR improves the interaction of `--frozen` such that we reduce the
dependency on the `pyproject.toml` and increase the dependency on the
`uv.lock`. Specifically, we now read the list of workspace members from
the `uv.lock` rather than the `pyproject.toml`, which means we don't
need to discover the member `pyproject.toml` files in order to perform a
`uv sync --frozen --all-packages`.
2024-11-02 02:48:55 +00:00
Charlie Marsh b36ae6d5ae
Add support for `uv export --all-packages` (#8742)
## Summary

Same as the other PRs, but for `uv export`.
2024-11-02 02:25:29 +00:00
Charlie Marsh 3808b61fc1
Add support for `uv run --all-packages` (#8741)
## Summary

Closes https://github.com/astral-sh/uv/issues/8724.
2024-11-02 02:16:06 +00:00
Charlie Marsh 3c9dd97fe9
Add support for `uv sync --all-packages` (#8739)
## Summary

This PR enables `uv sync --all-packages` to sync all packages in a
workspace. It removes a common use-case for the legacy non-`[project]`
packages that we're trying to move away from.

Closes https://github.com/astral-sh/uv/issues/8724.
2024-11-02 01:55:08 +00:00
Andrew Gallant 58a9811881
fix bug where `python_version < '0'` could appear in a final resolution (#8759)
This PR fixes a bug where it was possible for dependencies to be
included in a final resolution with markers that always evaluate to
false. Specifically, `python_version < '0'`.

While we do filter based on Python markers during forking, it turns out
that the markers for each fork are "combined" *after* this filtering
step. But the process of combination can result in a more specific
marker that is always false for the configured Python requirement. This
could result in dependencies with markers that are always false (like
`python_version < '0'`) appearing in the resolution.

The first commit in this PR adds a regression test (with an undesirable
result), and the second commit fixes the regression and updates the
test.

Fixes #8676
2024-11-01 20:11:40 +00:00
Trevor Manz a90a8e7a61
Fix `add httpx` example with real git branch (#8756)
<!--
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

The example in the docs for adding a git source with `--branch` fails
because `main` doesn't exist.

```sh
uv add git+https://github.com/encode/httpx --branch main
# error: Git operation failed
#   Caused by: failed to fetch into: /Users/manzt/.cache/uv/git-v0/db/4c0b1441d92956e1
#   Caused by: failed to fetch branch `main`
#   Caused by: process didn't exit successfully: `/usr/bin/git fetch --force --update-head-ok 'https://github.com/encode/httpx' '+refs/heads/main:refs/remotes/origin/main'` (exit status: 128)
```

This PR changes the example to the default branch for httpx, `master`.

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

## Test Plan

N/A

<!-- How was it tested? -->
2024-11-01 13:03:21 -04:00
Charlie Marsh f4da6ffdd6
Run `cargo update` (#8703)
Pull in https://github.com/prefix-dev/async_http_range_reader/pull/19,
removes a version of `itertools`.
2024-11-01 10:26:21 -04:00
Andrew Gallant 049ccf7d77
uv-client: switch to RFC 9110 compatible format (#8752)
This still utilizes the RFC 2822 datetime formatter, but utilizes new
methods [added in jiff 0.1.14] to emit timestamps in a format strictly
compatible with RFC 9110.

It seems like most HTTP servers were pretty flexible and supported RFC
2822 datetime formats, but #8747 shows at least one case where that
isn't true. Given that the [MDN docs prescribe RFC 9110], we defer to
them.

Fixes #8747

[added in jiff 0.1.14]: https://github.com/BurntSushi/jiff/pull/154
[MDN docs prescribe RFC 9110]:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since
2024-11-01 09:46:24 -04:00
Lan, Jian f8291144c0
Improve and fix some documents (#8749)
<!--
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

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

## Test Plan

<!-- How was it tested? -->
2024-11-01 09:44:04 -04:00
Justin Bandoro bf8436c16a
Docs: fix env var name in providing credentials section (#8740)
I was following along the docs for this section and the index name
didn't match the example before it.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-11-01 01:16:38 +00:00
Charlie Marsh 40b48267e5
Include member groups when locking workspace (#8736)
## Summary

It turns out that when locking, we were only taking the groups from the
root `pyproject.toml` into account, and ignoring groups that were only
defined in a workspace member.
2024-11-01 00:04:34 +00:00
Charlie Marsh 5a46b5e52c
Avoid error for `--group` defined in non-root workspace member (#8734)
## Summary

Closes https://github.com/astral-sh/uv/issues/8722.
2024-10-31 20:11:22 +00:00
Charlie Marsh 24ad43e79c
Avoid showing dependency group annotations on workspace members in tree (#8730)
## Summary

By default, `uv tree` shows the full workspace, not _just_ the root. If
the root depended on a workspace member as a dev dependency, then we'd
still show it as `(group: dev)` in `uv tree` even if you passed
`--no-dev`, because we weren't filtering the edges in the right place.

This is still somewhat confusing, because if `root` depends on workspace
member `child` as a dev dependency, `uv tree --no-dev` still shows both.

Closes https://github.com/astral-sh/uv/issues/8719.
2024-10-31 16:09:36 -04:00
Charlie Marsh f3264583ac
Sanitize filenames during zip extraction (#8732)
## Summary

Based on the example in `async-zip`:
527bda9d58/examples/file_extraction.rs (L33)

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

## Test Plan

Created https://github.com/astral-sh/sanitize-wheel-test.
2024-10-31 19:12:51 +00:00
Zanie Blue 8d3408fe39
Add support for installing versioned Python executables on Windows (#8663)
Incorporating #8637 into #8458 

- Adds `python-managed` feature selection to Windows CI for `python
install` tests
- Adds trampoline sniffing utilities to `uv-trampoline-builder`
- Uses a trampoline to install Python executables into the `PATH` on
Windows
2024-10-31 15:58:35 +00:00
konsti f5a7d70642
Check error case for skip existing (#8631) 2024-10-31 15:37:30 +00:00
konsti 082259493e
Skip existing, second iteration: Check the index before uploading (#8531)
Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-10-31 16:23:12 +01:00
Zanie Blue b52f229862
Do not error when the Python bin directory is missing on `uv python uninstall` (#8725) 2024-10-31 14:15:47 +00:00
Andi Pabst ad896c89d9
Fix link to publish guide in README (#8720)
<!--
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

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

The README contains a link to the publish guide
(https://docs.astral.sh/uv/guides/publish.md) that gives an error 404.
When navigating to that page via the side menu, the correct link seems
to be (https://docs.astral.sh/uv/guides/publish/).

## Test Plan

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

Documentation change, therefore manual testing by clicking on the link.
2024-10-31 09:00:46 -04:00
Zanie Blue 1b760af79d
Fix test context filtering of Python platform keys with elided patch versions (#8713)
Cherry-picked from #8650
2024-10-30 22:34:37 -05:00
Zanie Blue 85f9a0d0ec
Bump version to 0.4.29 (#8711) 2024-10-30 18:22:53 -05:00
Zanie Blue 995307767f
Clarify preview requirement for relevance of `uv python dir --bin` (#8709) 2024-10-30 21:48:34 +00:00
Zanie Blue 47eb66b138
Add test coverage for `uv python install` with invalid requests (#8708) 2024-10-30 16:38:47 -05:00
Zanie Blue 893257bb0b
Refactor `uv python install` (#8701)
Pulling out of https://github.com/astral-sh/uv/pull/8650 for
readability.

Trying to clean this up to simplify extensions in the future. This is
not a strict refactor, there are behavioral changes here.

- Adds some structs for managing state.
- Addresses some likely inconsistent behavior for weird edge-cases. 
- We fill platform information before checking if a request is
satisfied.
- We error earlier if we can't find a download for the request, i.e.,
even if you somehow have it installed.
- Only reports versions as uninstalled if a download actually replaces
them.
- Moves some of the default output to tracing messages.
- Even if an installation was already satisfied, we'll check that it is
setup properly
2024-10-30 21:28:08 +00:00
Charlie Marsh bed47d512a
Use portable paths for subdirectories in lock URLs (#8707)
## Summary

We're writing different URLs on Windows vs. Linux because the
subdirectory path is being serialized with a back vs. forward slash.
2024-10-30 15:37:40 -04:00
konsti 4a5a79eed8
Support transitive dependencies in Git workspaces (#8665)
When resolving workspace dependencies (from one workspace member to
another) from a workspace that's in git, we need to emit these
transitive dependencies as git dependencies, not path dependencies as
all other workspace deps. This fixes a bug where we would treat them as
path dependencies inside the checkout directory, leading either to
clashes (between a local path and another direct git dependency) or
invalid lockfiles (referencing the checkout dir in the lockfile when we
should be referencing the git repo).

Fixes #8087
Fixes #4920
Fixes #3936 since we needed that information anyway

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-30 19:12:23 +00:00
Zanie Blue 4dd36b799f
Install versioned Python executables into the bin directory during `uv python install` (#8458)
Updates `uv python install` to link `python3.x` in the executable
directory (i.e., `~/.local/bin`) to the the managed interpreter path.

Includes

- #8569 
- #8571 

Remaining work

- #8663 
- #8650 
- Add an opt-out setting and flag
- Update documentation
2024-10-30 14:13:20 +00:00
konsti 94fc35edd9
Fix feature scoping for pep508 wasm32 support for ruff (#8694) 2024-10-30 12:21:23 +00:00
konsti c1a0fb35e8
Simplify pep440 -> version ranges conversion (#8683) 2024-10-30 13:10:48 +01:00