summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-02-02 06:09:35 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2015-02-02 11:20:36 -0800
commit2d9190d264dd276853aca41998fffbab1baecdb0 (patch)
tree304c5b3eadc15363529e5a504025447daaddc405 /lib
parent6b90017efa1f3157fe4be7d0c7b199b6e51b9fa8 (diff)
downloadspack-2d9190d264dd276853aca41998fffbab1baecdb0.tar.gz
spack-2d9190d264dd276853aca41998fffbab1baecdb0.tar.bz2
spack-2d9190d264dd276853aca41998fffbab1baecdb0.tar.xz
spack-2d9190d264dd276853aca41998fffbab1baecdb0.zip
Add extensions command.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/llnl/util/link_tree.py5
-rw-r--r--lib/spack/spack/cmd/extensions.py9
-rw-r--r--lib/spack/spack/directory_layout.py2
-rw-r--r--lib/spack/spack/package.py5
-rw-r--r--lib/spack/spack/packages.py5
-rw-r--r--lib/spack/spack/spec.py7
6 files changed, 26 insertions, 7 deletions
diff --git a/lib/spack/llnl/util/link_tree.py b/lib/spack/llnl/util/link_tree.py
index 887f6f4d26..4e4e48316e 100644
--- a/lib/spack/llnl/util/link_tree.py
+++ b/lib/spack/llnl/util/link_tree.py
@@ -27,7 +27,7 @@ __all__ = ['LinkTree']
import os
import shutil
-from llnl.util.filesystem import mkdirp
+from llnl.util.filesystem import *
empty_file_name = '.spack-empty'
@@ -93,6 +93,7 @@ def traverse_tree(source_root, dest_root, rel_path='', **kwargs):
for f in os.listdir(source_path):
source_child = os.path.join(source_path, f)
dest_child = os.path.join(dest_path, f)
+ rel_child = os.path.join(rel_path, f)
# Treat as a directory
if os.path.isdir(source_child) and (
@@ -101,7 +102,7 @@ def traverse_tree(source_root, dest_root, rel_path='', **kwargs):
# When follow_nonexisting isn't set, don't descend into dirs
# in source that do not exist in dest
if follow_nonexisting or os.path.exists(dest_child):
- tuples = traverse_tree(source_child, dest_child, rel_path, **kwargs)
+ tuples = traverse_tree(source_root, dest_root, rel_child, **kwargs)
for t in tuples: yield t
# Treat as a file.
diff --git a/lib/spack/spack/cmd/extensions.py b/lib/spack/spack/cmd/extensions.py
index 961d7e3f24..f28a388bf2 100644
--- a/lib/spack/spack/cmd/extensions.py
+++ b/lib/spack/spack/cmd/extensions.py
@@ -26,6 +26,7 @@ import sys
from external import argparse
import llnl.util.tty as tty
+from llnl.util.tty.colify import colify
import spack
import spack.cmd
@@ -66,10 +67,10 @@ def extensions(parser, args):
exts = spack.install_layout.get_extensions(spec)
if not exts:
- tty.msg("%s has no activated extensions." % spec.short_spec)
+ tty.msg("%s has no activated extensions." % spec.cshort_spec)
else:
- tty.msg("Showing %d activated extension%s for package:"
- % (len(exts), 's' if len(exts) > 1 else ''),
- spec.short_spec)
+ tty.msg("Extensions for package %s:" % spec.cshort_spec)
+ colify(pkg.name for pkg in spack.db.extensions_for(spec))
print
+ tty.msg("%d currently activated:" % len(exts))
spack.cmd.find.display_specs(exts, mode=args.mode)
diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py
index ff327ed504..efc40a17a4 100644
--- a/lib/spack/spack/directory_layout.py
+++ b/lib/spack/spack/directory_layout.py
@@ -269,8 +269,8 @@ class SpecHashDirectoryLayout(DirectoryLayout):
def get_extensions(self, spec):
_check_concrete(spec)
- path = self.extension_file_path(spec)
extensions = set()
+ path = self.extension_file_path(spec)
if os.path.exists(path):
with closing(open(path)) as ext_file:
for line in ext_file:
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 0b6bc4ce6c..b905968540 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -522,6 +522,11 @@ class Package(object):
return len(self.extendees) > 0
+ def extends(self, spec):
+ return (spec.name in self.extendees and
+ spec.satisfies(self.extendees[spec.name][0]))
+
+
@property
def activated(self):
if not self.spec.concrete:
diff --git a/lib/spack/spack/packages.py b/lib/spack/spack/packages.py
index bb5a94bcab..b3049e812f 100644
--- a/lib/spack/spack/packages.py
+++ b/lib/spack/spack/packages.py
@@ -112,6 +112,11 @@ class PackageDB(object):
return providers
+ @_autospec
+ def extensions_for(self, extendee_spec):
+ return [p for p in self.all_packages() if p.extends(extendee_spec)]
+
+
def dirname_for_package_name(self, pkg_name):
"""Get the directory name for a particular package. This is the
directory that contains its package.py file."""
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 2f4fe9ca24..dffdccaddb 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -553,6 +553,13 @@ class Spec(object):
@property
+ def cshort_spec(self):
+ """Returns a version of the spec with the dependencies hashed
+ instead of completely enumerated."""
+ return self.format('$_$@$%@$+$=$#', color=True)
+
+
+ @property
def prefix(self):
return Prefix(spack.install_layout.path_for_spec(self))