Fix a bug preventing to set platform= on externals (#43758)

closes #43406
This commit is contained in:
Massimiliano Culpo 2024-04-22 09:15:22 +02:00 committed by GitHub
parent 7c1a309453
commit a450dd31fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 7 deletions

View file

@ -1610,6 +1610,7 @@ def external_imposition(input_spec, requirements):
self.gen.newline() self.gen.newline()
self.trigger_rules() self.trigger_rules()
self.effect_rules()
def preferred_variants(self, pkg_name): def preferred_variants(self, pkg_name):
"""Facts on concretization preferences, as read from packages.yaml""" """Facts on concretization preferences, as read from packages.yaml"""

View file

@ -993,14 +993,13 @@ pkg_fact(Package, variant_single_value("dev_path"))
% Platform semantics % Platform semantics
%----------------------------------------------------------------------------- %-----------------------------------------------------------------------------
% if no platform is set, fall back to the default % NOTE: Currently we have a single allowed platform per DAG, therefore there is no
error(100, "platform '{0}' is not allowed on the current host", Platform) % need to have additional optimization criteria. If we ever add cross-platform dags,
:- attr("node_platform", _, Platform), not allowed_platform(Platform). % this needs to be changed.
:- 2 { allowed_platform(Platform) }, internal_error("More than one allowed platform detected").
attr("node_platform", PackageNode, Platform) 1 { attr("node_platform", PackageNode, Platform) : allowed_platform(Platform) } 1
:- attr("node", PackageNode), :- attr("node", PackageNode).
not attr("node_platform_set", PackageNode),
node_platform_default(Platform).
% setting platform on a node is a hard constraint % setting platform on a node is a hard constraint
attr("node_platform", PackageNode, Platform) attr("node_platform", PackageNode, Platform)

View file

@ -2398,6 +2398,19 @@ def test_reuse_specs_from_non_available_compilers(self, mutable_config, mutable_
for s in root.traverse(root=False): for s in root.traverse(root=False):
assert s.satisfies("%gcc@10.2.1") assert s.satisfies("%gcc@10.2.1")
@pytest.mark.regression("43406")
def test_externals_with_platform_explicitly_set(self, tmp_path):
"""Tests that users can specify platform=xxx in an external spec"""
external_conf = {
"mpich": {
"buildable": False,
"externals": [{"spec": "mpich@=2.0.0 platform=test", "prefix": str(tmp_path)}],
}
}
spack.config.set("packages", external_conf)
s = Spec("mpich").concretized()
assert s.external
@pytest.fixture() @pytest.fixture()
def duplicates_test_repository(): def duplicates_test_repository():