diff --git a/conda_build/metadata.py b/conda_build/metadata.py index 37e94367d4..4681fd653c 100644 --- a/conda_build/metadata.py +++ b/conda_build/metadata.py @@ -2668,13 +2668,11 @@ def get_loop_vars(self): return variants.get_vars(_variants, loop_only=True) def get_used_loop_vars(self, force_top_level=False, force_global=False): - return { - var - for var in self.get_used_vars( - force_top_level=force_top_level, force_global=force_global - ) - if var in self.get_loop_vars() - } + loop_vars = self.get_loop_vars() + used_vars = self.get_used_vars( + force_top_level=force_top_level, force_global=force_global + ) + return set(loop_vars).intersection(used_vars) def get_rendered_recipe_text( self, permit_undefined_jinja=False, extract_pattern=None diff --git a/conda_build/variants.py b/conda_build/variants.py index 46862fdbe4..a47c573ef0 100644 --- a/conda_build/variants.py +++ b/conda_build/variants.py @@ -697,16 +697,18 @@ def get_package_variants(recipedir_or_metadata, config=None, variants=None): def get_vars(variants, loop_only=False): """For purposes of naming/identifying, provide a way of identifying which variables contribute to the matrix dimensionality""" - special_keys = {"pin_run_as_build", "zip_keys", "ignore_version"} - special_keys.update(set(ensure_list(variants[0].get("extend_keys")))) + first_variant, *other_variants = variants + special_keys = { + "pin_run_as_build", + "zip_keys", + "ignore_version", + *ensure_list(first_variant.get("extend_keys")), + } loop_vars = [ k - for k in variants[0] + for k, v in first_variant.items() if k not in special_keys - and ( - not loop_only - or any(variant[k] != variants[0][k] for variant in variants[1:]) - ) + and (not loop_only or any(variant[k] != v for variant in other_variants)) ] return loop_vars