Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/spack/spack/solver/asp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,7 @@ def external_imposition(input_spec, requirements):
self.gen.newline()

self.trigger_rules()
self.effect_rules()

def preferred_variants(self, pkg_name):
"""Facts on concretization preferences, as read from packages.yaml"""
Expand Down
13 changes: 6 additions & 7 deletions lib/spack/spack/solver/concretize.lp
Original file line number Diff line number Diff line change
Expand Up @@ -993,14 +993,13 @@ pkg_fact(Package, variant_single_value("dev_path"))
% Platform semantics
%-----------------------------------------------------------------------------

% if no platform is set, fall back to the default
error(100, "platform '{0}' is not allowed on the current host", Platform)
:- attr("node_platform", _, Platform), not allowed_platform(Platform).
% NOTE: Currently we have a single allowed platform per DAG, therefore there is no
% need to have additional optimization criteria. If we ever add cross-platform dags,
% this needs to be changed.
:- 2 { allowed_platform(Platform) }, internal_error("More than one allowed platform detected").

attr("node_platform", PackageNode, Platform)
:- attr("node", PackageNode),
not attr("node_platform_set", PackageNode),
node_platform_default(Platform).
1 { attr("node_platform", PackageNode, Platform) : allowed_platform(Platform) } 1
:- attr("node", PackageNode).

% setting platform on a node is a hard constraint
attr("node_platform", PackageNode, Platform)
Expand Down
13 changes: 13 additions & 0 deletions lib/spack/spack/test/concretize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2398,6 +2398,19 @@ def test_reuse_specs_from_non_available_compilers(self, mutable_config, mutable_
for s in root.traverse(root=False):
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()
def duplicates_test_repository():
Expand Down