Remove dead code from Environment (#42818)

Environment.concretize_and_add is not used anywhere.
This commit is contained in:
Massimiliano Culpo 2024-02-23 10:48:07 +01:00 committed by GitHub
parent 98de8e3257
commit 0979a6a875
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 0 additions and 47 deletions

View file

@ -1485,44 +1485,6 @@ def _concretize_separately(self, tests=False):
] ]
return results return results
def concretize_and_add(self, user_spec, concrete_spec=None, tests=False):
"""Concretize and add a single spec to the environment.
Concretize the provided ``user_spec`` and add it along with the
concretized result to the environment. If the given ``user_spec`` was
already present in the environment, this does not add a duplicate.
The concretized spec will be added unless the ``user_spec`` was
already present and an associated concrete spec was already present.
Args:
concrete_spec: if provided, then it is assumed that it is the
result of concretizing the provided ``user_spec``
"""
if self.unify is True:
msg = (
"cannot install a single spec in an environment that is "
"configured to be concretized together. Run instead:\n\n"
" $ spack add <spec>\n"
" $ spack install\n"
)
raise SpackEnvironmentError(msg)
spec = Spec(user_spec)
if self.add(spec):
concrete = concrete_spec or spec.concretized(tests=tests)
self._add_concrete_spec(spec, concrete)
else:
# spec might be in the user_specs, but not installed.
# TODO: Redo name-based comparison for old style envs
spec = next(s for s in self.user_specs if s.satisfies(user_spec))
concrete = self.specs_by_hash.get(spec.dag_hash())
if not concrete:
concrete = spec.concretized(tests=tests)
self._add_concrete_spec(spec, concrete)
return concrete
@property @property
def default_view(self): def default_view(self):
if not self.has_view(default_view_name): if not self.has_view(default_view_name):

View file

@ -2731,15 +2731,6 @@ def test_concretize_user_specs_together():
assert all("mpich" not in spec for _, spec in e.concretized_specs()) assert all("mpich" not in spec for _, spec in e.concretized_specs())
def test_cant_install_single_spec_when_concretizing_together():
e = ev.create("coconcretization")
e.unify = True
with pytest.raises(ev.SpackEnvironmentError, match=r"cannot install"):
e.concretize_and_add("zlib")
e.install_all()
def test_duplicate_packages_raise_when_concretizing_together(): def test_duplicate_packages_raise_when_concretizing_together():
e = ev.create("coconcretization") e = ev.create("coconcretization")
e.unify = True e.unify = True