diff --git a/lib/spack/spack/package_base.py b/lib/spack/spack/package_base.py index e0e250cf7c8..2e12eebc582 100644 --- a/lib/spack/spack/package_base.py +++ b/lib/spack/spack/package_base.py @@ -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, diff --git a/lib/spack/spack/repo.py b/lib/spack/spack/repo.py index 0b511dab47c..123f34320e2 100644 --- a/lib/spack/spack/repo.py +++ b/lib/spack/spack/repo.py @@ -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.