extensions: support acting on a view
This allows extensions to be (de)activated and queried within a view rather than only acting on the global installation.
This commit is contained in:
parent
db529f5b61
commit
b7ec870c3b
@ -26,6 +26,7 @@
|
|||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
import spack
|
import spack
|
||||||
import spack.cmd
|
import spack.cmd
|
||||||
|
from spack.directory_layout import YamlViewExtensionsLayout
|
||||||
|
|
||||||
description = "activate a package extension"
|
description = "activate a package extension"
|
||||||
section = "extensions"
|
section = "extensions"
|
||||||
@ -36,6 +37,9 @@ def setup_parser(subparser):
|
|||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'-f', '--force', action='store_true',
|
'-f', '--force', action='store_true',
|
||||||
help="activate without first activating dependencies")
|
help="activate without first activating dependencies")
|
||||||
|
subparser.add_argument(
|
||||||
|
'-v', '--view', metavar='VIEW', type=str,
|
||||||
|
help="the view to operate on")
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'spec', nargs=argparse.REMAINDER,
|
'spec', nargs=argparse.REMAINDER,
|
||||||
help="spec of package extension to activate")
|
help="spec of package extension to activate")
|
||||||
@ -50,7 +54,11 @@ def activate(parser, args):
|
|||||||
if not spec.package.is_extension:
|
if not spec.package.is_extension:
|
||||||
tty.die("%s is not an extension." % spec.name)
|
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)
|
tty.die("Package %s is already activated." % specs[0].short_spec)
|
||||||
|
|
||||||
spec.package.do_activate()
|
spec.package.do_activate(extensions_layout=layout)
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
import spack
|
import spack
|
||||||
import spack.cmd
|
import spack.cmd
|
||||||
import spack.store
|
import spack.store
|
||||||
|
from spack.directory_layout import YamlViewExtensionsLayout
|
||||||
from spack.graph import topological_sort
|
from spack.graph import topological_sort
|
||||||
|
|
||||||
description = "deactivate a package extension"
|
description = "deactivate a package extension"
|
||||||
@ -39,6 +40,9 @@ def setup_parser(subparser):
|
|||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'-f', '--force', action='store_true',
|
'-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(
|
subparser.add_argument(
|
||||||
'-a', '--all', action='store_true',
|
'-a', '--all', action='store_true',
|
||||||
help="deactivate all extensions of an extendable package, or "
|
help="deactivate all extensions of an extendable package, or "
|
||||||
@ -56,18 +60,24 @@ def deactivate(parser, args):
|
|||||||
spec = spack.cmd.disambiguate_spec(specs[0])
|
spec = spack.cmd.disambiguate_spec(specs[0])
|
||||||
pkg = spec.package
|
pkg = spec.package
|
||||||
|
|
||||||
|
layout = spack.store.extensions
|
||||||
|
if args.view is not None:
|
||||||
|
layout = YamlViewExtensionsLayout(args.view, spack.store.layout)
|
||||||
|
|
||||||
if args.all:
|
if args.all:
|
||||||
if pkg.extendable:
|
if pkg.extendable:
|
||||||
tty.msg("Deactivating all extensions of %s" % pkg.spec.short_spec)
|
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:
|
for ext_pkg in ext_pkgs:
|
||||||
ext_pkg.spec.normalize()
|
ext_pkg.spec.normalize()
|
||||||
if ext_pkg.is_activated():
|
if ext_pkg.is_activated():
|
||||||
ext_pkg.do_deactivate(force=True)
|
ext_pkg.do_deactivate(force=True, extensions_layout=layout)
|
||||||
|
|
||||||
elif pkg.is_extension:
|
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.die("%s is not activated." % pkg.spec.short_spec)
|
||||||
|
|
||||||
tty.msg("Deactivating %s and all dependencies." %
|
tty.msg("Deactivating %s and all dependencies." %
|
||||||
@ -80,9 +90,11 @@ def deactivate(parser, args):
|
|||||||
espec = index[name]
|
espec = index[name]
|
||||||
epkg = espec.package
|
epkg = espec.package
|
||||||
if epkg.extends(pkg.extendee_spec):
|
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:
|
else:
|
||||||
tty.die(
|
tty.die(
|
||||||
@ -94,7 +106,8 @@ def deactivate(parser, args):
|
|||||||
tty.die("spack deactivate requires an extension.",
|
tty.die("spack deactivate requires an extension.",
|
||||||
"Did you mean 'spack deactivate --all'?")
|
"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)
|
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)
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
import spack.cmd
|
import spack.cmd
|
||||||
import spack.cmd.find
|
import spack.cmd.find
|
||||||
import spack.store
|
import spack.store
|
||||||
|
from spack.directory_layout import YamlViewExtensionsLayout
|
||||||
|
|
||||||
description = "list extensions for package"
|
description = "list extensions for package"
|
||||||
section = "extensions"
|
section = "extensions"
|
||||||
@ -48,6 +49,9 @@ def setup_parser(subparser):
|
|||||||
format_group.add_argument(
|
format_group.add_argument(
|
||||||
'-d', '--deps', action='store_const', dest='mode', const='deps',
|
'-d', '--deps', action='store_const', dest='mode', const='deps',
|
||||||
help='show full dependency DAG of extensions')
|
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(
|
subparser.add_argument(
|
||||||
'spec', nargs=argparse.REMAINDER,
|
'spec', nargs=argparse.REMAINDER,
|
||||||
@ -86,6 +90,10 @@ def extensions(parser, args):
|
|||||||
tty.msg("%d extensions:" % len(extensions))
|
tty.msg("%d extensions:" % len(extensions))
|
||||||
colify(ext.name for ext in 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.
|
# List specs of installed extensions.
|
||||||
#
|
#
|
||||||
@ -95,14 +103,13 @@ def extensions(parser, args):
|
|||||||
print
|
print
|
||||||
if not installed:
|
if not installed:
|
||||||
tty.msg("None installed.")
|
tty.msg("None installed.")
|
||||||
return
|
|
||||||
tty.msg("%d installed:" % len(installed))
|
tty.msg("%d installed:" % len(installed))
|
||||||
spack.cmd.find.display_specs(installed, mode=args.mode)
|
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
|
print
|
||||||
if not activated:
|
if not activated:
|
||||||
tty.msg("None activated.")
|
tty.msg("None activated.")
|
||||||
|
Loading…
Reference in New Issue
Block a user