From 07fa1cd5f8f225e0c1c988f8620b30b1ff799aba Mon Sep 17 00:00:00 2001
From: Todd Gamblin <tgamblin@llnl.gov>
Date: Fri, 2 Sep 2016 15:10:30 -0700
Subject: [PATCH] Attributes for directives need to be set at class
 construction time. (#1718)

- moved ensure_dicts() call from Package.__init__ to
  Package.__metaclass__.
---
 lib/spack/spack/package.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 3ffedbbad9..882901d887 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))
-- 
GitLab