diff options
author | Greg Becker <becker33@llnl.gov> | 2022-11-06 16:47:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-06 16:47:07 -0800 |
commit | fce7bf179f03466e348075ae27f109187af6f08e (patch) | |
tree | bff8fe65e33494e595eb82f8bf1e9cbaa9ac4118 | |
parent | f3db624b86fc6b746a74dd7f042745e040312fed (diff) | |
download | spack-fce7bf179f03466e348075ae27f109187af6f08e.tar.gz spack-fce7bf179f03466e348075ae27f109187af6f08e.tar.bz2 spack-fce7bf179f03466e348075ae27f109187af6f08e.tar.xz spack-fce7bf179f03466e348075ae27f109187af6f08e.zip |
solver setup: extract virtual dependencies from reusable specs (#32434)
* extract virtual dependencies from reusable specs
* bugfix to avoid establishing new node for virtual
-rw-r--r-- | lib/spack/spack/solver/asp.py | 6 | ||||
-rw-r--r-- | lib/spack/spack/test/concretize.py | 22 |
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index f0437b9309..8c9108fea9 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -1463,6 +1463,12 @@ class SpackSolverSetup(object): if concrete_build_deps or dtype != "build": clauses.append(fn.depends_on(spec.name, dep.name, dtype)) + # Ensure Spack will not coconcretize this with another provider + # for the same virtual + for virtual in dep.package.virtuals_provided: + clauses.append(fn.virtual_node(virtual.name)) + clauses.append(fn.provider(dep.name, virtual.name)) + # imposing hash constraints for all but pure build deps of # already-installed concrete specs. if concrete_build_deps or dspec.deptypes != ("build",): diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index b943fad755..ab3337da5e 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -1706,6 +1706,28 @@ class TestConcretize(object): counter += 1 assert counter == occurances, concrete_specs + def test_coconcretize_reuse_and_virtuals(self): + import spack.solver.asp + + if spack.config.get("config:concretizer") == "original": + pytest.skip("Original concretizer cannot reuse") + + reusable_specs = [] + for s in ["mpileaks ^mpich", "zmpi"]: + reusable_specs.extend(spack.spec.Spec(s).concretized().traverse(root=True)) + + root_specs = [spack.spec.Spec("mpileaks"), spack.spec.Spec("zmpi")] + + import spack.solver.asp + + with spack.config.override("concretizer:reuse", True): + solver = spack.solver.asp.Solver() + setup = spack.solver.asp.SpackSolverSetup() + result, _, _ = solver.driver.solve(setup, root_specs, reuse=reusable_specs) + + for spec in result.specs: + assert "zmpi" in spec + @pytest.mark.regression("30864") def test_misleading_error_message_on_version(self, mutable_database): # For this bug to be triggered we need a reusable dependency |