move setattr back to get_pkg_class (since these config settings can affect class-level attrs)

This commit is contained in:
Peter Josef Scheibel
2022-10-19 16:11:02 -06:00
committed by Gregory Becker
parent d68e1c976d
commit d38ad41b65
2 changed files with 10 additions and 9 deletions

View File

@@ -694,15 +694,6 @@ def __init__(self, spec):
super(PackageBase, self).__init__()
# packages.yaml config can override package attributes. This is set
# on the instance rather than the class since the configuration can
# change between calls to repo.get for the same package.
settings = spack.config.get("packages").get(spec.name, {}).get("package_attributes", {})
for key, val in settings.items():
setattr(self, key, val)
# Note: the potential issue with setting these attributes here vs.
# in Repo.get is that subclasses could override these properties
@classmethod
def possible_dependencies(
cls,

View File

@@ -1362,6 +1362,16 @@ def get_pkg_class(self, pkg_name):
if not inspect.isclass(cls):
tty.die("%s.%s is not a class" % (pkg_name, class_name))
new_cfg_settings = spack.config.get("packages").get(pkg_name, {}).get("package_attributes", {})
overidden_attrs = getattr(cls, 'overidden_attrs', {})
for key, val in overidden_attrs.items():
setattr(cls, key, val)
new_overidden_attrs = {}
for key, val in new_cfg_settings.items():
new_overidden_attrs[key] = getattr(cls, key)
setattr(cls, key, val)
setattr(cls, 'overidden_attrs', dict(new_overidden_attrs))
return cls
def __str__(self):