diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 3ffedbbad9697bf4d0e1298cacf4c09f76d9f251..882901d887676c17d71bb6a76c6479ea46474897 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -329,6 +329,12 @@ class SomePackage(Package): """ sanity_check_is_dir = [] + class __metaclass__(type): + """Ensure attributes required by Spack directives are present.""" + def __init__(cls, name, bases, dict): + type.__init__(cls, name, bases, dict) + spack.directives.ensure_dicts(cls) + def __init__(self, spec): # this determines how the package should be built. self.spec = spec @@ -342,9 +348,6 @@ def __init__(self, spec): # Allow custom staging paths for packages self.path = None - # Sanity check attributes required by Spack directives. - spack.directives.ensure_dicts(type(self)) - # Check versions in the versions dict. for v in self.versions: assert (isinstance(v, Version))