diff --git a/Cargo.lock b/Cargo.lock index fad01b4ff..eed97b340 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3748,6 +3748,7 @@ dependencies = [ "rattler_conda_types", "rattler_digest", "resolvo", + "serde", "tempfile", "thiserror", "tracing", diff --git a/Cargo.toml b/Cargo.toml index 6162742f2..c26432af7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ rattler_shell = { version = "0.20.6", default-features = false, features = [ ] } rattler_solve = { version = "0.23.2", default-features = false, features = [ "resolvo", + "serde" ] } rattler_virtual_packages = { version = "0.19.13", default-features = false } rattler_package_streaming = { version = "0.21.1", default-features = false } diff --git a/src/build.rs b/src/build.rs index 4b96b022e..060ac9c2f 100644 --- a/src/build.rs +++ b/src/build.rs @@ -5,6 +5,7 @@ use std::vec; use miette::IntoDiagnostic; use rattler_index::index; +use rattler_solve::{ChannelPriority, SolveStrategy}; use crate::metadata::Output; use crate::package_test::TestConfiguration; @@ -168,6 +169,8 @@ pub async fn run_build( target_platform: Some(output.build_configuration.host_platform), keep_test_prefix: tool_configuration.no_clean, channels: output.reindex_channels().into_diagnostic()?, + channel_priority: ChannelPriority::Strict, + solve_strategy: SolveStrategy::Highest, tool_configuration: tool_configuration.clone(), }, ) diff --git a/src/lib.rs b/src/lib.rs index 78ada148b..30c68982b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,6 +39,7 @@ use metadata::Output; use miette::{IntoDiagnostic, WrapErr}; use petgraph::{algo::toposort, graph::DiGraph, visit::DfsPostOrder}; use rattler_conda_types::{package::ArchiveType, Channel, ChannelConfig, Platform}; +use rattler_solve::{ChannelPriority, SolveStrategy}; use recipe::parser::Dependency; use std::{ collections::{BTreeMap, HashMap}, @@ -283,6 +284,8 @@ pub async fn get_build_output( ) .into_diagnostic()?, channels, + channel_priority: ChannelPriority::Strict, + solve_strategy: SolveStrategy::Highest, timestamp, subpackages: subpackages.clone(), packaging_settings: PackagingSettings::from_args( @@ -376,6 +379,8 @@ pub async fn run_test_from_args( target_platform: None, keep_test_prefix: false, channels, + channel_priority: ChannelPriority::Strict, + solve_strategy: SolveStrategy::Highest, tool_configuration: Configuration { client, fancy_log_handler, diff --git a/src/metadata.rs b/src/metadata.rs index 84846fad0..f49b291f6 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -19,6 +19,7 @@ use rattler_conda_types::{ }; use rattler_index::index; use rattler_package_streaming::write::CompressionLevel; +use rattler_solve::{ChannelPriority, SolveStrategy}; use serde::{Deserialize, Serialize}; use url::Url; @@ -219,6 +220,10 @@ pub struct BuildConfiguration { pub directories: Directories, /// The channels to use when resolving environments pub channels: Vec, + /// The channel priority that is used to resolve dependencies + pub channel_priority: ChannelPriority, + /// The solve strategy to use when resolving dependencies + pub solve_strategy: SolveStrategy, /// The timestamp to use for the build pub timestamp: chrono::DateTime, /// All subpackages coming from this output or other outputs from the same recipe @@ -271,7 +276,7 @@ pub struct BuildSummary { /// A output. This is the central element that is passed to the `run_build` function /// and fully specifies all the options and settings to run the build. -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Output { /// The rendered recipe that is used to build this output pub recipe: Recipe, @@ -672,9 +677,8 @@ mod test { timestamp: Some(chrono::Utc.timestamp_opt(123123, 0).unwrap()), track_features: vec![], version: VersionWithSource::from_str("1.2.3").unwrap(), - purls: Default::default(), - // TODO! - run_exports: Default::default(), + purls: None, + run_exports: None, }, file_name: "test-1.2.3-h123.tar.bz2".into(), url: Url::from_str("https://test.com/test/linux-64/test-1.2.3-h123.tar.bz2") diff --git a/src/package_test/run_test.rs b/src/package_test/run_test.rs index 9ef4f85e2..0b2dff930 100644 --- a/src/package_test/run_test.rs +++ b/src/package_test/run_test.rs @@ -21,6 +21,7 @@ use rattler::package_cache::CacheKey; use rattler_conda_types::{package::ArchiveIdentifier, MatchSpec, Platform}; use rattler_index::index; use rattler_shell::activation::ActivationError; +use rattler_solve::{ChannelPriority, SolveStrategy}; use url::Url; use crate::env_vars; @@ -168,7 +169,7 @@ async fn legacy_tests_from_folder(pkg: &Path) -> Result<(PathBuf, Vec), s } /// The configuration for a test -#[derive(Default, Clone, Debug)] +#[derive(Default, Clone)] pub struct TestConfiguration { /// The test prefix directory (will be created) pub test_prefix: PathBuf, @@ -179,6 +180,10 @@ pub struct TestConfiguration { /// The channels to use for the test – do not forget to add the local build outputs channel /// if desired pub channels: Vec, + /// The channel priority that is used to resolve dependencies + pub channel_priority: ChannelPriority, + /// The solve strategy to use when resolving dependencies + pub solve_strategy: SolveStrategy, /// The tool configuration pub tool_configuration: tool_configuration::Configuration, } @@ -307,6 +312,8 @@ pub async fn run_test(package_file: &Path, config: &TestConfiguration) -> Result &prefix, &config.channels, &config.tool_configuration, + config.channel_priority, + config.solve_strategy, ) .await .map_err(TestError::TestEnvironmentSetup)?; @@ -370,6 +377,8 @@ async fn run_python_test( prefix, &config.channels, &config.tool_configuration, + config.channel_priority, + config.solve_strategy, ) .await .map_err(TestError::TestEnvironmentSetup)?; @@ -444,6 +453,8 @@ async fn run_shell_test( &build_prefix, &config.channels, &config.tool_configuration, + config.channel_priority, + config.solve_strategy, ) .await .map_err(TestError::TestEnvironmentSetup)?; @@ -473,6 +484,8 @@ async fn run_shell_test( &run_env, &config.channels, &config.tool_configuration, + config.channel_priority, + config.solve_strategy, ) .await .map_err(TestError::TestEnvironmentSetup)?; diff --git a/src/render/resolved_dependencies.rs b/src/render/resolved_dependencies.rs index b53ea0526..9941e0be8 100644 --- a/src/render/resolved_dependencies.rs +++ b/src/render/resolved_dependencies.rs @@ -593,6 +593,8 @@ async fn resolve_dependencies( &output.build_configuration.directories.build_prefix, channels, tool_configuration, + output.build_configuration.channel_priority, + output.build_configuration.solve_strategy, ) .await .map_err(ResolveError::from)?; @@ -693,6 +695,8 @@ async fn resolve_dependencies( &output.build_configuration.directories.host_prefix, channels, tool_configuration, + output.build_configuration.channel_priority, + output.build_configuration.solve_strategy, ) .await .map_err(ResolveError::from)?; diff --git a/src/render/solver.rs b/src/render/solver.rs index 98f5b6929..34ab7b26b 100644 --- a/src/render/solver.rs +++ b/src/render/solver.rs @@ -5,7 +5,7 @@ use indicatif::{HumanBytes, ProgressBar}; use rattler::install::{DefaultProgressFormatter, IndicatifReporter, Installer}; use rattler_conda_types::{Channel, GenericVirtualPackage, MatchSpec, Platform, RepoDataRecord}; use rattler_repodata_gateway::Gateway; -use rattler_solve::{resolvo::Solver, SolverImpl, SolverTask}; +use rattler_solve::{resolvo::Solver, ChannelPriority, SolveStrategy, SolverImpl, SolverTask}; use url::Url; use crate::tool_configuration; @@ -54,6 +54,8 @@ pub async fn create_environment( target_prefix: &Path, channels: &[Url], tool_configuration: &tool_configuration::Configuration, + channel_priority: ChannelPriority, + solve_strategy: SolveStrategy, ) -> anyhow::Result> { // Parse the specs from the command line. We do this explicitly instead of allow clap to deal // with this because we need to parse the `channel_config` when parsing matchspecs. @@ -95,6 +97,8 @@ pub async fn create_environment( let solver_task = SolverTask { virtual_packages, specs: specs.to_vec(), + channel_priority, + strategy: solve_strategy, ..SolverTask::from_iter(&repo_data) }; diff --git a/src/snapshots/rattler_build__metadata__test__curl_recipe.yaml.snap b/src/snapshots/rattler_build__metadata__test__curl_recipe.yaml.snap index 69283f9ea..d03ad4745 100644 --- a/src/snapshots/rattler_build__metadata__test__curl_recipe.yaml.snap +++ b/src/snapshots/rattler_build__metadata__test__curl_recipe.yaml.snap @@ -1,6 +1,5 @@ --- source: src/metadata.rs -assertion_line: 734 expression: output --- recipe: @@ -45,6 +44,8 @@ build_configuration: build_dir: /Users/wolfv/Programs/rattler-build/output/bld/rattler-build_curl_1700573293 channels: - "https://conda.anaconda.org/conda-forge" + channel_priority: strict + solve_strategy: highest timestamp: "2023-11-21T13:28:13.086796Z" subpackages: curl: diff --git a/src/snapshots/rattler_build__metadata__test__read_recipe_with_sources.snap b/src/snapshots/rattler_build__metadata__test__read_recipe_with_sources.snap index 55d4f08de..8b4aca24d 100644 --- a/src/snapshots/rattler_build__metadata__test__read_recipe_with_sources.snap +++ b/src/snapshots/rattler_build__metadata__test__read_recipe_with_sources.snap @@ -1,6 +1,5 @@ --- source: src/metadata.rs -assertion_line: 745 expression: git_source_output --- recipe: @@ -41,6 +40,8 @@ build_configuration: build_dir: /Users/wolfv/Programs/rattler-build/output/bld/rattler-build_git_source_1704379826 channels: - "https://conda.anaconda.org/conda-forge" + channel_priority: strict + solve_strategy: highest timestamp: "2024-01-04T14:50:26.411202Z" subpackages: git_source: diff --git a/src/snapshots/rattler_build__metadata__test__rich_recipe.yaml.snap b/src/snapshots/rattler_build__metadata__test__rich_recipe.yaml.snap index 51896adcc..bea1aedae 100644 --- a/src/snapshots/rattler_build__metadata__test__rich_recipe.yaml.snap +++ b/src/snapshots/rattler_build__metadata__test__rich_recipe.yaml.snap @@ -1,6 +1,5 @@ --- source: src/metadata.rs -assertion_line: 734 expression: output --- recipe: @@ -62,6 +61,8 @@ build_configuration: build_dir: /Users/wolfv/Programs/rattler-build/output/bld/rattler-build_rich_1702492812 channels: - "https://conda.anaconda.org/conda-forge" + channel_priority: strict + solve_strategy: highest timestamp: "2023-12-13T18:40:12.845800Z" subpackages: rich: diff --git a/test-data/rendered_recipes/curl_recipe.yaml b/test-data/rendered_recipes/curl_recipe.yaml index c911700a8..5074a5b7e 100644 --- a/test-data/rendered_recipes/curl_recipe.yaml +++ b/test-data/rendered_recipes/curl_recipe.yaml @@ -42,6 +42,8 @@ build_configuration: build_dir: /Users/wolfv/Programs/rattler-build/output/bld/rattler-build_curl_1700573293 channels: - https://conda.anaconda.org/conda-forge + channel_priority: strict + solve_strategy: highest timestamp: 2023-11-21T13:28:13.086796Z subpackages: curl: diff --git a/test-data/rendered_recipes/git_source.yaml b/test-data/rendered_recipes/git_source.yaml index 83df6684a..94852fbb9 100644 --- a/test-data/rendered_recipes/git_source.yaml +++ b/test-data/rendered_recipes/git_source.yaml @@ -36,6 +36,8 @@ build_configuration: build_dir: /Users/wolfv/Programs/rattler-build/output/bld/rattler-build_git_source_1704379826 channels: - https://conda.anaconda.org/conda-forge + channel_priority: strict + solve_strategy: highest timestamp: 2024-01-04T14:50:26.411202Z subpackages: git_source: diff --git a/test-data/rendered_recipes/rich_recipe.yaml b/test-data/rendered_recipes/rich_recipe.yaml index ffafd44c4..6027270de 100644 --- a/test-data/rendered_recipes/rich_recipe.yaml +++ b/test-data/rendered_recipes/rich_recipe.yaml @@ -62,6 +62,8 @@ build_configuration: build_dir: /Users/wolfv/Programs/rattler-build/output/bld/rattler-build_rich_1702492812 channels: - https://conda.anaconda.org/conda-forge + channel_priority: strict + solve_strategy: highest timestamp: 2023-12-13T18:40:12.845800Z subpackages: rich: