mirror of https://github.com/astral-sh/uv
Accept iterator in universal marker evaluation (#11571)
## Summary Something I noticed while working on https://github.com/astral-sh/uv/issues/11548.
This commit is contained in:
parent
e21f793a1f
commit
e95da5c3af
|
|
@ -1,4 +1,3 @@
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
@ -320,17 +319,13 @@ pub trait Installable<'lock> {
|
||||||
additional_activated_extras.push(key);
|
additional_activated_extras.push(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let temp_activated_extras = if additional_activated_extras.is_empty() {
|
|
||||||
Cow::Borrowed(&activated_extras)
|
|
||||||
} else {
|
|
||||||
let mut owned = activated_extras.clone();
|
|
||||||
owned.extend_from_slice(&additional_activated_extras);
|
|
||||||
Cow::Owned(owned)
|
|
||||||
};
|
|
||||||
if !dep.complexified_marker.evaluate(
|
if !dep.complexified_marker.evaluate(
|
||||||
marker_env,
|
marker_env,
|
||||||
&temp_activated_extras,
|
activated_extras
|
||||||
&activated_groups,
|
.iter()
|
||||||
|
.chain(additional_activated_extras.iter())
|
||||||
|
.copied(),
|
||||||
|
activated_groups.iter().copied(),
|
||||||
) {
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -413,8 +408,8 @@ pub trait Installable<'lock> {
|
||||||
for dep in deps {
|
for dep in deps {
|
||||||
if !dep.complexified_marker.evaluate(
|
if !dep.complexified_marker.evaluate(
|
||||||
marker_env,
|
marker_env,
|
||||||
&activated_extras,
|
activated_extras.iter().copied(),
|
||||||
&activated_groups,
|
activated_groups.iter().copied(),
|
||||||
) {
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -245,20 +245,18 @@ impl UniversalMarker {
|
||||||
pub(crate) fn evaluate<P, E, G>(
|
pub(crate) fn evaluate<P, E, G>(
|
||||||
self,
|
self,
|
||||||
env: &MarkerEnvironment,
|
env: &MarkerEnvironment,
|
||||||
extras: &[(P, E)],
|
extras: impl Iterator<Item = (P, E)>,
|
||||||
groups: &[(P, G)],
|
groups: impl Iterator<Item = (P, G)>,
|
||||||
) -> bool
|
) -> bool
|
||||||
where
|
where
|
||||||
P: Borrow<PackageName>,
|
P: Borrow<PackageName>,
|
||||||
E: Borrow<ExtraName>,
|
E: Borrow<ExtraName>,
|
||||||
G: Borrow<GroupName>,
|
G: Borrow<GroupName>,
|
||||||
{
|
{
|
||||||
let extras = extras
|
let extras =
|
||||||
.iter()
|
extras.map(|(package, extra)| encode_package_extra(package.borrow(), extra.borrow()));
|
||||||
.map(|(package, extra)| encode_package_extra(package.borrow(), extra.borrow()));
|
let groups =
|
||||||
let groups = groups
|
groups.map(|(package, group)| encode_package_group(package.borrow(), group.borrow()));
|
||||||
.iter()
|
|
||||||
.map(|(package, group)| encode_package_group(package.borrow(), group.borrow()));
|
|
||||||
self.marker
|
self.marker
|
||||||
.evaluate(env, &extras.chain(groups).collect::<Vec<ExtraName>>())
|
.evaluate(env, &extras.chain(groups).collect::<Vec<ExtraName>>())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue