Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add channel priority and solve strategy #888

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
3 changes: 3 additions & 0 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
},
)
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 8 additions & 4 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -219,6 +220,10 @@ pub struct BuildConfiguration {
pub directories: Directories,
/// The channels to use when resolving environments
pub channels: Vec<Url>,
/// 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<chrono::Utc>,
/// All subpackages coming from this output or other outputs from the same recipe
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down
15 changes: 14 additions & 1 deletion src/package_test/run_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -168,7 +169,7 @@ async fn legacy_tests_from_folder(pkg: &Path) -> Result<(PathBuf, Vec<Tests>), 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,
Expand All @@ -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<Url>,
/// 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,
}
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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)?;
Expand Down
4 changes: 4 additions & 0 deletions src/render/resolved_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down Expand Up @@ -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)?;
Expand Down
6 changes: 5 additions & 1 deletion src/render/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Vec<RepoDataRecord>> {
// 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.
Expand Down Expand Up @@ -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)
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: src/metadata.rs
assertion_line: 734
expression: output
---
recipe:
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: src/metadata.rs
assertion_line: 745
expression: git_source_output
---
recipe:
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: src/metadata.rs
assertion_line: 734
expression: output
---
recipe:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions test-data/rendered_recipes/curl_recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions test-data/rendered_recipes/git_source.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions test-data/rendered_recipes/rich_recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading