externals: allow package prefs to configure default not buildable (#16735)
Allows `all` to be configured non-buildable in packages.yaml. The following config would only allow zlib to be built by Spack, all other packages would have to be found as externals. ``` packages: all: buildable: False zlib: buildable: True ```
This commit is contained in:
parent
92989fbbfd
commit
cfb6f21236
2 changed files with 74 additions and 4 deletions
|
@ -190,11 +190,17 @@ def spec_externals(spec):
|
||||||
|
|
||||||
def is_spec_buildable(spec):
|
def is_spec_buildable(spec):
|
||||||
"""Return true if the spec pkgspec is configured as buildable"""
|
"""Return true if the spec pkgspec is configured as buildable"""
|
||||||
|
|
||||||
allpkgs = spack.config.get('packages')
|
allpkgs = spack.config.get('packages')
|
||||||
do_not_build = [name for name, entry in allpkgs.items()
|
all_buildable = allpkgs.get('all', {}).get('buildable', True)
|
||||||
if not entry.get('buildable', True)]
|
|
||||||
return not (spec.name in do_not_build or
|
# Get the list of names for which all_buildable is overridden
|
||||||
any(spec.package.provides(name) for name in do_not_build))
|
reverse = [name 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(spec.package.provides(name) for name in reverse))
|
||||||
|
return not all_buildable if spec_reversed else all_buildable
|
||||||
|
|
||||||
|
|
||||||
def get_package_dir_permissions(spec):
|
def get_package_dir_permissions(spec):
|
||||||
|
|
|
@ -239,6 +239,70 @@ def mock_module(cmd, module):
|
||||||
spec.concretize()
|
spec.concretize()
|
||||||
assert spec['mpich'].external_path == '/dummy/path'
|
assert spec['mpich'].external_path == '/dummy/path'
|
||||||
|
|
||||||
|
def test_buildable_false(self):
|
||||||
|
conf = syaml.load_config("""\
|
||||||
|
libelf:
|
||||||
|
buildable: false
|
||||||
|
""")
|
||||||
|
spack.config.set('packages', conf, scope='concretize')
|
||||||
|
spec = Spec('libelf')
|
||||||
|
assert not spack.package_prefs.is_spec_buildable(spec)
|
||||||
|
|
||||||
|
spec = Spec('mpich')
|
||||||
|
assert spack.package_prefs.is_spec_buildable(spec)
|
||||||
|
|
||||||
|
def test_buildable_false_virtual(self):
|
||||||
|
conf = syaml.load_config("""\
|
||||||
|
mpi:
|
||||||
|
buildable: false
|
||||||
|
""")
|
||||||
|
spack.config.set('packages', conf, scope='concretize')
|
||||||
|
spec = Spec('libelf')
|
||||||
|
assert spack.package_prefs.is_spec_buildable(spec)
|
||||||
|
|
||||||
|
spec = Spec('mpich')
|
||||||
|
assert not spack.package_prefs.is_spec_buildable(spec)
|
||||||
|
|
||||||
|
def test_buildable_false_all(self):
|
||||||
|
conf = syaml.load_config("""\
|
||||||
|
all:
|
||||||
|
buildable: false
|
||||||
|
""")
|
||||||
|
spack.config.set('packages', conf, scope='concretize')
|
||||||
|
spec = Spec('libelf')
|
||||||
|
assert not spack.package_prefs.is_spec_buildable(spec)
|
||||||
|
|
||||||
|
spec = Spec('mpich')
|
||||||
|
assert not spack.package_prefs.is_spec_buildable(spec)
|
||||||
|
|
||||||
|
def test_buildable_false_all_true_package(self):
|
||||||
|
conf = syaml.load_config("""\
|
||||||
|
all:
|
||||||
|
buildable: false
|
||||||
|
libelf:
|
||||||
|
buildable: true
|
||||||
|
""")
|
||||||
|
spack.config.set('packages', conf, scope='concretize')
|
||||||
|
spec = Spec('libelf')
|
||||||
|
assert spack.package_prefs.is_spec_buildable(spec)
|
||||||
|
|
||||||
|
spec = Spec('mpich')
|
||||||
|
assert not spack.package_prefs.is_spec_buildable(spec)
|
||||||
|
|
||||||
|
def test_buildable_false_all_true_virtual(self):
|
||||||
|
conf = syaml.load_config("""\
|
||||||
|
all:
|
||||||
|
buildable: false
|
||||||
|
mpi:
|
||||||
|
buildable: true
|
||||||
|
""")
|
||||||
|
spack.config.set('packages', conf, scope='concretize')
|
||||||
|
spec = Spec('libelf')
|
||||||
|
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 a new issue