Skip to content

Commit

Permalink
Add root
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jun 25, 2024
1 parent 7c082ef commit d41022e
Show file tree
Hide file tree
Showing 13 changed files with 437 additions and 269 deletions.
25 changes: 19 additions & 6 deletions crates/uv-resolver/src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use uv_configuration::ExtrasSpecification;
use uv_git::{GitReference, GitSha, RepositoryReference, ResolvedRepositoryReference};
use uv_normalize::{ExtraName, GroupName, PackageName};

use crate::resolution::AnnotatedDist;
use crate::resolution::{AnnotatedDist, ResolutionGraphNode};
use crate::{RequiresPython, ResolutionGraph};

#[derive(Clone, Debug, serde::Deserialize)]
Expand Down Expand Up @@ -62,11 +62,16 @@ impl Lock {

// Lock all base packages.
for node_index in graph.petgraph.node_indices() {
let dist = &graph.petgraph[node_index];
let ResolutionGraphNode::Dist(dist) = &graph.petgraph[node_index] else {
continue;
};
if dist.is_base() {
let mut locked_dist = Distribution::from_annotated_dist(dist)?;
for edge in graph.petgraph.edges(node_index) {
let dependency_dist = &graph.petgraph[edge.target()];
let ResolutionGraphNode::Dist(dependency_dist) = &graph.petgraph[edge.target()]
else {
continue;
};
let marker = edge.weight().as_ref();
locked_dist.add_dependency(dependency_dist, marker);
}
Expand All @@ -82,7 +87,9 @@ impl Lock {

// Lock all extras and development dependencies.
for node_index in graph.petgraph.node_indices() {
let dist = &graph.petgraph[node_index];
let ResolutionGraphNode::Dist(dist) = &graph.petgraph[node_index] else {
continue;
};
if let Some(extra) = dist.extra.as_ref() {
let id = DistributionId::from_annotated_dist(dist);
let Some(locked_dist) = locked_dists.get_mut(&id) else {
Expand All @@ -93,7 +100,10 @@ impl Lock {
.into());
};
for edge in graph.petgraph.edges(node_index) {
let dependency_dist = &graph.petgraph[edge.target()];
let ResolutionGraphNode::Dist(dependency_dist) = &graph.petgraph[edge.target()]
else {
continue;
};
let marker = edge.weight().as_ref();
locked_dist.add_optional_dependency(extra.clone(), dependency_dist, marker);
}
Expand All @@ -108,7 +118,10 @@ impl Lock {
.into());
};
for edge in graph.petgraph.edges(node_index) {
let dependency_dist = &graph.petgraph[edge.target()];
let ResolutionGraphNode::Dist(dependency_dist) = &graph.petgraph[edge.target()]
else {
continue;
};
let marker = edge.weight().as_ref();
locked_dist.add_dev_dependency(group.clone(), dependency_dist, marker);
}
Expand Down
Loading

0 comments on commit d41022e

Please sign in to comment.