Compare commits
2 Commits
develop-20
...
ldlist
Author | SHA1 | Date | |
---|---|---|---|
![]() |
70708d7420 | ||
![]() |
b624c5b9a3 |
@@ -924,6 +924,9 @@ use ``spack find --loaded``.
|
|||||||
-- linux-debian7 / intel@15.0.0 ---------------------------------
|
-- linux-debian7 / intel@15.0.0 ---------------------------------
|
||||||
libelf@0.8.13
|
libelf@0.8.13
|
||||||
|
|
||||||
|
You can also use ``spack load --list`` to get the same output, but it
|
||||||
|
does not have the full set of query options that ``spack find`` offers.
|
||||||
|
|
||||||
We'll learn more about Spack's spec syntax in the next section.
|
We'll learn more about Spack's spec syntax in the next section.
|
||||||
|
|
||||||
|
|
||||||
|
@@ -204,6 +204,16 @@ def display_env(env, args, decorator):
|
|||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
def filter_loaded_specs(specs):
|
||||||
|
"""Filter a list of specs returning only those that are currently loaded."""
|
||||||
|
hashes = os.environ.get(uenv.spack_loaded_hashes_var, '').split(':')
|
||||||
|
return [x for x in specs if x.dag_hash() in hashes]
|
||||||
|
|
||||||
|
|
||||||
|
def print_how_many_pkgs(specs, pkg_type=""):
|
||||||
|
tty.msg("%s" % plural(len(specs), pkg_type + " package"))
|
||||||
|
|
||||||
|
|
||||||
def find(parser, args):
|
def find(parser, args):
|
||||||
if args.bootstrap:
|
if args.bootstrap:
|
||||||
bootstrap_store_path = spack.bootstrap.store_path()
|
bootstrap_store_path = spack.bootstrap.store_path()
|
||||||
@@ -241,8 +251,7 @@ def _find(parser, args):
|
|||||||
results = [x for x in results if x.name in packages_with_tags]
|
results = [x for x in results if x.name in packages_with_tags]
|
||||||
|
|
||||||
if args.loaded:
|
if args.loaded:
|
||||||
hashes = os.environ.get(uenv.spack_loaded_hashes_var, '').split(':')
|
results = filter_loaded_specs(results)
|
||||||
results = [x for x in results if x.dag_hash() in hashes]
|
|
||||||
|
|
||||||
# Display the result
|
# Display the result
|
||||||
if args.json:
|
if args.json:
|
||||||
@@ -251,7 +260,10 @@ def _find(parser, args):
|
|||||||
if not args.format:
|
if not args.format:
|
||||||
if env:
|
if env:
|
||||||
display_env(env, args, decorator)
|
display_env(env, args, decorator)
|
||||||
|
|
||||||
if sys.stdout.isatty() and args.groups:
|
if sys.stdout.isatty() and args.groups:
|
||||||
tty.msg("%s" % plural(len(results), 'installed package'))
|
pkg_type = "loaded" if args.loaded else "installed"
|
||||||
|
print_how_many_pkgs(results, pkg_type)
|
||||||
|
|
||||||
cmd.display_specs(
|
cmd.display_specs(
|
||||||
results, args, decorator=decorator, all_headers=True)
|
results, args, decorator=decorator, all_headers=True)
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import spack.cmd
|
import spack.cmd
|
||||||
import spack.cmd.common.arguments as arguments
|
import spack.cmd.common.arguments as arguments
|
||||||
|
import spack.cmd.find
|
||||||
import spack.environment as ev
|
import spack.environment as ev
|
||||||
import spack.store
|
import spack.store
|
||||||
import spack.user_environment as uenv
|
import spack.user_environment as uenv
|
||||||
@@ -20,8 +21,7 @@
|
|||||||
def setup_parser(subparser):
|
def setup_parser(subparser):
|
||||||
"""Parser is only constructed so that this prints a nice help
|
"""Parser is only constructed so that this prints a nice help
|
||||||
message with -h. """
|
message with -h. """
|
||||||
arguments.add_common_arguments(
|
arguments.add_common_arguments(subparser, ['constraint'])
|
||||||
subparser, ['installed_specs'])
|
|
||||||
|
|
||||||
shells = subparser.add_mutually_exclusive_group()
|
shells = subparser.add_mutually_exclusive_group()
|
||||||
shells.add_argument(
|
shells.add_argument(
|
||||||
@@ -53,14 +53,29 @@ def setup_parser(subparser):
|
|||||||
the dependencies"""
|
the dependencies"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
subparser.add_argument(
|
||||||
|
'--list',
|
||||||
|
action='store_true',
|
||||||
|
default=False,
|
||||||
|
help="show loaded packages: same as `spack find --loaded`"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def load(parser, args):
|
def load(parser, args):
|
||||||
env = ev.active_environment()
|
env = ev.active_environment()
|
||||||
|
|
||||||
|
if args.list:
|
||||||
|
results = spack.cmd.find.filter_loaded_specs(args.specs())
|
||||||
|
if sys.stdout.isatty():
|
||||||
|
spack.cmd.find.print_how_many_pkgs(results, "loaded")
|
||||||
|
spack.cmd.display_specs(results)
|
||||||
|
return
|
||||||
|
|
||||||
specs = [spack.cmd.disambiguate_spec(spec, env, first=args.load_first)
|
specs = [spack.cmd.disambiguate_spec(spec, env, first=args.load_first)
|
||||||
for spec in spack.cmd.parse_specs(args.specs)]
|
for spec in spack.cmd.parse_specs(args.constraint)]
|
||||||
|
|
||||||
if not args.shell:
|
if not args.shell:
|
||||||
specs_str = ' '.join(args.specs) or "SPECS"
|
specs_str = ' '.join(args.constraint) or "SPECS"
|
||||||
spack.cmd.common.shell_init_instructions(
|
spack.cmd.common.shell_init_instructions(
|
||||||
"spack load",
|
"spack load",
|
||||||
" eval `spack load {sh_arg} %s`" % specs_str,
|
" eval `spack load {sh_arg} %s`" % specs_str,
|
||||||
|
@@ -148,6 +148,7 @@ case unload:
|
|||||||
# argument and specs with "-h" in the name.
|
# argument and specs with "-h" in the name.
|
||||||
if ( " $_sp_spec" =~ "* --sh*" || \
|
if ( " $_sp_spec" =~ "* --sh*" || \
|
||||||
" $_sp_spec" =~ "* --csh*" || \
|
" $_sp_spec" =~ "* --csh*" || \
|
||||||
|
" $_sp_spec" =~ "* --list*" || \
|
||||||
" $_sp_spec" =~ "* -h*" || \
|
" $_sp_spec" =~ "* -h*" || \
|
||||||
" $_sp_spec" =~ "* --help*") then
|
" $_sp_spec" =~ "* --help*") then
|
||||||
# Args contain --sh, --csh, or -h/--help: just execute.
|
# Args contain --sh, --csh, or -h/--help: just execute.
|
||||||
|
@@ -106,6 +106,8 @@ contains "usage: spack module " spack -m module
|
|||||||
title 'Testing `spack load`'
|
title 'Testing `spack load`'
|
||||||
contains "export PATH=$(spack -m location -i b)/bin" spack -m load --only package --sh b
|
contains "export PATH=$(spack -m location -i b)/bin" spack -m load --only package --sh b
|
||||||
succeeds spack -m load b
|
succeeds spack -m load b
|
||||||
|
LIST_CONTENT=`spack -m load b; spack load --list`
|
||||||
|
contains "b@" echo $LIST_CONTENT
|
||||||
fails spack -m load -l
|
fails spack -m load -l
|
||||||
# test a variable MacOS clears and one it doesn't for recursive loads
|
# test a variable MacOS clears and one it doesn't for recursive loads
|
||||||
contains "export PATH=$(spack -m location -i a)/bin:$(spack -m location -i b)/bin" spack -m load --sh a
|
contains "export PATH=$(spack -m location -i a)/bin:$(spack -m location -i b)/bin" spack -m load --sh a
|
||||||
|
@@ -320,6 +320,11 @@ function check_env_activate_flags -d "check spack env subcommand flags for -h, -
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# looks for a single `--list`
|
||||||
|
if match_flag $_a "--list"
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
@@ -180,6 +180,7 @@ _spack_shell_wrapper() {
|
|||||||
if [ "${_a#* --sh}" != "$_a" ] || \
|
if [ "${_a#* --sh}" != "$_a" ] || \
|
||||||
[ "${_a#* --csh}" != "$_a" ] || \
|
[ "${_a#* --csh}" != "$_a" ] || \
|
||||||
[ "${_a#* -h}" != "$_a" ] || \
|
[ "${_a#* -h}" != "$_a" ] || \
|
||||||
|
[ "${_a#* --list}" != "$_a" ] || \
|
||||||
[ "${_a#* --help}" != "$_a" ];
|
[ "${_a#* --help}" != "$_a" ];
|
||||||
then
|
then
|
||||||
# Args contain --sh, --csh, or -h/--help: just execute.
|
# Args contain --sh, --csh, or -h/--help: just execute.
|
||||||
|
@@ -1215,7 +1215,7 @@ _spack_list() {
|
|||||||
_spack_load() {
|
_spack_load() {
|
||||||
if $list_options
|
if $list_options
|
||||||
then
|
then
|
||||||
SPACK_COMPREPLY="-h --help --sh --csh --fish --first --only"
|
SPACK_COMPREPLY="-h --help --sh --csh --fish --first --only --list"
|
||||||
else
|
else
|
||||||
_installed_packages
|
_installed_packages
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user