move set logic to PackageBase initializer (otherwise, users could instantiate package_class() in other locations and bypass the config)
This commit is contained in:
committed by
Gregory Becker
parent
0b24c820b4
commit
bb079ee356
@@ -694,6 +694,13 @@ 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("set", {})
|
||||
for key, val in settings.items():
|
||||
setattr(self, key, val)
|
||||
|
||||
@classmethod
|
||||
def possible_dependencies(
|
||||
cls,
|
||||
|
||||
@@ -1169,7 +1169,7 @@ def get(self, spec):
|
||||
|
||||
package_class = self.get_pkg_class(spec.name)
|
||||
try:
|
||||
package_instance = package_class(spec)
|
||||
return package_class(spec)
|
||||
except spack.error.SpackError:
|
||||
# pass these through as their error messages will be fine.
|
||||
raise
|
||||
@@ -1182,15 +1182,6 @@ def get(self, spec):
|
||||
sys.excepthook(*sys.exc_info())
|
||||
raise FailedConstructorError(spec.fullname, *sys.exc_info())
|
||||
|
||||
# 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("set", {})
|
||||
for key, val in settings.items():
|
||||
setattr(package_instance, key, val)
|
||||
|
||||
return package_instance
|
||||
|
||||
@autospec
|
||||
def dump_provenance(self, spec, path):
|
||||
"""Dump provenance information for a spec to a particular path.
|
||||
|
||||
Reference in New Issue
Block a user