Fix using sticky variants in externals (#42253)
This commit is contained in:
parent
cb4312996c
commit
9963e2a20c
3 changed files with 46 additions and 8 deletions
|
@ -1806,15 +1806,12 @@ def external_packages(self):
|
||||||
for local_idx, spec in enumerate(external_specs):
|
for local_idx, spec in enumerate(external_specs):
|
||||||
msg = "%s available as external when satisfying %s" % (spec.name, spec)
|
msg = "%s available as external when satisfying %s" % (spec.name, spec)
|
||||||
|
|
||||||
def external_imposition(input_spec, _):
|
def external_imposition(input_spec, requirements):
|
||||||
return [fn.attr("external_conditions_hold", input_spec.name, local_idx)]
|
return requirements + [
|
||||||
|
fn.attr("external_conditions_hold", input_spec.name, local_idx)
|
||||||
|
]
|
||||||
|
|
||||||
self.condition(
|
self.condition(spec, spec, msg=msg, transform_imposed=external_imposition)
|
||||||
spec,
|
|
||||||
spack.spec.Spec(spec.name),
|
|
||||||
msg=msg,
|
|
||||||
transform_imposed=external_imposition,
|
|
||||||
)
|
|
||||||
self.possible_versions[spec.name].add(spec.version)
|
self.possible_versions[spec.name].add(spec.version)
|
||||||
self.gen.newline()
|
self.gen.newline()
|
||||||
|
|
||||||
|
|
|
@ -1501,6 +1501,30 @@ def test_sticky_variant_in_package(self):
|
||||||
s = Spec("sticky-variant %clang").concretized()
|
s = Spec("sticky-variant %clang").concretized()
|
||||||
assert s.satisfies("%clang") and s.satisfies("~allow-gcc")
|
assert s.satisfies("%clang") and s.satisfies("~allow-gcc")
|
||||||
|
|
||||||
|
@pytest.mark.regression("42172")
|
||||||
|
@pytest.mark.only_clingo("Original concretizer cannot use sticky variants")
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"spec,allow_gcc",
|
||||||
|
[
|
||||||
|
("sticky-variant@1.0+allow-gcc", True),
|
||||||
|
("sticky-variant@1.0~allow-gcc", False),
|
||||||
|
("sticky-variant@1.0", False),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_sticky_variant_in_external(self, spec, allow_gcc):
|
||||||
|
# setup external for sticky-variant+allow-gcc
|
||||||
|
config = {"externals": [{"spec": spec, "prefix": "/fake/path"}], "buildable": False}
|
||||||
|
spack.config.set("packages:sticky-variant", config)
|
||||||
|
|
||||||
|
maybe = llnl.util.lang.nullcontext if allow_gcc else pytest.raises
|
||||||
|
with maybe(spack.error.SpackError):
|
||||||
|
s = Spec("sticky-variant-dependent%gcc").concretized()
|
||||||
|
|
||||||
|
if allow_gcc:
|
||||||
|
assert s.satisfies("%gcc")
|
||||||
|
assert s["sticky-variant"].satisfies("+allow-gcc")
|
||||||
|
assert s["sticky-variant"].external
|
||||||
|
|
||||||
@pytest.mark.only_clingo("Use case not supported by the original concretizer")
|
@pytest.mark.only_clingo("Use case not supported by the original concretizer")
|
||||||
def test_do_not_invent_new_concrete_versions_unless_necessary(self):
|
def test_do_not_invent_new_concrete_versions_unless_necessary(self):
|
||||||
# ensure we select a known satisfying version rather than creating
|
# ensure we select a known satisfying version rather than creating
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
|
||||||
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
from spack.package import *
|
||||||
|
|
||||||
|
|
||||||
|
class StickyVariantDependent(AutotoolsPackage):
|
||||||
|
"""Package with a sticky variant and a conflict"""
|
||||||
|
|
||||||
|
homepage = "http://www.example.com"
|
||||||
|
url = "http://www.example.com/a-1.0.tar.gz"
|
||||||
|
|
||||||
|
version("1.0", md5="0123456789abcdef0123456789abcdef")
|
||||||
|
|
||||||
|
depends_on("sticky-variant")
|
||||||
|
conflicts("%gcc", when="^sticky-variant~allow-gcc")
|
Loading…
Reference in a new issue