From 59fd5a2f1abe72fd084121d650fb10bcca862c0a Mon Sep 17 00:00:00 2001 From: Bas Zalmstra Date: Tue, 5 Dec 2023 17:31:51 +0100 Subject: [PATCH] refactor: move run_exports to requiremens --- examples/mamba/recipe.yaml | 23 +- src/recipe/custom_yaml.rs | 12 +- src/recipe/parser.rs | 4 +- src/recipe/parser/build.rs | 103 +------ src/recipe/parser/requirements.rs | 254 +++++++++++++++++- ..._requirements__test__compiler_serde-2.snap | 3 - ...r__requirements__test__compiler_serde.snap | 3 - ...uild__recipe__parser__tests__it_works.snap | 9 - ...recipe__parser__tests__jinja_sequence.snap | 14 +- ...recipe__parser__tests__recipe_windows.snap | 20 +- src/render/resolved_dependencies.rs | 15 +- ..._build__render__recipe__tests__render.snap | 4 - ...d__metadata__test__read_full_recipe-2.snap | 11 - ...ild__metadata__test__read_full_recipe.snap | 10 - ...en_selectors@selectors_flatten_2.yaml.snap | 13 +- src/variant_config.rs | 2 +- test-data/recipes/run_exports/recipe.yaml | 2 +- test-data/rendered_recipes/curl_recipe.yaml | 8 - test-data/rendered_recipes/rich_recipe.yaml | 8 - 19 files changed, 298 insertions(+), 220 deletions(-) diff --git a/examples/mamba/recipe.yaml b/examples/mamba/recipe.yaml index 1cb6489df..cbb25ccad 100644 --- a/examples/mamba/recipe.yaml +++ b/examples/mamba/recipe.yaml @@ -25,12 +25,6 @@ outputs: script: - ${{ "build_mamba.sh" if unix }} - ${{ "build_mamba.bat" if win }} - run_exports: - - ${{ pin_subpackage('libmamba', max_pin='x.x') }} - ignore_run_exports: - - spdlog - - python - # - ${{ "python" if win }} requirements: build: - ${{ compiler('cxx') }} @@ -54,6 +48,13 @@ outputs: - zstd run: - libsolv >=0.7.23 + run_exports: + - ${{ pin_subpackage('libmamba', max_pin='x.x') }} + ignore_run_exports: + by_name: + - spdlog + - python + # - ${{ "python" if win }} test: commands: - if: unix @@ -81,10 +82,6 @@ outputs: - ${{ "build_mamba.sh" if unix }} - ${{ "build_mamba.bat" if win }} string: py_sup${{ python | version_to_buildstring }}h${{ hash }}_${{ build_number }} - run_exports: - - ${{ pin_subpackage('libmambapy', max_pin='x.x') }} - ignore_run_exports: - - spdlog requirements: build: - ${{ compiler('cxx') }} @@ -112,7 +109,11 @@ outputs: run: - python - ${{ pin_subpackage('libmamba', exact=True) }} - + run_exports: + - ${{ pin_subpackage('libmambapy', max_pin='x.x') }} + ignore_run_exports: + by_name: + - spdlog test: imports: - libmambapy diff --git a/src/recipe/custom_yaml.rs b/src/recipe/custom_yaml.rs index 8f7e06cd6..958f7702d 100644 --- a/src/recipe/custom_yaml.rs +++ b/src/recipe/custom_yaml.rs @@ -3,7 +3,7 @@ use std::{collections::BTreeMap, fmt, hash::Hash, ops, path::PathBuf}; -use indexmap::IndexMap; +use indexmap::{IndexMap, IndexSet}; use marked_yaml::{types::MarkedScalarNode, Span}; use url::Url; @@ -1086,6 +1086,16 @@ where } } +impl TryConvertNode> for RenderedNode +where + RenderedNode: TryConvertNode, + RenderedScalarNode: TryConvertNode, +{ + fn try_convert(&self, name: &str) -> Result, PartialParsingError> { + TryConvertNode::>::try_convert(self, name).map(|v| v.into_iter().collect()) + } +} + impl TryConvertNode> for RenderedNode where RenderedNode: TryConvertNode, diff --git a/src/recipe/parser.rs b/src/recipe/parser.rs index 504d6d26f..9e5236902 100644 --- a/src/recipe/parser.rs +++ b/src/recipe/parser.rs @@ -26,10 +26,10 @@ mod test; pub use self::{ about::About, - build::{Build, RunExports, ScriptEnv}, + build::{Build, ScriptEnv}, output::find_outputs_from_src, package::{OutputPackage, Package}, - requirements::{Compiler, Dependency, PinSubpackage, Requirements}, + requirements::{Compiler, Dependency, PinSubpackage, Requirements, RunExports, IgnoreRunExports}, source::{Checksum, GitSource, GitUrl, PathSource, Source, UrlSource}, test::{PackageContent, Test}, }; diff --git a/src/recipe/parser/build.rs b/src/recipe/parser/build.rs index a8c3a237c..16526df48 100644 --- a/src/recipe/parser/build.rs +++ b/src/recipe/parser/build.rs @@ -1,14 +1,13 @@ use std::{collections::BTreeMap, str::FromStr}; -use rattler_conda_types::{package::EntryPoint, NoArchKind, NoArchType, PackageName}; +use rattler_conda_types::{package::EntryPoint, NoArchKind, NoArchType}; use serde::{Deserialize, Serialize}; use crate::{ _partialerror, recipe::{ custom_yaml::{ - HasSpan, RenderedMappingNode, RenderedNode, RenderedScalarNode, RenderedSequenceNode, - TryConvertNode, + HasSpan, RenderedMappingNode, RenderedNode, RenderedScalarNode, TryConvertNode, }, error::{ErrorKind, PartialParsingError}, }, @@ -32,12 +31,6 @@ pub struct Build { pub(super) script: Vec, /// Environment variables to pass through or set in the script pub(super) script_env: ScriptEnv, - /// A recipe can choose to ignore certain run exports of its dependencies - pub(super) ignore_run_exports: Vec, - /// A recipe can choose to ignore all run exports of coming from some packages - pub(super) ignore_run_exports_from: Vec, - /// The recipe can specify a list of run exports that it provides - pub(super) run_exports: RunExports, /// A noarch package runs on any platform. It can be either a python package or a generic package. pub(super) noarch: NoArchType, /// For a Python noarch package to have executables it is necessary to specify the python entry points. @@ -72,25 +65,6 @@ impl Build { &self.script_env } - /// Get run exports. - pub const fn run_exports(&self) -> &RunExports { - &self.run_exports - } - - /// Get the ignore run exports. - /// - /// A recipe can choose to ignore certain run exports of its dependencies - pub fn ignore_run_exports(&self) -> &[PackageName] { - self.ignore_run_exports.as_slice() - } - - /// Get the ignore run exports from. - /// - /// A recipe can choose to ignore all run exports of coming from some packages - pub fn ignore_run_exports_from(&self) -> &[PackageName] { - self.ignore_run_exports_from.as_slice() - } - /// Get the noarch type. pub const fn noarch(&self) -> &NoArchType { &self.noarch @@ -135,18 +109,9 @@ impl TryConvertNode for RenderedMappingNode { } "script" => build.script = value.try_convert(key_str)?, "script_env" => build.script_env = value.try_convert(key_str)?, - "ignore_run_exports" => { - build.ignore_run_exports = value.try_convert(key_str)?; - } - "ignore_run_exports_from" => { - build.ignore_run_exports_from = value.try_convert(key_str)?; - } "noarch" => { build.noarch = value.try_convert(key_str)?; } - "run_exports" => { - build.run_exports = value.try_convert(key_str)?; - } "entry_points" => { if let Some(NoArchKind::Generic) = build.noarch.kind() { return Err(_partialerror!( @@ -328,17 +293,6 @@ impl RunExports { } } -impl TryConvertNode for RenderedNode { - fn try_convert(&self, name: &str) -> Result { - match self { - RenderedNode::Scalar(s) => s.try_convert(name), - RenderedNode::Sequence(seq) => seq.try_convert(name), - RenderedNode::Mapping(map) => map.try_convert(name), - RenderedNode::Null(_) => Ok(RunExports::default()), - } - } -} - impl TryConvertNode for RenderedScalarNode { fn try_convert(&self, name: &str) -> Result { let mut run_exports = RunExports::default(); @@ -350,59 +304,6 @@ impl TryConvertNode for RenderedScalarNode { } } -impl TryConvertNode for RenderedSequenceNode { - fn try_convert(&self, name: &str) -> Result { - let mut run_exports = RunExports::default(); - - for node in self.iter() { - let deps = node.try_convert(name)?; - run_exports.weak = deps; - } - - Ok(run_exports) - } -} - -impl TryConvertNode for RenderedMappingNode { - fn try_convert(&self, name: &str) -> Result { - let mut run_exports = RunExports::default(); - - for (key, value) in self.iter() { - let key_str = key.as_str(); - match key_str { - "noarch" => { - run_exports.noarch = value.try_convert(key_str)?; - } - "strong" => { - let deps = value.try_convert(key_str)?; - run_exports.strong = deps; - } - "strong_constrains" => { - let deps = value.try_convert(key_str)?; - run_exports.strong_constrains = deps; - } - "weak" => { - let deps = value.try_convert(key_str)?; - run_exports.weak = deps; - } - "weak_constrains" => { - let deps = value.try_convert(key_str)?; - run_exports.weak_constrains = deps; - } - invalid => { - return Err(_partialerror!( - *key.span(), - ErrorKind::InvalidField(invalid.to_owned().into()), - help = format!("fields for {name} should be one of: `weak`, `strong`, `noarch`, `strong_constrains`, or `weak_constrains`") - )) - } - } - } - - Ok(run_exports) - } -} - impl TryConvertNode for RenderedNode { fn try_convert(&self, name: &str) -> Result { self.as_scalar() diff --git a/src/recipe/parser/requirements.rs b/src/recipe/parser/requirements.rs index 1a273bd7f..34bb284a0 100644 --- a/src/recipe/parser/requirements.rs +++ b/src/recipe/parser/requirements.rs @@ -1,10 +1,12 @@ //! Parsing for the requirements section of the recipe. +use indexmap::IndexSet; use std::{fmt, str::FromStr}; -use rattler_conda_types::MatchSpec; +use rattler_conda_types::{MatchSpec, PackageName}; use serde::{Deserialize, Serialize}; +use crate::recipe::custom_yaml::RenderedSequenceNode; use crate::{ _partialerror, recipe::{ @@ -24,7 +26,7 @@ pub struct Requirements { /// The environment will thus be resolved with the appropriate platform /// that is currently running (e.g. on linux-64 it will be resolved with linux-64). /// Typically things like compilers, build tools, etc. are installed here. - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub build: Vec, /// Requirements at _host_ time are requirements that the final executable is going /// to _link_ against. The environment will be resolved with the target_platform @@ -32,18 +34,26 @@ pub struct Requirements { /// host environment will be resolved with linux-aarch64). /// /// Typically things like libraries, headers, etc. are installed here. - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub host: Vec, /// Requirements at _run_ time are requirements that the final executable is going /// to _run_ against. The environment will be resolved with the target_platform /// at runtime. - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub run: Vec, /// Constrains are optional runtime requirements that are used to constrain the /// environment that is resolved. They are not installed by default, but when /// installed they will have to conform to the constrains specified here. - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub run_constrained: Vec, + + /// The recipe can specify a list of run exports that it provides. + #[serde(default, skip_serializing_if = "RunExports::is_empty")] + pub run_exports: RunExports, + + /// Ignore run-exports by name or from certain packages + #[serde(default, skip_serializing_if = "IgnoreRunExports::is_empty")] + pub ignore_run_exports: IgnoreRunExports, } impl Requirements { @@ -67,6 +77,16 @@ impl Requirements { self.run_constrained.as_slice() } + /// Get run exports. + pub const fn run_exports(&self) -> &RunExports { + &self.run_exports + } + + /// Get run exports that are ignored. + pub const fn ignore_run_exports(&self) -> &IgnoreRunExports { + &self.ignore_run_exports + } + /// Get all requirements at build time (combines build and host requirements) pub fn build_time(&self) -> impl Iterator { self.build.iter().chain(self.host.iter()) @@ -110,6 +130,8 @@ impl TryConvertNode for RenderedMappingNode { let mut host = Vec::new(); let mut run = Vec::new(); let mut run_constrained = Vec::new(); + let mut run_exports = RunExports::default(); + let mut ignore_run_exports = IgnoreRunExports::default(); for (key, value) in self.iter() { let key_str = key.as_str(); @@ -118,6 +140,12 @@ impl TryConvertNode for RenderedMappingNode { "host" => host = value.try_convert(key_str)?, "run" => run = value.try_convert(key_str)?, "run_constrained" => run_constrained = value.try_convert(key_str)?, + "run_exports" => { + run_exports = value.try_convert(key_str)?; + } + "ignore_run_exports" => { + ignore_run_exports = value.try_convert(key_str)?; + } invalid_key => { return Err(_partialerror!( *key.span(), @@ -132,6 +160,8 @@ impl TryConvertNode for RenderedMappingNode { host, run, run_constrained, + run_exports, + ignore_run_exports, }) } } @@ -344,6 +374,211 @@ impl TryConvertNode for RenderedScalarNode { }) } } +/// Run exports are applied to downstream packages that depend on this package. +#[derive(Debug, Default, Clone, Serialize, Deserialize)] +pub struct RunExports { + /// Noarch run exports are the only ones looked at when building noarch packages. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub noarch: Vec, + /// Strong run exports apply from the build and host env to the run env. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub strong: Vec, + /// Strong run constrains add run_constrains from the build and host env. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub strong_constrains: Vec, + /// Weak run exports apply from the host env to the run env. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub weak: Vec, + /// Weak run constrains add run_constrains from the host env. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub weak_constrains: Vec, +} + +impl RunExports { + /// Check if all fields are empty + pub fn is_empty(&self) -> bool { + self.noarch.is_empty() + && self.strong.is_empty() + && self.strong_constrains.is_empty() + && self.weak.is_empty() + && self.weak_constrains.is_empty() + } + + /// Get all run exports from all configurations + pub fn all(&self) -> impl Iterator { + self.noarch + .iter() + .chain(self.strong.iter()) + .chain(self.strong_constrains.iter()) + .chain(self.weak.iter()) + .chain(self.weak_constrains.iter()) + } + + /// Get the noarch run exports. + pub fn noarch(&self) -> &[Dependency] { + self.noarch.as_slice() + } + + /// Get the strong run exports. + pub fn strong(&self) -> &[Dependency] { + self.strong.as_slice() + } + + /// Get the strong run constrains. + pub fn strong_constrains(&self) -> &[Dependency] { + self.strong_constrains.as_slice() + } + + /// Get the weak run exports. + pub fn weak(&self) -> &[Dependency] { + self.weak.as_slice() + } + + /// Get the weak run constrains. + pub fn weak_constrains(&self) -> &[Dependency] { + self.weak_constrains.as_slice() + } +} + +impl TryConvertNode for RenderedNode { + fn try_convert(&self, name: &str) -> Result { + match self { + RenderedNode::Scalar(s) => s.try_convert(name), + RenderedNode::Sequence(seq) => seq.try_convert(name), + RenderedNode::Mapping(map) => map.try_convert(name), + RenderedNode::Null(_) => Ok(RunExports::default()), + } + } +} + +impl TryConvertNode for RenderedScalarNode { + fn try_convert(&self, name: &str) -> Result { + let mut run_exports = RunExports::default(); + + let dep = self.try_convert(name)?; + run_exports.weak.push(dep); + + Ok(run_exports) + } +} + +impl TryConvertNode for RenderedSequenceNode { + fn try_convert(&self, name: &str) -> Result { + let mut run_exports = RunExports::default(); + + for node in self.iter() { + let deps = node.try_convert(name)?; + run_exports.weak = deps; + } + + Ok(run_exports) + } +} + +impl TryConvertNode for RenderedMappingNode { + fn try_convert(&self, name: &str) -> Result { + let mut run_exports = RunExports::default(); + + for (key, value) in self.iter() { + let key_str = key.as_str(); + match key_str { + "noarch" => { + run_exports.noarch = value.try_convert(key_str)?; + } + "strong" => { + let deps = value.try_convert(key_str)?; + run_exports.strong = deps; + } + "strong_constrains" => { + let deps = value.try_convert(key_str)?; + run_exports.strong_constrains = deps; + } + "weak" => { + let deps = value.try_convert(key_str)?; + run_exports.weak = deps; + } + "weak_constrains" => { + let deps = value.try_convert(key_str)?; + run_exports.weak_constrains = deps; + } + invalid => { + return Err(_partialerror!( + *key.span(), + ErrorKind::InvalidField(invalid.to_owned().into()), + help = format!("fields for {name} should be one of: `weak`, `strong`, `noarch`, `strong_constrains`, or `weak_constrains`") + )); + } + } + } + + Ok(run_exports) + } +} + +/// Run exports to ignore +#[derive(Debug, Default, Clone, Serialize, Deserialize)] +pub struct IgnoreRunExports { + #[serde(default, skip_serializing_if = "IndexSet::is_empty")] + pub(super) by_name: IndexSet, + #[serde(default, skip_serializing_if = "IndexSet::is_empty")] + pub(super) from_package: IndexSet, +} + +impl IgnoreRunExports { + /// Returns the package names that should be ignored as run_exports. + pub fn by_name(&self) -> &IndexSet { + &self.by_name + } + + /// Returns the package names from who we should ignore any run_export requirement. + #[allow(clippy::wrong_self_convention)] + pub fn from_package(&self) -> &IndexSet { + &self.from_package + } + + /// Returns true if this instance is considered empty, e.g. no run_exports should be ignored at + /// all. + pub fn is_empty(&self) -> bool { + self.by_name.is_empty() && self.from_package.is_empty() + } +} + +impl TryConvertNode for RenderedNode { + fn try_convert(&self, name: &str) -> Result { + self.as_mapping() + .ok_or_else(|| _partialerror!(*self.span(), ErrorKind::ExpectedMapping)) + .and_then(|m| m.try_convert(name)) + } +} + +impl TryConvertNode for RenderedMappingNode { + fn try_convert(&self, name: &str) -> Result { + let mut ignore_run_exports = IgnoreRunExports::default(); + + for (key, value) in self.iter() { + let key_str = key.as_str(); + match key_str { + "by_name" => { + ignore_run_exports.by_name = value.try_convert(key_str)?; + } + "from_package" => { + ignore_run_exports.from_package = value.try_convert(key_str)?; + } + invalid => { + return Err(_partialerror!( + *key.span(), + ErrorKind::InvalidField(invalid.to_owned().into()), + help = format!( + "fields for {name} should be one of: `by_name`, or `from_package`" + ) + )); + } + } + } + + Ok(ignore_run_exports) + } +} #[cfg(test)] mod test { @@ -365,18 +600,13 @@ mod test { let requirements = Requirements { build: vec![Dependency::Compiler(compiler)], - host: vec![], - run: vec![], - run_constrained: vec![], + ..Default::default() }; insta::assert_yaml_snapshot!(requirements); let yaml = serde_yaml::to_string(&requirements).unwrap(); - assert_eq!( - yaml, - "build:\n- __COMPILER gcc\nhost: []\nrun: []\nrun_constrained: []\n" - ); + assert_eq!(yaml, "build:\n- __COMPILER gcc\n"); let deserialized: Requirements = serde_yaml::from_str(&yaml).unwrap(); insta::assert_yaml_snapshot!(deserialized); diff --git a/src/recipe/parser/snapshots/rattler_build__recipe__parser__requirements__test__compiler_serde-2.snap b/src/recipe/parser/snapshots/rattler_build__recipe__parser__requirements__test__compiler_serde-2.snap index a90dccaa0..780e4b561 100644 --- a/src/recipe/parser/snapshots/rattler_build__recipe__parser__requirements__test__compiler_serde-2.snap +++ b/src/recipe/parser/snapshots/rattler_build__recipe__parser__requirements__test__compiler_serde-2.snap @@ -4,7 +4,4 @@ expression: deserialized --- build: - __COMPILER gcc -host: [] -run: [] -run_constrained: [] diff --git a/src/recipe/parser/snapshots/rattler_build__recipe__parser__requirements__test__compiler_serde.snap b/src/recipe/parser/snapshots/rattler_build__recipe__parser__requirements__test__compiler_serde.snap index e227621f2..2a7ca2b07 100644 --- a/src/recipe/parser/snapshots/rattler_build__recipe__parser__requirements__test__compiler_serde.snap +++ b/src/recipe/parser/snapshots/rattler_build__recipe__parser__requirements__test__compiler_serde.snap @@ -4,7 +4,4 @@ expression: requirements --- build: - __COMPILER gcc -host: [] -run: [] -run_constrained: [] diff --git a/src/recipe/snapshots/rattler_build__recipe__parser__tests__it_works.snap b/src/recipe/snapshots/rattler_build__recipe__parser__tests__it_works.snap index 33d464125..d082b6902 100644 --- a/src/recipe/snapshots/rattler_build__recipe__parser__tests__it_works.snap +++ b/src/recipe/snapshots/rattler_build__recipe__parser__tests__it_works.snap @@ -83,15 +83,6 @@ Recipe { env: {}, secrets: [], }, - ignore_run_exports: [], - ignore_run_exports_from: [], - run_exports: RunExports { - noarch: [], - strong: [], - strong_constrains: [], - weak: [], - weak_constrains: [], - }, noarch: NoArchType( None, ), diff --git a/src/recipe/snapshots/rattler_build__recipe__parser__tests__jinja_sequence.snap b/src/recipe/snapshots/rattler_build__recipe__parser__tests__jinja_sequence.snap index 7f888811d..fa3644824 100644 --- a/src/recipe/snapshots/rattler_build__recipe__parser__tests__jinja_sequence.snap +++ b/src/recipe/snapshots/rattler_build__recipe__parser__tests__jinja_sequence.snap @@ -16,21 +16,9 @@ build: passthrough: [] env: {} secrets: [] - ignore_run_exports: [] - ignore_run_exports_from: [] - run_exports: - noarch: [] - strong: [] - strong_constrains: [] - weak: [] - weak_constrains: [] noarch: false entry_points: [] -requirements: - build: [] - host: [] - run: [] - run_constrained: [] +requirements: {} test: imports: [] commands: [] diff --git a/src/recipe/snapshots/rattler_build__recipe__parser__tests__recipe_windows.snap b/src/recipe/snapshots/rattler_build__recipe__parser__tests__recipe_windows.snap index 12db2abf5..45ffc1e70 100644 --- a/src/recipe/snapshots/rattler_build__recipe__parser__tests__recipe_windows.snap +++ b/src/recipe/snapshots/rattler_build__recipe__parser__tests__recipe_windows.snap @@ -83,15 +83,6 @@ Recipe { env: {}, secrets: [], }, - ignore_run_exports: [], - ignore_run_exports_from: [], - run_exports: RunExports { - noarch: [], - strong: [], - strong_constrains: [], - weak: [], - weak_constrains: [], - }, noarch: NoArchType( None, ), @@ -247,6 +238,17 @@ Recipe { }, ), ], + run_exports: RunExports { + noarch: [], + strong: [], + strong_constrains: [], + weak: [], + weak_constrains: [], + }, + ignore_run_exports: IgnoreRunExports { + by_name: {}, + from_package: {}, + }, }, test: Test { imports: [], diff --git a/src/render/resolved_dependencies.rs b/src/render/resolved_dependencies.rs index 707bc0c4b..21a34ad4c 100644 --- a/src/render/resolved_dependencies.rs +++ b/src/render/resolved_dependencies.rs @@ -461,12 +461,13 @@ pub async fn resolve_dependencies( .iter() .any(|m| Some(&rec.package_record.name) == m.name.as_ref()); - let ignore_run_exports_from = output.recipe.build().ignore_run_exports_from(); - if !ignore_run_exports_from.is_empty() { - res && !ignore_run_exports_from.contains(&rec.package_record.name) - } else { - res - } + let ignore_run_exports_from = output + .recipe + .requirements() + .ignore_run_exports() + .from_package(); + + res && !ignore_run_exports_from.contains(&rec.package_record.name) }) .map_err(ResolveError::CouldNotCollectRunExports)?; @@ -551,7 +552,7 @@ pub async fn resolve_dependencies( .collect::>()) }; - let run_exports = output.recipe.build().run_exports(); + let run_exports = output.recipe.requirements().run_exports(); let run_exports = if !run_exports.is_empty() { Some(RunExportsJson { diff --git a/src/render/snapshots/rattler_build__render__recipe__tests__render.snap b/src/render/snapshots/rattler_build__render__recipe__tests__render.snap index dd856dec3..04449871c 100644 --- a/src/render/snapshots/rattler_build__render__recipe__tests__render.snap +++ b/src/render/snapshots/rattler_build__render__recipe__tests__render.snap @@ -17,10 +17,6 @@ source: build: number: 0 string: h12341234_0 - script: ~ - ignore_run_exports: ~ - ignore_run_exports_from: ~ - run_exports: ~ noarch: false entry_points: [] requirements: diff --git a/src/snapshots/rattler_build__metadata__test__read_full_recipe-2.snap b/src/snapshots/rattler_build__metadata__test__read_full_recipe-2.snap index a27f9065d..23ccefc38 100644 --- a/src/snapshots/rattler_build__metadata__test__read_full_recipe-2.snap +++ b/src/snapshots/rattler_build__metadata__test__read_full_recipe-2.snap @@ -21,14 +21,6 @@ recipe: passthrough: [] env: {} secrets: [] - ignore_run_exports: [] - ignore_run_exports_from: [] - run_exports: - noarch: [] - strong: [] - strong_constrains: [] - weak: [] - weak_constrains: [] noarch: false entry_points: [] requirements: @@ -38,9 +30,6 @@ recipe: - perl - pkg-config - libtool - host: [] - run: [] - run_constrained: [] test: imports: [] commands: [] diff --git a/src/snapshots/rattler_build__metadata__test__read_full_recipe.snap b/src/snapshots/rattler_build__metadata__test__read_full_recipe.snap index d6ea023fd..10c25bf09 100644 --- a/src/snapshots/rattler_build__metadata__test__read_full_recipe.snap +++ b/src/snapshots/rattler_build__metadata__test__read_full_recipe.snap @@ -22,18 +22,9 @@ recipe: passthrough: [] env: {} secrets: [] - ignore_run_exports: [] - ignore_run_exports_from: [] - run_exports: - noarch: [] - strong: [] - strong_constrains: [] - weak: [] - weak_constrains: [] noarch: python entry_points: [] requirements: - build: [] host: - pip - poetry-core >=1.0.0 @@ -43,7 +34,6 @@ recipe: - "pygments >=2.13.0,<3.0.0" - python ==3.10 - "typing_extensions >=4.0.0,<5.0.0" - run_constrained: [] test: imports: - rich diff --git a/src/snapshots/rattler_build__selectors__tests__flatten_selectors@selectors_flatten_2.yaml.snap b/src/snapshots/rattler_build__selectors__tests__flatten_selectors@selectors_flatten_2.yaml.snap index ff1609b63..5e3393f26 100644 --- a/src/snapshots/rattler_build__selectors__tests__flatten_selectors@selectors_flatten_2.yaml.snap +++ b/src/snapshots/rattler_build__selectors__tests__flatten_selectors@selectors_flatten_2.yaml.snap @@ -12,12 +12,6 @@ source: sha256: 63fd8a1dbec811e63d4f9b5e27757af45d08a219d0900c7c7a19e0b177a576b8 build: number: 0 - ignore_run_exports: - - libcurl - - libarchive - - libgcc-ng - - libstdcxx-ng - - spdlog requirements: build: - "{{ compiler(\"c\") }}" @@ -42,6 +36,13 @@ requirements: - openssl-static - reproc-cpp-static - reproc-static + ignore_run_exports: + by_name: + - libcurl + - libarchive + - libgcc-ng + - libstdcxx-ng + - spdlog test: commands: - test -f $PREFIX/bin/micromamba diff --git a/src/variant_config.rs b/src/variant_config.rs index 73b23989e..e3dcba2f3 100644 --- a/src/variant_config.rs +++ b/src/variant_config.rs @@ -592,7 +592,7 @@ impl VariantConfig { .run .iter() .chain(requirements.run_constrained.iter()) - .chain(parsed_recipe.build().run_exports().all()) + .chain(requirements.run_exports().all()) .try_for_each(|dep| -> Result<(), VariantError> { if let Dependency::PinSubpackage(pin_sub) = dep { let pin = pin_sub.pin_value(); diff --git a/test-data/recipes/run_exports/recipe.yaml b/test-data/recipes/run_exports/recipe.yaml index 340d272c6..ed51c8f1e 100644 --- a/test-data/recipes/run_exports/recipe.yaml +++ b/test-data/recipes/run_exports/recipe.yaml @@ -2,6 +2,6 @@ package: name: run_exports_test version: "1.0.0" -build: +requirements: run_exports: - ${{ pin_subpackage("run_exports_test", exact=True) }} diff --git a/test-data/rendered_recipes/curl_recipe.yaml b/test-data/rendered_recipes/curl_recipe.yaml index 2df560b1a..d7d621d3a 100644 --- a/test-data/rendered_recipes/curl_recipe.yaml +++ b/test-data/rendered_recipes/curl_recipe.yaml @@ -17,14 +17,6 @@ recipe: passthrough: [] env: {} secrets: [] - ignore_run_exports: [] - ignore_run_exports_from: [] - run_exports: - noarch: [] - strong: [] - strong_constrains: [] - weak: [] - weak_constrains: [] noarch: false entry_points: [] requirements: diff --git a/test-data/rendered_recipes/rich_recipe.yaml b/test-data/rendered_recipes/rich_recipe.yaml index bdb8017d5..ab01fc06b 100644 --- a/test-data/rendered_recipes/rich_recipe.yaml +++ b/test-data/rendered_recipes/rich_recipe.yaml @@ -18,14 +18,6 @@ recipe: passthrough: [] env: {} secrets: [] - ignore_run_exports: [] - ignore_run_exports_from: [] - run_exports: - noarch: [] - strong: [] - strong_constrains: [] - weak: [] - weak_constrains: [] noarch: python entry_points: [] requirements: