Share flat index across resolutions (#930)

## Summary

This PR restructures the flat index fetching in a few ways:

1. It now lives in its own `FlatIndexClient`, since it felt a bit
awkward (in my opinion) for it to live in `RegistryClient`.
2. We now fetch the `FlatIndex` outside of the resolver. This has a few
benefits: (1) the resolver construct is no longer `async` and no longer
returns `Result`, which feels better for a resolver; and (2) we can
share the `FlatIndex` across resolutions rather than re-fetching it for
every source distribution build.
This commit is contained in:
Charlie Marsh 2024-01-15 11:02:02 -05:00 committed by GitHub
parent e6d7124147
commit 42888a9609
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 336 additions and 192 deletions

View file

@ -15,7 +15,7 @@ use pep508_rs::{MarkerEnvironment, Requirement, StringVersion};
use platform_host::{Arch, Os, Platform};
use platform_tags::Tags;
use puffin_cache::Cache;
use puffin_client::RegistryClientBuilder;
use puffin_client::{FlatIndex, RegistryClientBuilder};
use puffin_interpreter::{Interpreter, Virtualenv};
use puffin_resolver::{
DisplayResolutionGraph, Manifest, PreReleaseMode, ResolutionGraph, ResolutionMode,
@ -100,6 +100,7 @@ async fn resolve(
tags: &Tags,
) -> Result<ResolutionGraph> {
let client = RegistryClientBuilder::new(Cache::temp()?).build();
let flat_index = FlatIndex::default();
let interpreter = Interpreter::artificial(
Platform::current()?,
markers.clone(),
@ -118,9 +119,9 @@ async fn resolve(
&interpreter,
tags,
&client,
&flat_index,
&build_context,
)
.await?;
);
Ok(resolver.resolve().await?)
}