diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/cmd/activate.py | 12 | ||||
-rw-r--r-- | lib/spack/spack/cmd/deactivate.py | 27 | ||||
-rw-r--r-- | lib/spack/spack/cmd/extensions.py | 13 |
3 files changed, 40 insertions, 12 deletions
diff --git a/lib/spack/spack/cmd/activate.py b/lib/spack/spack/cmd/activate.py index ae72ec7db2..5105cc8e46 100644 --- a/lib/spack/spack/cmd/activate.py +++ b/lib/spack/spack/cmd/activate.py @@ -26,6 +26,7 @@ import argparse import llnl.util.tty as tty import spack import spack.cmd +from spack.directory_layout import YamlViewExtensionsLayout description = "activate a package extension" section = "extensions" @@ -37,6 +38,9 @@ def setup_parser(subparser): '-f', '--force', action='store_true', help="activate without first activating dependencies") subparser.add_argument( + '-v', '--view', metavar='VIEW', type=str, + help="the view to operate on") + subparser.add_argument( 'spec', nargs=argparse.REMAINDER, help="spec of package extension to activate") @@ -50,7 +54,11 @@ def activate(parser, args): if not spec.package.is_extension: tty.die("%s is not an extension." % spec.name) - if spec.package.is_activated(): + layout = spack.store.extensions + if args.view is not None: + layout = YamlViewExtensionsLayout(args.view, spack.store.layout) + + if spec.package.is_activated(extensions_layout=layout): tty.die("Package %s is already activated." % specs[0].short_spec) - spec.package.do_activate() + spec.package.do_activate(extensions_layout=layout) diff --git a/lib/spack/spack/cmd/deactivate.py b/lib/spack/spack/cmd/deactivate.py index 0be4612ba2..e3397beae2 100644 --- a/lib/spack/spack/cmd/deactivate.py +++ b/lib/spack/spack/cmd/deactivate.py @@ -28,6 +28,7 @@ import llnl.util.tty as tty import spack import spack.cmd import spack.store +from spack.directory_layout import YamlViewExtensionsLayout from spack.graph import topological_sort description = "deactivate a package extension" @@ -40,6 +41,9 @@ def setup_parser(subparser): '-f', '--force', action='store_true', help="run deactivation even if spec is NOT currently activated") subparser.add_argument( + '-v', '--view', metavar='VIEW', type=str, + help="the view to operate on") + subparser.add_argument( '-a', '--all', action='store_true', help="deactivate all extensions of an extendable package, or " "deactivate an extension AND its dependencies") @@ -56,18 +60,24 @@ def deactivate(parser, args): spec = spack.cmd.disambiguate_spec(specs[0]) pkg = spec.package + layout = spack.store.extensions + if args.view is not None: + layout = YamlViewExtensionsLayout(args.view, spack.store.layout) + if args.all: if pkg.extendable: tty.msg("Deactivating all extensions of %s" % pkg.spec.short_spec) - ext_pkgs = spack.store.db.activated_extensions_for(spec) + ext_pkgs = spack.store.db.activated_extensions_for( + spec, extensions_layout=layout) for ext_pkg in ext_pkgs: ext_pkg.spec.normalize() if ext_pkg.is_activated(): - ext_pkg.do_deactivate(force=True) + ext_pkg.do_deactivate(force=True, extensions_layout=layout) elif pkg.is_extension: - if not args.force and not spec.package.is_activated(): + if not args.force and \ + not spec.package.is_activated(extensions_layout=layout): tty.die("%s is not activated." % pkg.spec.short_spec) tty.msg("Deactivating %s and all dependencies." % @@ -80,9 +90,11 @@ def deactivate(parser, args): espec = index[name] epkg = espec.package if epkg.extends(pkg.extendee_spec): - if epkg.is_activated() or args.force: + if epkg.is_activated(extensions_layout=layout) or \ + args.force: - epkg.do_deactivate(force=args.force) + epkg.do_deactivate( + force=args.force, extensions_layout=layout) else: tty.die( @@ -94,7 +106,8 @@ def deactivate(parser, args): tty.die("spack deactivate requires an extension.", "Did you mean 'spack deactivate --all'?") - if not args.force and not spec.package.is_activated(): + if not args.force and \ + not spec.package.is_activated(extensions_layout=layout): tty.die("Package %s is not activated." % specs[0].short_spec) - spec.package.do_deactivate(force=args.force) + spec.package.do_deactivate(force=args.force, extensions_layout=layout) diff --git a/lib/spack/spack/cmd/extensions.py b/lib/spack/spack/cmd/extensions.py index 9521974d1c..c3ec76a058 100644 --- a/lib/spack/spack/cmd/extensions.py +++ b/lib/spack/spack/cmd/extensions.py @@ -31,6 +31,7 @@ import spack import spack.cmd import spack.cmd.find import spack.store +from spack.directory_layout import YamlViewExtensionsLayout description = "list extensions for package" section = "extensions" @@ -48,6 +49,9 @@ def setup_parser(subparser): format_group.add_argument( '-d', '--deps', action='store_const', dest='mode', const='deps', help='show full dependency DAG of extensions') + subparser.add_argument( + '-v', '--view', metavar='VIEW', type=str, + help="the view to operate on") subparser.add_argument( 'spec', nargs=argparse.REMAINDER, @@ -86,6 +90,10 @@ def extensions(parser, args): tty.msg("%d extensions:" % len(extensions)) colify(ext.name for ext in extensions) + layout = spack.store.extensions + if args.view is not None: + layout = YamlViewExtensionsLayout(args.view, spack.store.layout) + # # List specs of installed extensions. # @@ -95,14 +103,13 @@ def extensions(parser, args): print if not installed: tty.msg("None installed.") - return tty.msg("%d installed:" % len(installed)) spack.cmd.find.display_specs(installed, mode=args.mode) # - # List specs of globally activated extensions. + # List specs of activated extensions. # - activated = spack.store.extensions.extension_map(spec) + activated = layout.extension_map(spec) print if not activated: tty.msg("None activated.") |