Commit Graph

3812 Commits

Author SHA1 Message Date
Charlie Marsh 0aaa6ba5be
Migrate to `zlib-rs` (#9184)
## Summary

I've tried this a few times; just curious if it passes tests.
2024-11-18 15:45:14 +00:00
Charlie Marsh 46151c13cd
Fix flaky failure in `verify_hashes_mismatch` (#9198)
## Summary

I moved this to a separate test. The packages may or may not be
downloaded already, since the previous command fails -- it just depends
on timing.
2024-11-18 14:26:53 +00:00
konsti a07d5a1d18
Update pubgrub to `Ranges::from_iter` (#9145)
Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-11-18 12:28:17 +00:00
Shantanu 587c9b02a6
Fix typo in environment variable name (#9186)
https://github.com/astral-sh/uv/pull/9170/files#r1845768798
2024-11-18 02:54:26 +00:00
Charlie Marsh 8d258655e2
Sort distributions when computing hash (#9185)
## Summary

The distributions used to be stored in a `BTreeMap`, keyed by name.
They're now stored in a graph... so iteration isn't guaranteed to
produce a deterministic hash!

This fixes a "flaky" test, though it's actually a real bug. The test was
right!

Closes #9137.
2024-11-17 21:43:03 -05:00
Charlie Marsh a72e2f9195 Avoid flaky preparedness error in verify_hashes_mismatch 2024-11-17 21:39:40 -05:00
Shantanu 71d9c45393
Turn `--verify-hashes` on by default (#9170)
Fixes #9164

Using clap's `default_value_t` makes the `flag` function unhappy, so
just set the default when we unwrap. Tested with no flags,
`--verify-hashes`, `--no-verify-hashes` and setting in uv.toml

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-11-18 01:57:54 +00:00
Charlie Marsh 5ba186628b
Avoid showing disjoint marker error with `true` (#9169)
## Summary

Ran into this in practice, and it's awkward:

![Screenshot 2024-11-16 at 12 19
25 PM](https://github.com/user-attachments/assets/1c5d296e-b6ea-4e28-83fc-0ae096dfe2b8)
2024-11-17 20:50:44 -05:00
renovate[bot] 352e3341de
Update Rust crate flate2 to v1.0.35 (#9176) 2024-11-17 20:48:21 -05:00
Charlie Marsh 12266f8f81
Add a dedicated error for `include = "dev"` with `tool.uv.dev-dependencies` (#9173)
## Summary

This isn't really spec-compliant, so we already don't allow it -- this
just adds a better error message and an explicit test for it.
2024-11-17 13:22:04 -05:00
Charlie Marsh fb3f365d10
Support overrides and constraints in PEP 723 scripts (#9162)
## Summary

Closes https://github.com/astral-sh/uv/issues/9141.
2024-11-15 23:03:39 -05:00
Charlie Marsh e21227504b
Include cyan for prefix on versions (#9155)
## Summary

The `v` in `v1.0.0` wasn't cyan, but the version was. This wasn't
obvious from the snapshots, which ignore color.
2024-11-15 16:11:19 -05:00
Charlie Marsh 5bff2ba243
Include extras and dependency groups in derivation chains (#9113)
## Summary

Displays extras and dependency groups when explaining inclusion.
2024-11-15 15:37:18 -05:00
Charlie Marsh 8dd095cab8
Include version constraints in derivation chains (#9112)
## Summary

Derivation chains can now include the versions at which a package was
requested.
2024-11-15 15:06:24 -05:00
renovate[bot] 312ae12650
Update Rust crate thiserror to v2 (#9006) 2024-11-15 09:54:16 -06:00
konsti 21d570fac9
Build backend: Include readme and license files (#9149)
When building source distributions, we need to include the readme, so it
can become part the METADATA body when building the wheel. We also need
to support the license files from PEP 639. When building the source
distribution, we copy those file relative to their origin, when building
the wheel, we copy them to `.dist-info/licenses`.

The test for idempotence in wheel building is merged into the file
listing test, which also covers that source tree -> source dist -> wheel
is equivalent to source tree -> wheel, though we do need to check for
file inclusion stronger here.

Best reviewed commit-by-commit
2024-11-15 14:41:39 +00:00
konsti 997ff9d57a
Allow apostrophe in venv name (#8984)
Escape an apostrophe in the venv path name.

Fixes #8947
2024-11-15 10:52:10 +01:00
konsti 0abb2a4595
Refactor shell quoting (#9055)
Move the shlex-like quoting utils in the uv-shell crate, so we only
write `r#"'"'"'"#` once.

Split out from #8984
2024-11-15 09:06:54 +00:00
Micha Reiser 7b4197bc0e
Detect nested workspace inside the current workspace and members with identical names (#9094)
## Summary

Align uv's workspace discovery with red knots (see
https://github.com/astral-sh/ruff/pull/14308#issuecomment-2474296308)

* Detect nested workspace inside the current workspace rather than
testing if the current workspace is a member of any outer workspace.
* Detect packages with identical names.

## Test Plan

I added two integration tests. I also back ported the tests to main to
verify that both these invalid workspaces aren't catched by uv today.
That makes this, technically, a breaking change but I would consider the
change a bug fix.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-11-15 04:03:00 +00:00
Charlie Marsh 2b08d767cd
Show derivation markers for resolutions with project name (#9136)
## Summary

I was wrongly using `.name()` to detect if a package was "not root", but
in `pip compile`, the root can have a name -- so we were failing to find
the derivation chain.
2024-11-14 19:25:25 -05:00
Zanie Blue 195f4b634f
Bump version to 0.5.2 (#9133) 2024-11-14 15:59:50 -06:00
Charlie Marsh 92735ced9a
Misc. touch-ups to target-to-resolution routine (#9131) 2024-11-14 16:24:03 -05:00
Charlie Marsh fe477c3417
Show full derivation chain when encountering build failures (#9108)
## Summary

This PR adds context to our error messages to explain _why_ a given
package was included, if we fail to download or build it.

It's quite a large change, but it motivated some good refactors and
improvements along the way.

Closes https://github.com/astral-sh/uv/issues/8962.
2024-11-14 15:48:26 -05:00
Charlie Marsh a552f74308
Refactor `Resolution` type to retain dependency graph (#9106)
## Summary

This PR should not contain any user-visible changes, but the goal is to
refactor the `Resolution` type to retain a dependency graph. We want to
be able to explain _why_ a given package was excluded on error (see:
https://github.com/astral-sh/uv/issues/8962), which in turn requires
that at install time, we can go back and figure out the dependency
chain. At present, `Resolution` is just a map from package name to
distribution; this PR remodels it as a graph in which each node is a
package, and the edges contain markers plus extras or dependency groups.
2024-11-14 15:25:34 -05:00
konsti 3a7db17147
Build backend: Add source tree -> source dist -> wheel tests (#9091)
A first milestone: source tree -> source dist -> wheel -> install works.
This PR adds a test for this.

There's obviously a lot still missing, including basics such as the
Readme inclusion.
2024-11-14 19:15:32 +00:00
konsti 9a20f8c7b7
Remove end-of-line whitespace in snapshots (#9127)
I've configured my IDE to remove trailing end-of-line whitespace, and
these snapshots were causing trouble.
2024-11-14 18:16:20 +00:00
konsti c2ccc2c5dc
Support `copy_dir_all` in unit tests too (#9124)
Refactoring for https://github.com/astral-sh/uv/pull/9091
2024-11-14 18:05:15 +00:00
Zanie Blue 50cfbd904c
Show file extensions on available commands when not `.exe` (#9099)
Closes https://github.com/astral-sh/uv/issues/8770
2024-11-14 10:21:19 -06:00
konsti 57ff5330fc
Show link we failed on parsing index pages (#9118)
For #8172, show the link we failed on. This should e.g. give a hint on
permission denied pages such as
https://github.com/astral-sh/uv/issues/8172#issuecomment-2474392691.
2024-11-14 16:00:33 +01:00
Charlie Marsh b37170df94
Rename `ResolutionGraph` to `ResolverOutput` (#9103)
## Summary

As discussed in Discord... This struct has evolved to include a lot of
information apart from the `petgraph::Graph`. And I want to add a graph
to the simplified `Resolution` type. So I think this name makes more
sense.
2024-11-14 14:51:11 +00:00
konsti 02a7bb43d9
Minimal wheel settings (#9085)
A small refactoring and minimal wheel settings. source tree -> source
dist -> wheel is working, which we'll add tests for in the next PR.
2024-11-14 13:40:09 +00:00
konsti 4ac78f673b
Build backend: Switch to custom glob-walkdir implementation (#9013)
When doing a directory traversal for source dist inclusion, we want to
offer the user include and exclude options, and we want to avoid
traversing irrelevant directories. The latter is important for
performance, especially on network file systems, but also with large
data directories, or (not-included) directories with other permissions.
To support this, we introduce `GlobDirFilter`, which uses a DFA from
regex_automata to determine whether any children of a directory can be
included and skips the directory if not.

The globs are based on PEP 639. The syntax is more restricted than glob
or globset, but it's standardized. I chose it over glob or globset
because we're already using this syntax for `project.license-files` a
required by PEP 639, so it makes sense to use the same globs for all
includes (see e.g.
4f52a3bb62/pyproject.toml (L36-L48)
for example with same semantics for include and exclude)

### Semantics

Glob semantics are complex due to mixing directories and files,
expectations around simplicity and our need to exclude most of the tree
in the project from traversal. The current draft uses a syntax that
optimizes for simple default use cases for the start.

#### includes

Glob expressions which files and directories to include in the source
distribution.

Includes are anchored, which means that `pyproject.toml` includes only
`<project root>/pyproject.toml`. Use for example `assets/**/sample.csv`
to include for all
`sample.csv` files in `<project root>/assets` or any child directory. To
recursively include
all files under a directory, use a `/**` suffix, e.g. `src/**`. For
performance and
reproducibility, avoid unanchored matches such as `**/sample.csv`.

The glob syntax is the reduced portable glob from
[PEP 639](https://peps.python.org/pep-0639/#add-license-FILES-key).

#### excludes

Glob expressions which files and directories to exclude from the
previous source
distribution includes.

Excludes are not, which means that `__pycache__` excludes all
directories named
`__pycache__` and it's children anywhere. To anchor a directory, use a
`/` prefix, e.g.,
`/dist` will exclude only `<project root>/dist`.

The glob syntax is the reduced portable glob from
[PEP 639](https://peps.python.org/pep-0639/#add-license-FILES-key).
2024-11-14 13:14:58 +00:00
Andrew Gallant e310dcc7c1 doc: tweak docs a bit
We also update the docs for flags like `--extra` to note that they may
result in an error if they try to enable extras that are conflicting.
2024-11-14 08:02:46 -05:00
Andrew Gallant c68e0d624e uv: expose `conflicts` in `tool.uv` in `pyproject.toml` 2024-11-14 08:02:46 -05:00
Andrew Gallant c0440e93cf uv/tests: add a few tests for conflicting groups
This includes a test where we define a conflict between an extra and a
group.
2024-11-14 08:02:46 -05:00
Andrew Gallant 277e7f8dd0 uv-resolver: support conflicting groups
Surprisingly, this seems to be all that's necessary.

Previously, we were only extracting an extra from a
PubGrubPackage to test for conflicts. But now we extract
either an extra or a group. The surrounding code all
remains the same.

We do need to add some extra checking for groups
specifically, but I believe that's it.
2024-11-14 08:02:46 -05:00
Andrew Gallant 3f483d5911 uv-pypi-types: make 'contains' methods generic
This lets us ask whether an `&ExtraName` or a `&GroupName` is contained
in a particular conflict set.
2024-11-14 08:02:46 -05:00
Andrew Gallant 06943ca870 uv-pypi-types: make room for group names in addition to extras
This adds support for providing conflicting group names in addition to
extra names to `Conflicts`.

This merely makes "room" for it in the types while keeping everything
working. We'll add proper support for it in the next commit.

Note that one interesting trick we do here is depend directly on
`hashbrown` so that we can make use of its `Equivalent` trait. This in
turn lets us use things like `ConflictItemRef` as a lookup key for a
hashset that contains `ConflictItem`. This mirrors using a `&str` as a
lookup key for a hashset that contains `String`, but works for arbitrary
types. `std` doesn't support this, but `hashbrown` does. This trick in
turn lets us simplify some of our data structures.

This also rejiggers some of the serde-interaction with the conflicting
types. We now use a wire type to represent our conflicting items for
more flexibility. i.e., Support `extra` XOR `group` fields.
2024-11-14 08:02:46 -05:00
Andrew Gallant cda8b3276a uv-resolver: add to `diverging_packages` when forking based on conflicts
This addresses Konsti's comment about it being empty:
https://github.com/astral-sh/uv/pull/8976#discussion_r1837951568
2024-11-14 08:02:46 -05:00
Andrew Gallant c2c9bd9557 uv/tests: adds a test with mutually exclusive extras across a workspace
This tests comes from here:
https://github.com/astral-sh/uv/pull/8976#issuecomment-2473672199

And it was originally thought of by Konsti.

This test case is the motivation for making `package` optional in
`conflicts` instead of forbidding it entirely.
2024-11-14 08:02:46 -05:00
Andrew Gallant bb78e00a87 *: update "conflicting groups" terminology everywhere else 2024-11-14 08:02:46 -05:00
Andrew Gallant 19a044d4db uv-pypi-types: rename "conflicting group" types to more generic "conflicts"
Since this is intended to support _both_ groups and extras, it doesn't
make sense to just name it for groups. And since there isn't really a
word that encapsulates both "extra" and "group," we just fall back to
the super general "conflicts."

We'll rename the variables and other things in the next commit.
2024-11-14 08:02:46 -05:00
Andrew Gallant 84d50ce81a uv-pypi-types: rename conflicting_groups module to conflicts
We'll do the rest of the renaming in the next commit.
2024-11-14 08:02:46 -05:00
Charlie Marsh 2e73f47453
Avoid duplicating first-entry comments in `uv add` (#9109)
## Summary

Closes https://github.com/astral-sh/uv/issues/9105.
2024-11-14 02:13:59 +00:00
Charlie Marsh 8c663d2a3f
Convert to `RequirementSource` rather than `Requirement` (#9107)
## Summary

This seems like a vestige left over from a refactor.
2024-11-13 20:00:13 -05:00
Charlie Marsh 9339e55a11
Add `version` to `ResolvedDist` (#9102)
## Summary

I need this for the derivation chain work
(https://github.com/astral-sh/uv/issues/8962), but it just seems
generally useful. You can't always get a version from a `Dist` (it could
be URL-based!), but when we create a `ResolvedDist`, we _do_ know the
version (and not just the URL). This PR preserves it.
2024-11-13 19:06:16 -05:00
Charlie Marsh 17181d9e59
Add missing `Download` variants to diagnostics (#9101) 2024-11-13 17:36:54 -05:00
Charlie Marsh 415e3dcd24
Remove unnecessary descriptions from test suite (#9100) 2024-11-13 21:00:14 +00:00
Charlie Marsh 35549de62d
Defer reporting of build failures in resolver (#9098)
## Summary

In https://github.com/astral-sh/uv/issues/9078, resolution fails because
we fail to build `jsmin`. However... if you look at what's actually
happening, `jsmin` fails to build during _prefetching_. And we never
actually attempt to access its metadata later on.

This PR modifies the metadata result handling such that we don't raise
these errors until the resolver actually asks for the metadata, so
https://github.com/astral-sh/uv/issues/9078 now succeeds.

I actually had to make this change anyway in pursuing
https://github.com/astral-sh/uv/issues/8962, so I've decided to carve it
out here.

Closes https://github.com/astral-sh/uv/issues/9078.
2024-11-13 15:49:08 -05:00
Charlie Marsh b0e7476008
Sort by name, then specifiers in `uv add` (#9097)
## Summary

This PR ensures that `pylint>=3.2.6` followed by
`pylint-module-boundaries>=1.3.1` is considered sorted, despite the fact
that `>` is later in the alphabetic than `-`. By purely comparing
strings, they would _not_ be sorted; but by considering the name, then
the specifiers, they are.

Closes https://github.com/astral-sh/uv/issues/9076.
2024-11-13 15:47:57 -05:00