summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2022-02-18 19:51:01 +0100
committerGitHub <noreply@github.com>2022-02-18 11:51:01 -0700
commit7fd94fc4bc1e8609cc44524dd1139e3d63bb571f (patch)
tree2dc901dc5abf5b286130645311bdc3dfdf86a052 /lib
parent2ed52d32c7d99a4106f7d8a3d2d519a4c57e162e (diff)
downloadspack-7fd94fc4bc1e8609cc44524dd1139e3d63bb571f.tar.gz
spack-7fd94fc4bc1e8609cc44524dd1139e3d63bb571f.tar.bz2
spack-7fd94fc4bc1e8609cc44524dd1139e3d63bb571f.tar.xz
spack-7fd94fc4bc1e8609cc44524dd1139e3d63bb571f.zip
spack external find: change default behavior (#29031)
See https://github.com/spack/spack/issues/25353#issuecomment-1041868116 This commit changes the default behavior of ``` $ spack external find ``` from searching all the possible packages Spack knows about to search only for the ones tagged as being a "build-tool". It also introduces a `--all` option to restore the old behavior.
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']