package preferences: allow specs to be configured buildable when their virtuals are not (#18269)
* respect spec buildable that overrides virtual buildable
This commit is contained in:
parent
22c2f3fe89
commit
f3db624b86
@ -195,23 +195,23 @@ def _package(maybe_abstract_spec):
|
|||||||
|
|
||||||
def is_spec_buildable(spec):
|
def is_spec_buildable(spec):
|
||||||
"""Return true if the spec is configured as buildable"""
|
"""Return true if the spec is configured as buildable"""
|
||||||
|
|
||||||
allpkgs = spack.config.get("packages")
|
allpkgs = spack.config.get("packages")
|
||||||
all_buildable = allpkgs.get("all", {}).get("buildable", True)
|
all_buildable = allpkgs.get("all", {}).get("buildable", True)
|
||||||
|
so_far = all_buildable # the default "so far"
|
||||||
|
|
||||||
def _package(s):
|
def _package(s):
|
||||||
pkg_cls = spack.repo.path.get_pkg_class(s.name)
|
pkg_cls = spack.repo.path.get_pkg_class(s.name)
|
||||||
return pkg_cls(s)
|
return pkg_cls(s)
|
||||||
|
|
||||||
# Get the list of names for which all_buildable is overridden
|
# check whether any providers for this package override the default
|
||||||
reverse = [
|
if any(
|
||||||
name
|
_package(spec).provides(name) and entry.get("buildable", so_far) != so_far
|
||||||
for name, entry in allpkgs.items()
|
for name, entry in allpkgs.items()
|
||||||
if entry.get("buildable", all_buildable) != all_buildable
|
):
|
||||||
]
|
so_far = not so_far
|
||||||
# Does this spec override all_buildable
|
|
||||||
spec_reversed = spec.name in reverse or any(_package(spec).provides(name) for name in reverse)
|
spec_buildable = allpkgs.get(spec.name, {}).get("buildable", so_far)
|
||||||
return not all_buildable if spec_reversed else all_buildable
|
return spec_buildable
|
||||||
|
|
||||||
|
|
||||||
def get_package_dir_permissions(spec):
|
def get_package_dir_permissions(spec):
|
||||||
|
@ -395,6 +395,23 @@ def test_buildable_false_all_true_virtual(self):
|
|||||||
spec = Spec("mpich")
|
spec = Spec("mpich")
|
||||||
assert spack.package_prefs.is_spec_buildable(spec)
|
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):
|
def test_config_permissions_from_all(self, configure_permissions):
|
||||||
# Although these aren't strictly about concretization, they are
|
# Although these aren't strictly about concretization, they are
|
||||||
# configured in the same file and therefore convenient to test here.
|
# configured in the same file and therefore convenient to test here.
|
||||||
|
Loading…
Reference in New Issue
Block a user