diff options
Diffstat (limited to 'lib/spack/spack/cmd/deactivate.py')
-rw-r--r-- | lib/spack/spack/cmd/deactivate.py | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/lib/spack/spack/cmd/deactivate.py b/lib/spack/spack/cmd/deactivate.py index fedd078972..ae5241dfe8 100644 --- a/lib/spack/spack/cmd/deactivate.py +++ b/lib/spack/spack/cmd/deactivate.py @@ -1,13 +1,13 @@ ############################################################################## -# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC. +# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC. # Produced at the Lawrence Livermore National Laboratory. # # This file is part of Spack. # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. # LLNL-CODE-647188 # -# For details, see https://github.com/llnl/spack -# Please also see the LICENSE file for our notice and the LGPL. +# For details, see https://github.com/spack/spack +# Please also see the NOTICE and LICENSE files for our notice and the LGPL. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License (as @@ -28,22 +28,28 @@ 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." +description = "deactivate a package extension" +section = "extensions" +level = "long" def setup_parser(subparser): subparser.add_argument( '-f', '--force', action='store_true', - help="Run deactivation even if spec is NOT currently activated.") + 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.") + help="deactivate all extensions of an extendable package, or " + "deactivate an extension AND its dependencies") subparser.add_argument( 'spec', nargs=argparse.REMAINDER, - help="spec of package extension to deactivate.") + help="spec of package extension to deactivate") def deactivate(parser, args): @@ -54,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.installed_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.activated: - ext_pkg.do_deactivate(force=True) + if ext_pkg.is_activated(): + ext_pkg.do_deactivate(force=True, extensions_layout=layout) elif pkg.is_extension: - if not args.force and not spec.package.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." % @@ -78,9 +90,11 @@ def deactivate(parser, args): espec = index[name] epkg = espec.package if epkg.extends(pkg.extendee_spec): - if epkg.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( @@ -92,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.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) |