From af81387e6fc825b73adbe00c8f30b1a5b3100082 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Sat, 20 Jul 2024 10:37:40 -0500 Subject: [PATCH] on_package_attributes: pass checks to pkg in builder --- lib/spack/spack/package_base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/spack/spack/package_base.py b/lib/spack/spack/package_base.py index 6f2d4406bca..e356494064a 100644 --- a/lib/spack/spack/package_base.py +++ b/lib/spack/spack/package_base.py @@ -358,12 +358,14 @@ def on_package_attributes(**attr_dict): def _execute_under_condition(func): @functools.wraps(func) def _wrapper(instance, *args, **kwargs): + # Support both builders and packages + pkg = instance.pkg if isinstance(instance, spack.builder.Builder) else instance # If all the attributes have the value we require, then execute - has_all_attributes = all([hasattr(instance, key) for key in attr_dict]) + has_all_attributes = all([hasattr(pkg, key) for key in attr_dict]) if has_all_attributes: has_the_right_values = all( [ - getattr(instance, key) == value for key, value in attr_dict.items() + getattr(pkg, key) == value for key, value in attr_dict.items() ] # NOQA: ignore=E501 ) if has_the_right_values: