diff options
Diffstat (limited to 'lib/spack/spack/cmd/deactivate.py')
-rw-r--r-- | lib/spack/spack/cmd/deactivate.py | 27 |
1 files changed, 20 insertions, 7 deletions
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) |