44from os .path import join
55from pathlib import Path
66
7+ from conda import CondaError
78from conda .base .context import context
9+ from rattler_build import RattlerBuildError
810from rattler_build .progress import RichProgressCallback
911from rattler_build .render import RenderConfig
10- from rattler_build .stage0 import Stage0Recipe
12+ from rattler_build .stage0 import MultiOutputRecipe , Stage0Recipe
1113from rattler_build .tool_config import PlatformConfig , ToolConfiguration
1214from rattler_build .variant_config import VariantConfig
1315
@@ -91,8 +93,6 @@ def check_arguments_rattler(
9193def process_recipes (
9294 recipes : list [str ],
9395 variant_config : VariantConfig ,
94- render_config : RenderConfig ,
95- tool_config : ToolConfiguration ,
9696 command : str ,
9797 output_dir : str ,
9898 channels : list [str ],
@@ -101,6 +101,15 @@ def process_recipes(
101101 package_format : str ,
102102 no_include_recipe : bool ,
103103 debug : bool ,
104+ target_platform : str ,
105+ build_platform : str ,
106+ host_platform : str ,
107+ experimental : bool ,
108+ extra_context : dict [str ],
109+ test_strategy : str ,
110+ skip_existing : bool ,
111+ noarch_build_platform : str ,
112+ channel_priority : str ,
104113) -> int :
105114 import yaml
106115
@@ -113,11 +122,37 @@ def process_recipes(
113122 # load the recipe file
114123 try :
115124 recipe = Stage0Recipe .from_file (Path (recipe_path ))
116- except Exception as e :
125+ except RattlerBuildError as e :
117126 raise CondaBuildUserError (
118127 f"Failed to process recipe { recipe_path } : { str (e )} "
119128 )
120129
130+ if isinstance (recipe , MultiOutputRecipe ):
131+ for idx , output in enumerate (recipe .outputs , 1 ):
132+ output_dict = output .to_dict ()
133+ if "staging" in output_dict :
134+ experimental = True
135+
136+ # common tool / platform / render configuration
137+ tool_config = ToolConfiguration (
138+ test_strategy = test_strategy ,
139+ skip_existing = skip_existing ,
140+ noarch_build_platform = noarch_build_platform ,
141+ channel_priority = channel_priority ,
142+ )
143+
144+ platform_config = PlatformConfig (
145+ target_platform = target_platform ,
146+ build_platform = build_platform ,
147+ host_platform = host_platform ,
148+ experimental = experimental ,
149+ )
150+
151+ render_config = RenderConfig (
152+ platform = platform_config ,
153+ extra_context = extra_context ,
154+ )
155+
121156 # render the recipe
122157 try :
123158 rendered = recipe .render (variant_config , render_config )
@@ -127,8 +162,9 @@ def process_recipes(
127162 )
128163
129164 if command == "render" :
130- data = rendered [0 ].recipe .to_dict ()
131- print (yaml .safe_dump (data , indent = 2 , sort_keys = False ))
165+ for item in rendered :
166+ data = item .recipe .to_dict ()
167+ print (yaml .safe_dump (data , indent = 2 , sort_keys = False ))
132168 succeeded .append (recipe_path_str )
133169 continue
134170
@@ -151,9 +187,8 @@ def process_recipes(
151187 no_include_recipe = no_include_recipe ,
152188 debug = debug ,
153189 )
154- except Exception as e :
155- print (f"Build failed for recipe { recipe_path } : { str (e )} " )
156- raise
190+ except RattlerBuildError as e :
191+ raise CondaError (f"Build failed for recipe { recipe_path } : { str (e )} " )
157192
158193 # if all variants built without raising, mark recipe as succeeded
159194 succeeded .append (recipe_path_str )
@@ -195,6 +230,7 @@ def run_rattler(command: str, parsed_args: argparse.Namespace, config: Config) -
195230 output_dir : str = config .croot
196231 no_include_recipe : bool = False
197232 no_build_id : bool = False
233+ experimental : bool = False
198234 package_format : str | None = None
199235 debug : bool = False
200236 channels : list [str ] = []
@@ -206,6 +242,7 @@ def run_rattler(command: str, parsed_args: argparse.Namespace, config: Config) -
206242 noarch_build_platform : str = config .variant .get (
207243 "noarch_build_platform" , config .subdir
208244 )
245+ variant_config : VariantConfig = VariantConfig ()
209246
210247 # TODO: investigate why is config.channel_urls
211248 # does not pick up condarc settings, need to use context.channels
@@ -293,36 +330,14 @@ def run_rattler(command: str, parsed_args: argparse.Namespace, config: Config) -
293330 join (recipe_dir , "recipe.yaml" ) for recipe_dir in parsed_args .recipe
294331 ]
295332
296- from ..variants import find_config_files
297-
298333 # configure variant
299- for variant in config_files :
300- variant_config = VariantConfig .from_file (variant )
301-
302- # common tool / platform / render configuration
303- tool_config = ToolConfiguration (
304- test_strategy = test_strategy ,
305- skip_existing = skip_existing ,
306- noarch_build_platform = noarch_build_platform ,
307- channel_priority = channel_priority ,
308- )
309-
310- platform_config = PlatformConfig (
311- target_platform = target_platform ,
312- build_platform = build_platform ,
313- host_platform = host_platform ,
314- )
315-
316- render_config = RenderConfig (
317- platform = platform_config ,
318- extra_context = extra_context ,
319- )
334+ if config_files :
335+ for variant in config_files :
336+ variant_config = VariantConfig .from_file (variant )
320337
321338 return process_recipes (
322339 recipes = recipes ,
323340 variant_config = variant_config ,
324- render_config = render_config ,
325- tool_config = tool_config ,
326341 command = command ,
327342 output_dir = output_dir ,
328343 channels = channels ,
@@ -331,4 +346,13 @@ def run_rattler(command: str, parsed_args: argparse.Namespace, config: Config) -
331346 package_format = package_format ,
332347 no_include_recipe = no_include_recipe ,
333348 debug = debug ,
349+ target_platform = target_platform ,
350+ build_platform = build_platform ,
351+ host_platform = host_platform ,
352+ experimental = experimental ,
353+ extra_context = extra_context ,
354+ test_strategy = test_strategy ,
355+ skip_existing = skip_existing ,
356+ noarch_build_platform = noarch_build_platform ,
357+ channel_priority = channel_priority ,
334358 )
0 commit comments