Add extensions command.

This commit is contained in:
Todd Gamblin
2015-02-02 06:09:35 -08:00
parent 6b90017efa
commit 2d9190d264
8 changed files with 99 additions and 12 deletions

View File

@@ -27,7 +27,7 @@
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.

View File

@@ -26,6 +26,7 @@
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)

View File

@@ -269,8 +269,8 @@ def extension_file_path(self, spec):
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:

View File

@@ -522,6 +522,11 @@ def is_extension(self):
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:

View File

@@ -112,6 +112,11 @@ def providers_for(self, vpkg_spec):
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."""

View File

@@ -552,6 +552,13 @@ def short_spec(self):
return self.format('$_$@$%@$+$=$#')
@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))