From 468c63127bb0ea953fefe545468517a41430c401 Mon Sep 17 00:00:00 2001 From: Min RK Date: Fri, 28 Jun 2024 21:07:18 +0200 Subject: [PATCH] try a simpler reduction just remove unused variants that add dimensionality, don't try to remove anything else --- conda_smithy/configure_feedstock.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index ae9808b16..329798a34 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -879,7 +879,7 @@ def migrate_combined_spec(combined_spec, forge_dir, config, forge_config): return combined_spec -def reduce_variants(recipe_path, config, variants): +def reduce_variants(recipe_path, config, input_variants): """Subset of render_recipe to compute reduced variant matrix large numbers of unused variants greatly increase render time @@ -892,7 +892,7 @@ def reduce_variants(recipe_path, config, variants): # from distribute_variants # explode variants dict to list of variants variants = initial_variants = conda_build.variants.get_package_variants( - metadata, variants=variants + metadata, variants=input_variants ) logger.debug(f"Starting with {len(initial_variants)} variants") if metadata.noarch or metadata.noarch_python: @@ -911,12 +911,20 @@ def reduce_variants(recipe_path, config, variants): metadata.config.variant = variants[0] metadata.config.variants = variants all_used = metadata.get_used_vars(force_global=True) - reduced_variants = metadata.get_reduced_variant_set(all_used) - logger.info(f"Rendering {len(reduced_variants)} variants") - # return reduced, exploded list of variant dict to input format - return conda_build.variants.list_of_dicts_to_dict_of_lists( - reduced_variants - ) + new_input_variants = input_variants.copy() + # trim unused dimensions + # these cost a lot in render_recipe! + for key, value in list(input_variants.items()): + if len(value) > 1 and key not in all_used | { + "zip_keys", + "pin_run_as_build", + "ignore_build_only_deps", + "extend_keys", + }: + logger.debug(f"Trimming unused dimension: {key}") + new_input_variants.pop(key) + _trim_unused_zip_keys(new_input_variants) + return new_input_variants def _conda_build_api_render_for_smithy( @@ -955,7 +963,7 @@ def _conda_build_api_render_for_smithy( # reduce unused variants first, they get very expensive in render_recipe if variants: variants = reduce_variants( - recipe_path, config=config, variants=variants + recipe_path, config=config, input_variants=variants ) metadata_tuples = render_recipe(