spec.py: remove VariantMap.concrete (#49170)

VariantMap.concrete is unused, and would be incorrect if it were used
due to conditional variants.

Just let the Spec dictate what is concrete and what is not.
This commit is contained in:
Harmen Stoppels 2025-02-25 10:18:06 +01:00 committed by GitHub
parent 3ad99d75f9
commit 4e311a22d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 0 additions and 27 deletions

View File

@ -4615,17 +4615,6 @@ def constrain(self, other: "VariantMap") -> bool:
return changed return changed
@property
def concrete(self):
"""Returns True if the spec is concrete in terms of variants.
Returns:
bool: True or False
"""
return self.spec._concrete or all(
v in self for v in spack.repo.PATH.get_pkg_class(self.spec.fullname).variant_names()
)
def copy(self) -> "VariantMap": def copy(self) -> "VariantMap":
clone = VariantMap(self.spec) clone = VariantMap(self.spec)
for name, variant in self.items(): for name, variant in self.items():

View File

@ -685,22 +685,6 @@ def test_str(self) -> None:
c["shared"] = BoolValuedVariant("shared", True) c["shared"] = BoolValuedVariant("shared", True)
assert str(c) == "+shared feebar=foo foo=bar,baz foobar=fee" assert str(c) == "+shared feebar=foo foo=bar,baz foobar=fee"
def test_concrete(self, mock_packages, config) -> None:
spec = Spec("pkg-a")
assert not VariantMap(spec).concrete
# concrete if associated spec is concrete
spec = spack.concretize.concretize_one(spec)
assert VariantMap(spec).concrete
# concrete if all variants are present (even if spec not concrete)
spec._mark_concrete(False)
assert spec.variants.concrete
# remove a variant to test the condition
del spec.variants["foo"]
assert not spec.variants.concrete
def test_disjoint_set_initialization_errors(): def test_disjoint_set_initialization_errors():
# Constructing from non-disjoint sets should raise an exception # Constructing from non-disjoint sets should raise an exception