Skip to content

Commit

Permalink
feat: switch to new solver backend implementation (#178)
Browse files Browse the repository at this point in the history
* feat: switch to new solver backend implementation

* fix: fmt

* fix: missing snapshot

* fix: actually all missing snapshots
  • Loading branch information
baszalmstra authored Jul 6, 2023
1 parent 26febab commit 477a4fa
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 144 deletions.
38 changes: 24 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ rattler_conda_types = { default-features = false, git = "https://github.com/mamb
rattler_networking = { default-features = false, git = "https://github.com/mamba-org/rattler", branch = "main" }
rattler_repodata_gateway = { default-features = false, git = "https://github.com/mamba-org/rattler", branch = "main", features = ["sparse"] }
rattler_shell = { default-features = false, git = "https://github.com/mamba-org/rattler", branch = "main", features = ["sysinfo"] }
rattler_solve = { default-features = false, git = "https://github.com/mamba-org/rattler", branch = "main" }
rattler_solve = { default-features = false, git = "https://github.com/mamba-org/rattler", branch = "main", features = ["libsolv-sys"] }
rattler_virtual_packages = { default-features = false, git = "https://github.com/mamba-org/rattler", branch = "main" }
#rattler = { default-features = false, path="../rattler/crates/rattler" }
#rattler_conda_types = { default-features = false, path="../rattler/crates/rattler_conda_types" }
Expand Down
15 changes: 9 additions & 6 deletions src/cli/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rattler_conda_types::{
version_spec::VersionOperator, MatchSpec, NamelessMatchSpec, Platform, Version, VersionSpec,
};
use rattler_repodata_gateway::sparse::SparseRepoData;
use rattler_solve::{LibsolvRepoData, SolverBackend};
use rattler_solve::{libsolv_sys, SolverImpl};
use std::collections::HashMap;
use std::path::PathBuf;

Expand Down Expand Up @@ -212,9 +212,7 @@ pub fn determine_best_version(
.map(|(name, spec)| MatchSpec::from_nameless(spec.clone(), Some(name.clone())))
.collect(),

available_packages: available_packages
.iter()
.map(|records| LibsolvRepoData::from_records(records)),
available_packages: &available_packages,

virtual_packages: get_minimal_virtual_packages(platform)
.into_iter()
Expand All @@ -227,12 +225,17 @@ pub fn determine_best_version(
pinned_packages: vec![],
};

let records = rattler_solve::LibsolvBackend.solve(task)?;
let records = libsolv_sys::Solver.solve(task)?;

// Determine the versions of the new packages
Ok(records
.into_iter()
.filter(|record| new_specs.contains_key(&record.package_record.name))
.map(|record| (record.package_record.name, record.package_record.version))
.map(|record| {
(
record.package_record.name,
record.package_record.version.into(),
)
})
.collect())
}
8 changes: 3 additions & 5 deletions src/cli/global/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rattler_shell::{
shell::Shell,
shell::ShellEnum,
};
use rattler_solve::{LibsolvRepoData, SolverBackend};
use rattler_solve::{libsolv_sys, SolverImpl};
use std::{
path::{Path, PathBuf},
str::FromStr,
Expand Down Expand Up @@ -219,9 +219,7 @@ pub async fn execute(args: Args) -> anyhow::Result<()> {
// Construct a solver task that we can start solving.
let task = rattler_solve::SolverTask {
specs: vec![package_matchspec],
available_packages: available_packages
.iter()
.map(|records| LibsolvRepoData::from_records(records)),
available_packages: &available_packages,

virtual_packages: rattler_virtual_packages::VirtualPackage::current()?
.iter()
Expand All @@ -234,7 +232,7 @@ pub async fn execute(args: Args) -> anyhow::Result<()> {
};

// Solve it
let records = rattler_solve::LibsolvBackend.solve(task)?;
let records = libsolv_sys::Solver.solve(task)?;

// Create the binary environment prefix where we install or update the package
let bin_prefix = BinEnvDir::create(&package_name).await?;
Expand Down
10 changes: 4 additions & 6 deletions src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use rattler_conda_types::{
};
use rattler_networking::AuthenticatedClient;
use rattler_repodata_gateway::sparse::SparseRepoData;
use rattler_solve::{LibsolvRepoData, SolverBackend};
use rattler_solve::{libsolv_sys, SolverImpl};
use std::collections::HashMap;
use std::{
collections::{HashSet, VecDeque},
Expand Down Expand Up @@ -329,9 +329,7 @@ pub async fn update_lock_file(
// Construct a solver task that we can start solving.
let task = rattler_solve::SolverTask {
specs: match_specs.clone(),
available_packages: available_packages
.iter()
.map(|records| LibsolvRepoData::from_records(records)),
available_packages: &available_packages,

// TODO: All these things.
locked_packages: existing_lock_file
Expand All @@ -343,7 +341,7 @@ pub async fn update_lock_file(
};

// Solve the task
let records = rattler_solve::LibsolvBackend.solve(task)?;
let records = libsolv_sys::Solver.solve(task)?;

// Update lock file
let mut locked_packages = LockedPackages::new(platform);
Expand Down Expand Up @@ -415,7 +413,7 @@ pub fn get_required_packages(
subdir: "".to_string(),
timestamp: None,
track_features: vec![],
version: Version::from_str(&pkg.version)?,
version: Version::from_str(&pkg.version)?.into(),
},
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ ProjectManifest {
project: ProjectMetadata {
name: "foo",
version: Version {
norm: Some(
"0.1.0",
),
version: "[[0], [0], [1], [0]]",
local: "[]",
version: [[0], [0], [1], [0]],
local: [],
},
description: None,
authors: [],
Expand All @@ -37,11 +34,8 @@ ProjectManifest {
Operator(
Equals,
Version {
norm: Some(
"1.0.0",
),
version: "[[0], [1], [0], [0]]",
local: "[]",
version: [[0], [1], [0], [0]],
local: [],
},
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ ProjectManifest {
project: ProjectMetadata {
name: "foo",
version: Version {
norm: Some(
"0.1.0",
),
version: "[[0], [0], [1], [0]]",
local: "[]",
version: [[0], [0], [1], [0]],
local: [],
},
description: None,
authors: [],
Expand Down Expand Up @@ -47,11 +44,8 @@ ProjectManifest {
Operator(
Equals,
Version {
norm: Some(
"3.4.5",
),
version: "[[0], [3], [4], [5]]",
local: "[]",
version: [[0], [3], [4], [5]],
local: [],
},
),
),
Expand Down Expand Up @@ -80,11 +74,8 @@ ProjectManifest {
Operator(
Equals,
Version {
norm: Some(
"1.2.3",
),
version: "[[0], [1], [2], [3]]",
local: "[]",
version: [[0], [1], [2], [3]],
local: [],
},
),
),
Expand Down
21 changes: 6 additions & 15 deletions src/project/snapshots/pixi__project__tests__dependency_sets.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ expression: "project.all_dependencies(Platform::Linux64).unwrap()"
Operator(
Equals,
Version {
norm: Some(
"1.0",
),
version: "[[0], [1], [0]]",
local: "[]",
version: [[0], [1], [0]],
local: [],
},
),
),
Expand All @@ -31,11 +28,8 @@ expression: "project.all_dependencies(Platform::Linux64).unwrap()"
Operator(
Equals,
Version {
norm: Some(
"2.12",
),
version: "[[0], [2], [12]]",
local: "[]",
version: [[0], [2], [12]],
local: [],
},
),
),
Expand All @@ -53,11 +47,8 @@ expression: "project.all_dependencies(Platform::Linux64).unwrap()"
Operator(
Equals,
Version {
norm: Some(
"1.0",
),
version: "[[0], [1], [0]]",
local: "[]",
version: [[0], [1], [0]],
local: [],
},
),
),
Expand Down
Loading

0 comments on commit 477a4fa

Please sign in to comment.