Use lockfile to prefill resolver index (#4495)

## Summary

Use the lockfile to prefill the `InMemoryIndex` used by the resolver.
This enables us to resolve completely from the lockfile without making
any network requests/builds if the requirements are unchanged. It also
means that if new requirements are added we can still avoid most I/O
during resolution, partially addressing
https://github.com/astral-sh/uv/issues/3925.

The main limitation of this PR is that resolution from the lockfile can
fail if new versions are requested that are not present in the lockfile,
in which case we have to perform a fresh resolution. Fixing this would
likely require lazy version/metadata requests by `VersionMap` (this is
different from the lazy parsing we do, the list of versions in a
`VersionMap` is currently immutable).

Resolves https://github.com/astral-sh/uv/issues/3892.

## Test Plan

Added a `deterministic!` macro that ensures that a resolve from the
lockfile and a clean resolve result in the same lockfile output for all
our current tests.
This commit is contained in:
Ibraheem Ahmed 2024-07-12 18:49:28 -04:00 committed by GitHub
parent df2ee8ad14
commit ba217f1059
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 2578 additions and 1798 deletions

View file

@ -214,7 +214,7 @@ impl PrioritizedDist {
pub fn insert_built(
&mut self,
dist: RegistryBuiltWheel,
hashes: Vec<HashDigest>,
hashes: impl IntoIterator<Item = HashDigest>,
compatibility: WheelCompatibility,
) {
// Track the highest-priority wheel.
@ -233,7 +233,7 @@ impl PrioritizedDist {
pub fn insert_source(
&mut self,
dist: RegistrySourceDist,
hashes: Vec<HashDigest>,
hashes: impl IntoIterator<Item = HashDigest>,
compatibility: SourceDistCompatibility,
) {
// Track the highest-priority source.