summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/database.py4
-rw-r--r--lib/spack/spack/directory_layout.py4
-rw-r--r--lib/spack/spack/modules.py4
-rw-r--r--lib/spack/spack/packages.py15
-rw-r--r--lib/spack/spack/spec.py32
-rw-r--r--lib/spack/spack/test/spec_dag.py8
6 files changed, 46 insertions, 21 deletions
diff --git a/lib/spack/spack/database.py b/lib/spack/spack/database.py
index d62a47547d..bf54055a24 100644
--- a/lib/spack/spack/database.py
+++ b/lib/spack/spack/database.py
@@ -211,6 +211,10 @@ class Database(object):
child = self._read_spec_from_yaml(dep_hash, installs, hash_key)
spec._add_dependency(child)
+ # Specs from the database need to be marked concrete because
+ # they represent actual installations.
+ spec._mark_concrete()
+
return spec
diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py
index 056606b429..d91fbe9f4e 100644
--- a/lib/spack/spack/directory_layout.py
+++ b/lib/spack/spack/directory_layout.py
@@ -212,8 +212,8 @@ class YamlDirectoryLayout(DirectoryLayout):
spec = Spec.from_yaml(f)
# Specs read from actual installations are always concrete
- spec._normal = True
- spec._concrete = True
+ spec._mark_concrete()
+
return spec
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
index 59ed9f893e..7036626e29 100644
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -29,11 +29,11 @@ The various types of modules are installed by post-install hooks and
removed after an uninstall by post-uninstall hooks. This class
consolidates the logic for creating an abstract description of the
information that module systems need. Currently that includes a
-number directories to be appended to paths in the user's environment:
+number of directories to be appended to paths in the user's environment:
* /bin directories to be appended to PATH
* /lib* directories for LD_LIBRARY_PATH
- * /man* and /share/man* directories for LD_LIBRARY_PATH
+ * /man* and /share/man* directories for MANPATH
* the package prefix for CMAKE_PREFIX_PATH
This module also includes logic for coming up with unique names for
diff --git a/lib/spack/spack/packages.py b/lib/spack/spack/packages.py
index f6f4cbf025..080644fb90 100644
--- a/lib/spack/spack/packages.py
+++ b/lib/spack/spack/packages.py
@@ -67,27 +67,28 @@ class PackageDB(object):
if spec.virtual:
raise UnknownPackageError(spec.name)
+ key = hash(spec)
if kwargs.get('new', False):
- if spec in self.instances:
- del self.instances[spec]
+ if key in self.instances:
+ del self.instances[key]
- if not spec in self.instances:
+ if not key in self.instances:
package_class = self.get_class_for_package_name(spec.name)
try:
- copy = spec.copy()
- self.instances[copy] = package_class(copy)
+ copy = spec.copy() # defensive copy. Package owns its spec.
+ self.instances[key] = package_class(copy)
except Exception, e:
if spack.debug:
sys.excepthook(*sys.exc_info())
raise FailedConstructorError(spec.name, e)
- return self.instances[spec]
+ return self.instances[key]
@_autospec
def delete(self, spec):
"""Force a package to be recreated."""
- del self.instances[spec]
+ del self.instances[spec.dag_hash()]
def purge(self):
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index f62182ce76..037ec97a5e 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -833,7 +833,18 @@ class Spec(object):
changed = any(changes)
force=True
- self._concrete = True
+ self._mark_concrete()
+
+
+ def _mark_concrete(self):
+ """Mark this spec and its dependencies as concrete.
+
+ Only for internal use -- client code should use "concretize"
+ unless there is a need to force a spec to be concrete.
+ """
+ for s in self.traverse():
+ s._normal = True
+ s._concrete = True
def concretized(self):
@@ -1481,8 +1492,11 @@ class Spec(object):
def _cmp_node(self):
"""Comparison key for just *this node* and not its deps."""
- return (self.name, self.versions, self.variants,
- self.architecture, self.compiler)
+ return (self.name,
+ self.versions,
+ self.variants,
+ self.architecture,
+ self.compiler)
def eq_node(self, other):
@@ -1496,11 +1510,15 @@ class Spec(object):
def _cmp_key(self):
- """Comparison key for this node and all dependencies *without*
- considering structure. This is the default, as
- normalization will restore structure.
+ """This returns a key for the spec *including* DAG structure.
+
+ The key is the concatenation of:
+ 1. A tuple describing this node in the DAG.
+ 2. The hash of each of this node's dependencies' cmp_keys.
"""
- return self._cmp_node() + (self.sorted_deps(),)
+ return self._cmp_node() + (
+ tuple(hash(self.dependencies[name])
+ for name in sorted(self.dependencies)),)
def colorized(self):
diff --git a/lib/spack/spack/test/spec_dag.py b/lib/spack/spack/test/spec_dag.py
index 94438b6a0c..d3a4d77b32 100644
--- a/lib/spack/spack/test/spec_dag.py
+++ b/lib/spack/spack/test/spec_dag.py
@@ -340,16 +340,18 @@ class SpecDagTest(MockPackagesTest):
self.assertEqual(spec, expected_flat)
self.assertTrue(spec.eq_dag(expected_flat))
- self.assertEqual(spec, expected_normalized)
+ # Normalized has different DAG structure, so NOT equal.
+ self.assertNotEqual(spec, expected_normalized)
self.assertFalse(spec.eq_dag(expected_normalized))
- self.assertEqual(spec, non_unique_nodes)
+ # Again, different DAG structure so not equal.
+ self.assertNotEqual(spec, non_unique_nodes)
self.assertFalse(spec.eq_dag(non_unique_nodes))
spec.normalize()
# After normalizing, spec_dag_equal should match the normalized spec.
- self.assertEqual(spec, expected_flat)
+ self.assertNotEqual(spec, expected_flat)
self.assertFalse(spec.eq_dag(expected_flat))
self.assertEqual(spec, expected_normalized)