summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/external.py22
-rw-r--r--lib/spack/spack/test/cmd/external.py4
2 files changed, 22 insertions, 4 deletions
diff --git a/lib/spack/spack/cmd/external.py b/lib/spack/spack/cmd/external.py
index 8a8dec9025..7e73572028 100644
--- a/lib/spack/spack/cmd/external.py
+++ b/lib/spack/spack/cmd/external.py
@@ -39,8 +39,17 @@ def setup_parser(subparser):
'--scope', choices=scopes, metavar=scopes_metavar,
default=spack.config.default_modify_scope('packages'),
help="configuration scope to modify")
+ find_parser.add_argument(
+ '--all', action='store_true',
+ help="search for all packages that Spack knows about"
+ )
spack.cmd.common.arguments.add_common_arguments(find_parser, ['tags'])
find_parser.add_argument('packages', nargs=argparse.REMAINDER)
+ find_parser.epilog = (
+ 'The search is by default on packages tagged with the "build-tools" or '
+ '"core-packages" tags. Use the --all option to search for every possible '
+ 'package Spack knows how to find.'
+ )
sp.add_parser(
'list', help='list detectable packages, by repository and name'
@@ -48,6 +57,14 @@ def setup_parser(subparser):
def external_find(args):
+ # If the user didn't specify anything, search for build tools by default
+ if not args.tags and not args.all and not args.packages:
+ args.tags = ['core-packages', 'build-tools']
+
+ # If the user specified both --all and --tag, then --all has precedence
+ if args.all and args.tags:
+ args.tags = []
+
# Construct the list of possible packages to be detected
packages_to_check = []
@@ -64,9 +81,10 @@ def external_find(args):
# Since tags are cached it's much faster to construct what we need
# to search directly, rather than filtering after the fact
packages_to_check = [
- spack.repo.get(pkg) for pkg in
- spack.repo.path.packages_with_tags(*args.tags)
+ spack.repo.get(pkg) for tag in args.tags for pkg in
+ spack.repo.path.packages_with_tags(tag)
]
+ packages_to_check = list(set(packages_to_check))
# If the list of packages is empty, search for every possible package
if not args.tags and not packages_to_check:
diff --git a/lib/spack/spack/test/cmd/external.py b/lib/spack/spack/test/cmd/external.py
index d8928798ab..f1bcad0c89 100644
--- a/lib/spack/spack/test/cmd/external.py
+++ b/lib/spack/spack/test/cmd/external.py
@@ -124,7 +124,7 @@ def test_find_external_cmd_not_buildable(
def test_find_external_cmd_full_repo(
mutable_config, working_env, mock_executable, mutable_mock_repo):
- """Test invoking 'spack external find' with no additional arguments, which
+ """Test invoking 'spack external find --all' with no additional arguments
iterates through each package in the repository.
"""
@@ -134,7 +134,7 @@ def test_find_external_cmd_full_repo(
prefix = os.path.dirname(os.path.dirname(exe_path1))
os.environ['PATH'] = ':'.join([os.path.dirname(exe_path1)])
- external('find')
+ external('find', '--all')
pkgs_cfg = spack.config.get('packages')
pkg_cfg = pkgs_cfg['find-externals1']