summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/extensions.py39
-rw-r--r--lib/spack/spack/packages.py6
2 files changed, 36 insertions, 9 deletions
diff --git a/lib/spack/spack/cmd/extensions.py b/lib/spack/spack/cmd/extensions.py
index f28a388bf2..f6ccd7b515 100644
--- a/lib/spack/spack/cmd/extensions.py
+++ b/lib/spack/spack/cmd/extensions.py
@@ -54,9 +54,14 @@ def extensions(parser, args):
if not args.spec:
tty.die("extensions requires a package spec.")
+ # Checks
spec = spack.cmd.parse_specs(args.spec)
if len(spec) > 1:
tty.die("Can only list extensions for one package.")
+
+ if not spec[0].package.extendable:
+ tty.die("%s is not an extendable package." % spec[0].name)
+
spec = spack.cmd.disambiguate_spec(spec[0])
if not spec.package.extendable:
@@ -65,12 +70,28 @@ def extensions(parser, args):
if not args.mode:
args.mode = 'short'
- exts = spack.install_layout.get_extensions(spec)
- if not exts:
- tty.msg("%s has no activated extensions." % spec.cshort_spec)
- else:
- 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)
+ # List package names of extensions
+ extensions = spack.db.extensions_for(spec)
+ if not extensions:
+ tty.msg("%s has no extensions." % spec.cshort_spec)
+ return
+ tty.msg("%s extensions:" % spec.cshort_spec)
+ colify(ext.name for ext in extensions)
+
+ # List specs of installed extensions.
+ installed = [s.spec for s in spack.db.installed_extensions_for(spec)]
+ print
+ if not installed:
+ tty.msg("None activated.")
+ return
+ tty.msg("%d installed:" % len(installed))
+ spack.cmd.find.display_specs(installed, mode=args.mode)
+
+ # List specs of activated extensions.
+ activated = spack.install_layout.get_extensions(spec)
+ print
+ if not activated:
+ tty.msg("None activated.")
+ return
+ tty.msg("%d currently activated:" % len(exts))
+ spack.cmd.find.display_specs(installed, mode=args.mode)
diff --git a/lib/spack/spack/packages.py b/lib/spack/spack/packages.py
index b3049e812f..7ef8135c1a 100644
--- a/lib/spack/spack/packages.py
+++ b/lib/spack/spack/packages.py
@@ -117,6 +117,12 @@ class PackageDB(object):
return [p for p in self.all_packages() if p.extends(extendee_spec)]
+ @_autospec
+ def installed_extensions_for(self, extendee_spec):
+ return [s.package for s in self.installed_package_specs()
+ if s.package.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."""