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:
		@@ -195,23 +195,23 @@ def _package(maybe_abstract_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):
 | 
			
		||||
 
 | 
			
		||||
@@ -395,6 +395,23 @@ def test_buildable_false_all_true_virtual(self):
 | 
			
		||||
        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.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user