mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-03 10:33:49 +00:00
*: update "conflicting groups" terminology everywhere else
This commit is contained in:
parent
19a044d4db
commit
bb78e00a87
28 changed files with 134 additions and 142 deletions
|
@ -82,7 +82,7 @@ pub struct Lock {
|
|||
/// forks in the lockfile so we can recreate them in subsequent resolutions.
|
||||
fork_markers: Vec<MarkerTree>,
|
||||
/// The conflicting groups/extras specified by the user.
|
||||
conflicting_groups: Conflicts,
|
||||
conflicts: Conflicts,
|
||||
/// The list of supported environments specified by the user.
|
||||
supported_environments: Vec<MarkerTree>,
|
||||
/// The range of supported Python versions.
|
||||
|
@ -315,7 +315,7 @@ impl Lock {
|
|||
requires_python: RequiresPython,
|
||||
options: ResolverOptions,
|
||||
manifest: ResolverManifest,
|
||||
conflicting_groups: Conflicts,
|
||||
conflicts: Conflicts,
|
||||
supported_environments: Vec<MarkerTree>,
|
||||
fork_markers: Vec<MarkerTree>,
|
||||
) -> Result<Self, LockError> {
|
||||
|
@ -465,7 +465,7 @@ impl Lock {
|
|||
let lock = Self {
|
||||
version,
|
||||
fork_markers,
|
||||
conflicting_groups,
|
||||
conflicts,
|
||||
supported_environments,
|
||||
requires_python,
|
||||
options,
|
||||
|
@ -485,8 +485,8 @@ impl Lock {
|
|||
|
||||
/// Record the conflicting groups that were used to generate this lock.
|
||||
#[must_use]
|
||||
pub fn with_conflicting_groups(mut self, conflicting_groups: Conflicts) -> Self {
|
||||
self.conflicting_groups = conflicting_groups;
|
||||
pub fn with_conflicts(mut self, conflicts: Conflicts) -> Self {
|
||||
self.conflicts = conflicts;
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -550,8 +550,8 @@ impl Lock {
|
|||
}
|
||||
|
||||
/// Returns the conflicting groups that were used to generate this lock.
|
||||
pub fn conflicting_groups(&self) -> &Conflicts {
|
||||
&self.conflicting_groups
|
||||
pub fn conflicts(&self) -> &Conflicts {
|
||||
&self.conflicts
|
||||
}
|
||||
|
||||
/// Returns the supported environments that were used to generate this lock.
|
||||
|
@ -632,9 +632,9 @@ impl Lock {
|
|||
doc.insert("supported-markers", value(supported_environments));
|
||||
}
|
||||
|
||||
if !self.conflicting_groups.is_empty() {
|
||||
if !self.conflicts.is_empty() {
|
||||
let mut list = Array::new();
|
||||
for groups in self.conflicting_groups.iter() {
|
||||
for groups in self.conflicts.iter() {
|
||||
list.push(each_element_on_its_line_array(groups.iter().map(|group| {
|
||||
let mut table = InlineTable::new();
|
||||
table.insert("package", Value::from(group.package().to_string()));
|
||||
|
@ -642,7 +642,7 @@ impl Lock {
|
|||
table
|
||||
})));
|
||||
}
|
||||
doc.insert("conflicting-groups", value(list));
|
||||
doc.insert("conflicts", value(list));
|
||||
}
|
||||
|
||||
// Write the settings that were used to generate the resolution.
|
||||
|
@ -1383,8 +1383,8 @@ struct LockWire {
|
|||
fork_markers: Vec<SimplifiedMarkerTree>,
|
||||
#[serde(rename = "supported-markers", default)]
|
||||
supported_environments: Vec<SimplifiedMarkerTree>,
|
||||
#[serde(rename = "conflicting-groups", default)]
|
||||
conflicting_groups: Option<Conflicts>,
|
||||
#[serde(rename = "conflicts", default)]
|
||||
conflicts: Option<Conflicts>,
|
||||
/// We discard the lockfile if these options match.
|
||||
#[serde(default)]
|
||||
options: ResolverOptions,
|
||||
|
@ -1436,7 +1436,7 @@ impl TryFrom<LockWire> for Lock {
|
|||
wire.requires_python,
|
||||
wire.options,
|
||||
wire.manifest,
|
||||
wire.conflicting_groups.unwrap_or_else(Conflicts::empty),
|
||||
wire.conflicts.unwrap_or_else(Conflicts::empty),
|
||||
supported_environments,
|
||||
fork_markers,
|
||||
)?;
|
||||
|
|
|
@ -6,7 +6,7 @@ Ok(
|
|||
Lock {
|
||||
version: 1,
|
||||
fork_markers: [],
|
||||
conflicting_groups: ConflictingGroupList(
|
||||
conflicts: Conflicts(
|
||||
[],
|
||||
),
|
||||
supported_environments: [],
|
||||
|
|
|
@ -6,7 +6,7 @@ Ok(
|
|||
Lock {
|
||||
version: 1,
|
||||
fork_markers: [],
|
||||
conflicting_groups: ConflictingGroupList(
|
||||
conflicts: Conflicts(
|
||||
[],
|
||||
),
|
||||
supported_environments: [],
|
||||
|
|
|
@ -6,7 +6,7 @@ Ok(
|
|||
Lock {
|
||||
version: 1,
|
||||
fork_markers: [],
|
||||
conflicting_groups: ConflictingGroupList(
|
||||
conflicts: Conflicts(
|
||||
[],
|
||||
),
|
||||
supported_environments: [],
|
||||
|
|
|
@ -6,7 +6,7 @@ Ok(
|
|||
Lock {
|
||||
version: 1,
|
||||
fork_markers: [],
|
||||
conflicting_groups: ConflictingGroupList(
|
||||
conflicts: Conflicts(
|
||||
[],
|
||||
),
|
||||
supported_environments: [],
|
||||
|
|
|
@ -6,7 +6,7 @@ Ok(
|
|||
Lock {
|
||||
version: 1,
|
||||
fork_markers: [],
|
||||
conflicting_groups: ConflictingGroupList(
|
||||
conflicts: Conflicts(
|
||||
[],
|
||||
),
|
||||
supported_environments: [],
|
||||
|
|
|
@ -6,7 +6,7 @@ Ok(
|
|||
Lock {
|
||||
version: 1,
|
||||
fork_markers: [],
|
||||
conflicting_groups: ConflictingGroupList(
|
||||
conflicts: Conflicts(
|
||||
[],
|
||||
),
|
||||
supported_environments: [],
|
||||
|
|
|
@ -6,7 +6,7 @@ Ok(
|
|||
Lock {
|
||||
version: 1,
|
||||
fork_markers: [],
|
||||
conflicting_groups: ConflictingGroupList(
|
||||
conflicts: Conflicts(
|
||||
[],
|
||||
),
|
||||
supported_environments: [],
|
||||
|
|
|
@ -6,7 +6,7 @@ Ok(
|
|||
Lock {
|
||||
version: 1,
|
||||
fork_markers: [],
|
||||
conflicting_groups: ConflictingGroupList(
|
||||
conflicts: Conflicts(
|
||||
[],
|
||||
),
|
||||
supported_environments: [],
|
||||
|
|
|
@ -6,7 +6,7 @@ Ok(
|
|||
Lock {
|
||||
version: 1,
|
||||
fork_markers: [],
|
||||
conflicting_groups: ConflictingGroupList(
|
||||
conflicts: Conflicts(
|
||||
[],
|
||||
),
|
||||
supported_environments: [],
|
||||
|
|
|
@ -6,7 +6,7 @@ Ok(
|
|||
Lock {
|
||||
version: 1,
|
||||
fork_markers: [],
|
||||
conflicting_groups: ConflictingGroupList(
|
||||
conflicts: Conflicts(
|
||||
[],
|
||||
),
|
||||
supported_environments: [],
|
||||
|
|
|
@ -190,7 +190,7 @@ impl PubGrubPackage {
|
|||
///
|
||||
/// If this package can't possibly be classified as a conflicting group,
|
||||
/// then this returns `None`.
|
||||
pub(crate) fn conflicting_group(&self) -> Option<ConflictItemRef<'_>> {
|
||||
pub(crate) fn conflicting_item(&self) -> Option<ConflictItemRef<'_>> {
|
||||
let package = self.name_no_root()?;
|
||||
let extra = self.extra()?;
|
||||
Some(ConflictItemRef::from((package, extra)))
|
||||
|
|
|
@ -103,7 +103,7 @@ impl ResolutionGraph {
|
|||
index: &InMemoryIndex,
|
||||
git: &GitResolver,
|
||||
python: &PythonRequirement,
|
||||
conflicting_groups: &Conflicts,
|
||||
conflicts: &Conflicts,
|
||||
resolution_strategy: &ResolutionStrategy,
|
||||
options: Options,
|
||||
) -> Result<Self, ResolveError> {
|
||||
|
@ -251,7 +251,7 @@ impl ResolutionGraph {
|
|||
// the same time. At which point, uv will report an error,
|
||||
// thereby sidestepping the possibility of installing different
|
||||
// versions of the same package into the same virtualenv. ---AG
|
||||
if conflicting_groups.is_empty() {
|
||||
if conflicts.is_empty() {
|
||||
#[allow(unused_mut, reason = "Used in debug_assertions below")]
|
||||
let mut conflicting = graph.find_conflicting_distributions();
|
||||
if !conflicting.is_empty() {
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use uv_normalize::{ExtraName, PackageName};
|
||||
use uv_pep508::{MarkerEnvironment, MarkerTree};
|
||||
use uv_pypi_types::{ConflictItem, ConflictItemRef, Conflicts, ResolverMarkerEnvironment};
|
||||
use uv_pypi_types::{ConflictItem, ConflictItemRef, ResolverMarkerEnvironment};
|
||||
|
||||
use crate::pubgrub::{PubGrubDependency, PubGrubPackage};
|
||||
use crate::requires_python::RequiresPythonRange;
|
||||
|
@ -425,7 +425,6 @@ impl<'d> Forker<'d> {
|
|||
pub(crate) fn fork(
|
||||
&self,
|
||||
env: &ResolverEnvironment,
|
||||
_conflicting_groups: &Conflicts,
|
||||
) -> Option<(Forker<'d>, Vec<ResolverEnvironment>)> {
|
||||
if !env.included_by_marker(&self.marker) {
|
||||
return None;
|
||||
|
|
|
@ -109,7 +109,7 @@ struct ResolverState<InstalledPackages: InstalledPackagesProvider> {
|
|||
hasher: HashStrategy,
|
||||
env: ResolverEnvironment,
|
||||
python_requirement: PythonRequirement,
|
||||
conflicting_groups: Conflicts,
|
||||
conflicts: Conflicts,
|
||||
workspace_members: BTreeSet<PackageName>,
|
||||
selector: CandidateSelector,
|
||||
index: InMemoryIndex,
|
||||
|
@ -150,7 +150,7 @@ impl<'a, Context: BuildContext, InstalledPackages: InstalledPackagesProvider>
|
|||
options: Options,
|
||||
python_requirement: &'a PythonRequirement,
|
||||
env: ResolverEnvironment,
|
||||
conflicting_groups: Conflicts,
|
||||
conflicts: Conflicts,
|
||||
tags: Option<&'a Tags>,
|
||||
flat_index: &'a FlatIndex,
|
||||
index: &'a InMemoryIndex,
|
||||
|
@ -177,7 +177,7 @@ impl<'a, Context: BuildContext, InstalledPackages: InstalledPackagesProvider>
|
|||
hasher,
|
||||
env,
|
||||
python_requirement,
|
||||
conflicting_groups,
|
||||
conflicts,
|
||||
index,
|
||||
build_context.git(),
|
||||
build_context.capabilities(),
|
||||
|
@ -198,7 +198,7 @@ impl<Provider: ResolverProvider, InstalledPackages: InstalledPackagesProvider>
|
|||
hasher: &HashStrategy,
|
||||
env: ResolverEnvironment,
|
||||
python_requirement: &PythonRequirement,
|
||||
conflicting_groups: Conflicts,
|
||||
conflicts: Conflicts,
|
||||
index: &InMemoryIndex,
|
||||
git: &GitResolver,
|
||||
capabilities: &IndexCapabilities,
|
||||
|
@ -226,7 +226,7 @@ impl<Provider: ResolverProvider, InstalledPackages: InstalledPackagesProvider>
|
|||
locations: locations.clone(),
|
||||
env,
|
||||
python_requirement: python_requirement.clone(),
|
||||
conflicting_groups,
|
||||
conflicts,
|
||||
installed_packages,
|
||||
unavailable_packages: DashMap::default(),
|
||||
incomplete_packages: DashMap::default(),
|
||||
|
@ -607,7 +607,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
&self.index,
|
||||
&self.git,
|
||||
&self.python_requirement,
|
||||
&self.conflicting_groups,
|
||||
&self.conflicts,
|
||||
self.selector.resolution_strategy(),
|
||||
self.options,
|
||||
)
|
||||
|
@ -1207,7 +1207,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
Dependencies::Unavailable(err) => ForkedDependencies::Unavailable(err),
|
||||
})
|
||||
} else {
|
||||
Ok(result?.fork(env, python_requirement, &self.conflicting_groups))
|
||||
Ok(result?.fork(env, python_requirement, &self.conflicts))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1387,15 +1387,12 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
}
|
||||
};
|
||||
|
||||
if let Some(err) =
|
||||
find_conflicting_extra(&self.conflicting_groups, &metadata.requires_dist)
|
||||
if let Some(err) = find_conflicting_extra(&self.conflicts, &metadata.requires_dist)
|
||||
{
|
||||
return Err(err);
|
||||
}
|
||||
for dependencies in metadata.dependency_groups.values() {
|
||||
if let Some(err) =
|
||||
find_conflicting_extra(&self.conflicting_groups, dependencies)
|
||||
{
|
||||
if let Some(err) = find_conflicting_extra(&self.conflicts, dependencies) {
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
|
@ -2694,7 +2691,7 @@ impl Dependencies {
|
|||
self,
|
||||
env: &ResolverEnvironment,
|
||||
python_requirement: &PythonRequirement,
|
||||
conflicting_groups: &Conflicts,
|
||||
conflicts: &Conflicts,
|
||||
) -> ForkedDependencies {
|
||||
let deps = match self {
|
||||
Dependencies::Available(deps) => deps,
|
||||
|
@ -2713,7 +2710,7 @@ impl Dependencies {
|
|||
let Forks {
|
||||
mut forks,
|
||||
diverging_packages,
|
||||
} = Forks::new(name_to_deps, env, python_requirement, conflicting_groups);
|
||||
} = Forks::new(name_to_deps, env, python_requirement, conflicts);
|
||||
if forks.is_empty() {
|
||||
ForkedDependencies::Unforked(vec![])
|
||||
} else if forks.len() == 1 {
|
||||
|
@ -2775,7 +2772,7 @@ impl Forks {
|
|||
name_to_deps: BTreeMap<PackageName, Vec<PubGrubDependency>>,
|
||||
env: &ResolverEnvironment,
|
||||
python_requirement: &PythonRequirement,
|
||||
conflicting_groups: &Conflicts,
|
||||
conflicts: &Conflicts,
|
||||
) -> Forks {
|
||||
let python_marker = python_requirement.to_marker_tree();
|
||||
|
||||
|
@ -2839,8 +2836,7 @@ impl Forks {
|
|||
|
||||
let mut new = vec![];
|
||||
for fork in std::mem::take(&mut forks) {
|
||||
let Some((remaining_forker, envs)) = forker.fork(&fork.env, conflicting_groups)
|
||||
else {
|
||||
let Some((remaining_forker, envs)) = forker.fork(&fork.env) else {
|
||||
new.push(fork);
|
||||
continue;
|
||||
};
|
||||
|
@ -2880,12 +2876,12 @@ impl Forks {
|
|||
// For example, if we have conflicting groups {x1, x2} and {x3,
|
||||
// x4}, we need to make sure the forks generated from one set
|
||||
// also account for the other set.
|
||||
for groups in conflicting_groups.iter() {
|
||||
for groups in conflicts.iter() {
|
||||
let mut new = vec![];
|
||||
for fork in std::mem::take(&mut forks) {
|
||||
let mut has_conflicting_dependency = false;
|
||||
for group in groups.iter() {
|
||||
if fork.contains_conflicting_group(group.as_ref()) {
|
||||
if fork.contains_conflicting_item(group.as_ref()) {
|
||||
has_conflicting_dependency = true;
|
||||
break;
|
||||
}
|
||||
|
@ -2954,7 +2950,7 @@ struct Fork {
|
|||
/// This exists to make some access patterns more efficient. Namely,
|
||||
/// it makes it easy to check whether there's a dependency with a
|
||||
/// particular conflicting group in this fork.
|
||||
conflicting_groups: FxHashMap<PackageName, FxHashSet<ExtraName>>,
|
||||
conflicts: FxHashMap<PackageName, FxHashSet<ExtraName>>,
|
||||
/// The resolver environment for this fork.
|
||||
///
|
||||
/// Principally, this corresponds to the markers in this for. So in the
|
||||
|
@ -2975,18 +2971,18 @@ impl Fork {
|
|||
fn new(env: ResolverEnvironment) -> Fork {
|
||||
Fork {
|
||||
dependencies: vec![],
|
||||
conflicting_groups: FxHashMap::default(),
|
||||
conflicts: FxHashMap::default(),
|
||||
env,
|
||||
}
|
||||
}
|
||||
|
||||
/// Add a dependency to this fork.
|
||||
fn add_dependency(&mut self, dep: PubGrubDependency) {
|
||||
if let Some(conflicting_group) = dep.package.conflicting_group() {
|
||||
self.conflicting_groups
|
||||
.entry(conflicting_group.package().clone())
|
||||
if let Some(conflicting_item) = dep.package.conflicting_item() {
|
||||
self.conflicts
|
||||
.entry(conflicting_item.package().clone())
|
||||
.or_default()
|
||||
.insert(conflicting_group.extra().clone());
|
||||
.insert(conflicting_item.extra().clone());
|
||||
}
|
||||
self.dependencies.push(dep);
|
||||
}
|
||||
|
@ -3004,9 +3000,9 @@ impl Fork {
|
|||
if self.env.included_by_marker(markers) {
|
||||
return true;
|
||||
}
|
||||
if let Some(conflicting_group) = dep.package.conflicting_group() {
|
||||
if let Some(set) = self.conflicting_groups.get_mut(conflicting_group.package()) {
|
||||
set.remove(conflicting_group.extra());
|
||||
if let Some(conflicting_item) = dep.package.conflicting_item() {
|
||||
if let Some(set) = self.conflicts.get_mut(conflicting_item.package()) {
|
||||
set.remove(conflicting_item.extra());
|
||||
}
|
||||
}
|
||||
false
|
||||
|
@ -3015,8 +3011,8 @@ impl Fork {
|
|||
|
||||
/// Returns true if any of the dependencies in this fork contain a
|
||||
/// dependency with the given package and extra values.
|
||||
fn contains_conflicting_group(&self, group: ConflictItemRef<'_>) -> bool {
|
||||
self.conflicting_groups
|
||||
fn contains_conflicting_item(&self, group: ConflictItemRef<'_>) -> bool {
|
||||
self.conflicts
|
||||
.get(group.package())
|
||||
.map(|set| set.contains(group.extra()))
|
||||
.unwrap_or(false)
|
||||
|
@ -3028,15 +3024,15 @@ impl Fork {
|
|||
fn exclude(mut self, groups: impl IntoIterator<Item = ConflictItem>) -> Fork {
|
||||
self.env = self.env.exclude_by_group(groups);
|
||||
self.dependencies.retain(|dep| {
|
||||
let Some(conflicting_group) = dep.package.conflicting_group() else {
|
||||
let Some(conflicting_item) = dep.package.conflicting_item() else {
|
||||
return true;
|
||||
};
|
||||
if self.env.included_by_group(conflicting_group) {
|
||||
if self.env.included_by_group(conflicting_item) {
|
||||
return true;
|
||||
}
|
||||
if let Some(conflicting_group) = dep.package.conflicting_group() {
|
||||
if let Some(set) = self.conflicting_groups.get_mut(conflicting_group.package()) {
|
||||
set.remove(conflicting_group.extra());
|
||||
if let Some(conflicting_item) = dep.package.conflicting_item() {
|
||||
if let Some(set) = self.conflicts.get_mut(conflicting_item.package()) {
|
||||
set.remove(conflicting_item.extra());
|
||||
}
|
||||
}
|
||||
false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue