Skip to content

Commit

Permalink
Use consistent order for extra groups in lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jun 12, 2024
1 parent aef74da commit a4a825b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
15 changes: 7 additions & 8 deletions crates/uv-resolver/src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::str::FromStr;

use anyhow::Result;
use either::Either;
use indexmap::IndexMap;
use petgraph::visit::EdgeRef;
use rustc_hash::FxHashMap;
use serde::{Deserialize, Deserializer};
Expand Down Expand Up @@ -59,7 +58,7 @@ pub struct Lock {
impl Lock {
/// Initialize a [`Lock`] from a [`ResolutionGraph`].
pub fn from_resolution_graph(graph: &ResolutionGraph) -> Result<Self, LockError> {
let mut locked_dists = IndexMap::with_capacity(graph.petgraph.node_count());
let mut locked_dists = BTreeMap::new();

// Lock all base packages.
for node_index in graph.petgraph.node_indices() {
Expand Down Expand Up @@ -531,10 +530,10 @@ pub struct Distribution {
wheels: Vec<Wheel>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
dependencies: Vec<Dependency>,
#[serde(default, skip_serializing_if = "IndexMap::is_empty")]
optional_dependencies: IndexMap<ExtraName, Vec<Dependency>>,
#[serde(default, skip_serializing_if = "IndexMap::is_empty")]
dev_dependencies: IndexMap<GroupName, Vec<Dependency>>,
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
optional_dependencies: BTreeMap<ExtraName, Vec<Dependency>>,
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
dev_dependencies: BTreeMap<GroupName, Vec<Dependency>>,
}

impl Distribution {
Expand All @@ -547,8 +546,8 @@ impl Distribution {
sdist,
wheels,
dependencies: vec![],
optional_dependencies: IndexMap::default(),
dev_dependencies: IndexMap::default(),
optional_dependencies: BTreeMap::default(),
dev_dependencies: BTreeMap::default(),
})
}

Expand Down
13 changes: 7 additions & 6 deletions crates/uv-resolver/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::thread;

use dashmap::DashMap;
use futures::{FutureExt, StreamExt, TryFutureExt};
use indexmap::{IndexMap, IndexSet};
use itertools::Itertools;
use pubgrub::error::PubGrubError;
use pubgrub::range::Range;
Expand Down Expand Up @@ -1521,10 +1522,10 @@ struct SolveState {
impl SolveState {
fn into_resolution(self) -> Resolution {
let solution = self.pubgrub.partial_solution.extract_solution();
let mut dependencies: FxHashMap<
let mut dependencies: IndexMap<
ResolutionDependencyNames,
FxHashSet<ResolutionDependencyVersions>,
> = FxHashMap::default();
IndexSet<ResolutionDependencyVersions>,
> = IndexMap::default();
for (package, self_version) in &solution {
for id in &self.pubgrub.incompatibilities[package] {
let pubgrub::solver::Kind::FromDependencyOf(
Expand Down Expand Up @@ -1682,7 +1683,7 @@ impl SolveState {
dev: dev.clone(),
url: url.clone(),
},
FxHashSet::from_iter([version]),
IndexSet::from_iter([version]),
))
} else {
None
Expand All @@ -1700,9 +1701,9 @@ impl SolveState {

#[derive(Debug, Default)]
pub(crate) struct Resolution {
pub(crate) packages: FxHashMap<ResolutionPackage, FxHashSet<Version>>,
pub(crate) packages: IndexMap<ResolutionPackage, IndexSet<Version>>,
pub(crate) dependencies:
FxHashMap<ResolutionDependencyNames, FxHashSet<ResolutionDependencyVersions>>,
IndexMap<ResolutionDependencyNames, IndexSet<ResolutionDependencyVersions>>,
pub(crate) pins: FilePins,
}

Expand Down

0 comments on commit a4a825b

Please sign in to comment.