summaryrefslogtreecommitdiff
path: root/lib/spack/spack/cmd/load.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/spack/cmd/load.py')
-rw-r--r--lib/spack/spack/cmd/load.py78
1 files changed, 48 insertions, 30 deletions
diff --git a/lib/spack/spack/cmd/load.py b/lib/spack/spack/cmd/load.py
index 64ae08930c..11ec2c5e25 100644
--- a/lib/spack/spack/cmd/load.py
+++ b/lib/spack/spack/cmd/load.py
@@ -20,47 +20,63 @@ level = "short"
def setup_parser(subparser):
"""Parser is only constructed so that this prints a nice help
- message with -h. """
- arguments.add_common_arguments(subparser, ['constraint'])
+ message with -h."""
+ arguments.add_common_arguments(subparser, ["constraint"])
shells = subparser.add_mutually_exclusive_group()
shells.add_argument(
- '--sh', action='store_const', dest='shell', const='sh',
- help="print sh commands to load the package")
+ "--sh",
+ action="store_const",
+ dest="shell",
+ const="sh",
+ help="print sh commands to load the package",
+ )
shells.add_argument(
- '--csh', action='store_const', dest='shell', const='csh',
- help="print csh commands to load the package")
+ "--csh",
+ action="store_const",
+ dest="shell",
+ const="csh",
+ help="print csh commands to load the package",
+ )
shells.add_argument(
- '--fish', action='store_const', dest='shell', const='fish',
- help="print fish commands to load the package")
+ "--fish",
+ action="store_const",
+ dest="shell",
+ const="fish",
+ help="print fish commands to load the package",
+ )
shells.add_argument(
- '--bat', action='store_const', dest='shell', const='bat',
- help="print bat commands to load the package")
+ "--bat",
+ action="store_const",
+ dest="shell",
+ const="bat",
+ help="print bat commands to load the package",
+ )
subparser.add_argument(
- '--first',
- action='store_true',
+ "--first",
+ action="store_true",
default=False,
- dest='load_first',
- help="load the first match if multiple packages match the spec"
+ dest="load_first",
+ help="load the first match if multiple packages match the spec",
)
subparser.add_argument(
- '--only',
- default='package,dependencies',
- dest='things_to_load',
- choices=['package', 'dependencies'],
+ "--only",
+ default="package,dependencies",
+ dest="things_to_load",
+ choices=["package", "dependencies"],
help="""select whether to load the package and its dependencies
the default is to load the package and all dependencies
alternatively one can decide to load only the package or only
-the dependencies"""
+the dependencies""",
)
subparser.add_argument(
- '--list',
- action='store_true',
+ "--list",
+ action="store_true",
default=False,
- help="show loaded packages: same as `spack find --loaded`"
+ help="show loaded packages: same as `spack find --loaded`",
)
@@ -74,11 +90,13 @@ def load(parser, args):
spack.cmd.display_specs(results)
return
- specs = [spack.cmd.disambiguate_spec(spec, env, first=args.load_first)
- for spec in spack.cmd.parse_specs(args.constraint)]
+ specs = [
+ spack.cmd.disambiguate_spec(spec, env, first=args.load_first)
+ for spec in spack.cmd.parse_specs(args.constraint)
+ ]
if not args.shell:
- specs_str = ' '.join(args.constraint) or "SPECS"
+ specs_str = " ".join(args.constraint) or "SPECS"
spack.cmd.common.shell_init_instructions(
"spack load",
" eval `spack load {sh_arg} %s`" % specs_str,
@@ -86,11 +104,11 @@ def load(parser, args):
return 1
with spack.store.db.read_transaction():
- if 'dependencies' in args.things_to_load:
- include_roots = 'package' in args.things_to_load
- specs = [dep for spec in specs
- for dep in
- spec.traverse(root=include_roots, order='post')]
+ if "dependencies" in args.things_to_load:
+ include_roots = "package" in args.things_to_load
+ specs = [
+ dep for spec in specs for dep in spec.traverse(root=include_roots, order="post")
+ ]
env_mod = spack.util.environment.EnvironmentModifications()
for spec in specs: