Repository navigation
Resolve URL dependencies without lookahead - #21763
charliermarsh wants to merge 10 commits into
Conversation
Merging this PR will degrade performance by 48.12%2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
| PrereleasePolicy::Explicit(packages) => { | ||
| if packages.contains(package_name, env) { | ||
| if packages.contains(package_name, env) | ||
| || self.possible_explicit.contains(package_name) |
There was a problem hiding this comment.
[P2] Speculative prerelease selection can execute an unauthorized build backend
Under --prerelease=explicit, this new possible_explicit fallback treats an as-yet ungrounded first-party pin as permission to select a prerelease. The resulting choose_version path immediately requests registry metadata; if the candidate is an attacker-controlled sdist with dynamic metadata, uv executes its PEP 517 backend before deciding whether the provider extra that grants prerelease permission is actually selected. The final grounding check can then reject the prerelease, but the backend has already run with the developer or CI worker's authority. Defer executable sdist metadata until the selected dependency graph authorizes the candidate, or restrict speculative inspection to non-executable metadata paths.
uv test inventory changesThis PR changes the tests when compared with the
|
| | ^^ | ||
| invalid type: integer `42`, expected a string | ||
|
|
||
| hint: `child` was included because `project` (v0.1.0) depends on `child` |
| # via | ||
| # -r requirements.in | ||
| # forkroot | ||
| forkdep==3.1 ; python_full_version >= '3.12' |
| Caused by: The .dist-info directory tomli-2.0.1 does not start with the normalized package name: foo | ||
| error: Failed to read `foo @ file://[TEMP_DIR]/foo-2.0.1-py3-none-any.whl` | ||
| cause: Failed to read metadata: `[TEMP_DIR]/foo-2.0.1-py3-none-any.whl` | ||
| cause: The .dist-info directory tomli-2.0.1 does not start with the normalized package name: foo |
| the branch. It can revisit earlier candidate decisions, including extras, when a different selection | ||
| might supply the missing URL. For small sets of universal registry wheels covering the active |
There was a problem hiding this comment.
Can we avoid this by prioritizing URLs over registry packages?
We currently discover transitive URLs before resolution and keep them after the dependency path that introduced them has been rejected. For example, if a rejected candidate activates
provider[url], another dependency that just requirestargetstill uses the URL from that extra. We now use the registry in that case, unless another selected dependency independently supplies a URL.Move URL discovery into the resolver and make the source part of each PubGrub candidate. URLs can be introduced by the root or by another authorized URL dependency. A registry package cannot introduce a URL; it can request an extra on an independently authorized URL package, whose own metadata can then declare another URL. The markers along that path matter: if the extra is requested only on Linux, its URL or explicit index applies only on Linux. Registry, explicitly selected index, and URL candidates remain distinct even when they publish the same version. If the registry has no suitable candidate, we keep possible URL sources open and can revisit earlier decisions to select a valid provider. Required URLs report the original artifact error with the selected dependency path; errors from excluded branches are discarded. A registry requirement written with a different Git reference can reuse an authorized source when the repository, package location, and commit match. Comparing references does not check out the registry-supplied revision or fetch its submodules or Git LFS.
Local directories have separate normal and editable candidates, and Git checkouts have separate candidates with and without LFS; each mode has its own metadata and failures. A plain declaration cannot enable either alternative on its own, but another selected first-party dependency can require it. Dependencies reported only by the alternative mode cannot authorize that mode themselves. Conflicting editable and non-editable declarations cannot both be included, and a virtual declaration cannot suppress another included declaration that requires installation. We validate each directory against its requested package name. Archive hashes from selected declarations stay in compiled requirements, even when an equivalent declaration omits its hash; hashes from an old registry pin are not reused for a URL.
Apply the same source and marker rules when checking lockfiles and preserve conditional extras when exporting. Checks validate authorized mutable dependencies reached through immutable registry or Git packages. Source declarations from Git packages are retained for offline checks. The metadata-free preview lock records incoming requests for empty mutable dependency extras; older preview locks with immutable parents of mutable dependencies are re-resolved once. First-party prerelease and yank policies, trusted hashes, and
lowest-directselection also follow the selected graph, including universal resolution and--fork-strategy fewest. Ordinary registry candidate sets stay compact. For small sets of universal registry wheels, URL-provider searches can skip versions that have identical requirements and Python compatibility or whose dependencies cannot reach a possible first-party source or policy. This removes the lookahead pass from pip and build dependency resolution.