Read all extras directly from lockfile (#4033)

## Summary
We now pass `ExtrasSpecification` to the lock routine.
This commit is contained in:
Charlie Marsh 2024-06-04 21:03:55 -04:00 committed by GitHub
parent 1b3200b2af
commit 8de3e38b94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 48 deletions

View file

@ -24,6 +24,7 @@ use pep440_rs::Version;
use pep508_rs::{MarkerEnvironment, MarkerTree, VerbatimUrl};
use platform_tags::{TagCompatibility, TagPriority, Tags};
use pypi_types::{HashDigest, ParsedArchiveUrl, ParsedGitUrl};
use uv_configuration::ExtrasSpecification;
use uv_git::{GitReference, GitSha, RepositoryReference, ResolvedRepositoryReference};
use uv_normalize::{ExtraName, PackageName};
@ -110,7 +111,7 @@ impl Lock {
marker_env: &MarkerEnvironment,
tags: &Tags,
root_name: &PackageName,
extras: &[ExtraName],
extras: &ExtrasSpecification,
) -> Resolution {
let mut queue: VecDeque<(&Distribution, Option<&ExtraName>)> = VecDeque::new();
@ -119,8 +120,23 @@ impl Lock {
.find_by_name(root_name)
.expect("found too many distributions matching root")
.expect("could not find root");
for extra in std::iter::once(None).chain(extras.iter().map(Some)) {
queue.push_back((root, extra));
// Add the base package.
queue.push_back((root, None));
// Add any extras.
match extras {
ExtrasSpecification::None => {}
ExtrasSpecification::All => {
for extra in root.optional_dependencies.keys() {
queue.push_back((root, Some(extra)));
}
}
ExtrasSpecification::Some(extras) => {
for extra in extras {
queue.push_back((root, Some(extra)));
}
}
}
let mut map = BTreeMap::default();