diff options
author | Greg Becker <becker33@llnl.gov> | 2022-11-06 16:45:38 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-06 16:45:38 -0800 |
commit | f3db624b86fc6b746a74dd7f042745e040312fed (patch) | |
tree | fc3c42c48652062d10927a079ed51a5b634e1c47 /lib | |
parent | 22c2f3fe896b4647016199d7e16df133cd43029b (diff) | |
download | spack-f3db624b86fc6b746a74dd7f042745e040312fed.tar.gz spack-f3db624b86fc6b746a74dd7f042745e040312fed.tar.bz2 spack-f3db624b86fc6b746a74dd7f042745e040312fed.tar.xz spack-f3db624b86fc6b746a74dd7f042745e040312fed.zip |
package preferences: allow specs to be configured buildable when their virtuals are not (#18269)
* respect spec buildable that overrides virtual buildable
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/package_prefs.py | 18 | ||||
-rw-r--r-- | lib/spack/spack/test/concretize_preferences.py | 17 |
2 files changed, 26 insertions, 9 deletions
diff --git a/lib/spack/spack/package_prefs.py b/lib/spack/spack/package_prefs.py index 975585ac95..48d1ca129d 100644 --- a/lib/spack/spack/package_prefs.py +++ b/lib/spack/spack/package_prefs.py @@ -195,23 +195,23 @@ def spec_externals(spec): def is_spec_buildable(spec): """Return true if the spec is configured as buildable""" - allpkgs = spack.config.get("packages") all_buildable = allpkgs.get("all", {}).get("buildable", True) + so_far = all_buildable # the default "so far" def _package(s): pkg_cls = spack.repo.path.get_pkg_class(s.name) return pkg_cls(s) - # Get the list of names for which all_buildable is overridden - reverse = [ - name + # check whether any providers for this package override the default + if any( + _package(spec).provides(name) and entry.get("buildable", so_far) != so_far for name, entry in allpkgs.items() - if entry.get("buildable", all_buildable) != all_buildable - ] - # Does this spec override all_buildable - spec_reversed = spec.name in reverse or any(_package(spec).provides(name) for name in reverse) - return not all_buildable if spec_reversed else all_buildable + ): + so_far = not so_far + + spec_buildable = allpkgs.get(spec.name, {}).get("buildable", so_far) + return spec_buildable def get_package_dir_permissions(spec): diff --git a/lib/spack/spack/test/concretize_preferences.py b/lib/spack/spack/test/concretize_preferences.py index eb5b073444..56bda697fc 100644 --- a/lib/spack/spack/test/concretize_preferences.py +++ b/lib/spack/spack/test/concretize_preferences.py @@ -395,6 +395,23 @@ mpi: spec = Spec("mpich") assert spack.package_prefs.is_spec_buildable(spec) + def test_buildable_false_virtual_true_pacakge(self): + conf = syaml.load_config( + """\ +mpi: + buildable: false +mpich: + buildable: true +""" + ) + spack.config.set("packages", conf, scope="concretize") + + spec = Spec("zmpi") + assert not spack.package_prefs.is_spec_buildable(spec) + + spec = Spec("mpich") + assert spack.package_prefs.is_spec_buildable(spec) + def test_config_permissions_from_all(self, configure_permissions): # Although these aren't strictly about concretization, they are # configured in the same file and therefore convenient to test here. |