summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2021-05-06 19:19:10 +0200
committerTodd Gamblin <tgamblin@llnl.gov>2021-05-22 11:51:21 -0700
commit30dd61264a69eb9385a07fa4e263f0e74719ed1f (patch)
treeb9b8eed858b6a1277326908c66435c3b461430bc /lib
parent13fed376f20f11221b83a806cc66e4ae82918c4d (diff)
downloadspack-30dd61264a69eb9385a07fa4e263f0e74719ed1f.tar.gz
spack-30dd61264a69eb9385a07fa4e263f0e74719ed1f.tar.bz2
spack-30dd61264a69eb9385a07fa4e263f0e74719ed1f.tar.xz
spack-30dd61264a69eb9385a07fa4e263f0e74719ed1f.zip
ASP-based solver: no intermediate package for concretizing together (#23307)
The ASP-based solver can natively manage cases where more than one root spec is given, and is able to concretize all the roots together (ensuring one spec per package at most). Modifications: - [x] When concretising together an environment the ASP-based solver calls directly its `solve` method rather than constructing a temporary fake root package.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/concretize.py18
-rw-r--r--lib/spack/spack/test/cmd/env.py15
2 files changed, 33 insertions, 0 deletions
diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py
index 7e180eb91e..7c00b4dd55 100644
--- a/lib/spack/spack/concretize.py
+++ b/lib/spack/spack/concretize.py
@@ -724,6 +724,24 @@ def concretize_specs_together(*abstract_specs):
Returns:
List of concretized specs
"""
+ if spack.config.get('config:concretizer') == 'original':
+ return _concretize_specs_together_original(*abstract_specs, **kwargs)
+ return _concretize_specs_together_new(*abstract_specs, **kwargs)
+
+
+def _concretize_specs_together_new(*abstract_specs, **kwargs):
+ import spack.solver.asp
+ result = spack.solver.asp.solve(abstract_specs)
+
+ if not result.satisfiable:
+ result.print_cores()
+ tty.die("Unsatisfiable spec.")
+
+ opt, i, answer = min(result.answers)
+ return [answer[s.name].copy() for s in abstract_specs]
+
+
+def _concretize_specs_together_original(*abstract_specs, **kwargs):
def make_concretization_repository(abstract_specs):
"""Returns the path to a temporary repository created to contain
a fake package that depends on all of the abstract specs.
diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py
index 44b5caf5f9..f43ea4ff32 100644
--- a/lib/spack/spack/test/cmd/env.py
+++ b/lib/spack/spack/test/cmd/env.py
@@ -2369,3 +2369,18 @@ spack:
e.clear()
e.write()
assert os.path.exists(str(spack_lock))
+
+
+@pytest.mark.regression('23440')
+def test_custom_version_concretize_together(tmpdir):
+ # Custom versions should be permitted in specs when
+ # concretizing together
+ e = ev.create('custom_version')
+ e.concretization = 'together'
+
+ # Concretize a first time using 'mpich' as the MPI provider
+ e.add('hdf5@myversion')
+ e.add('mpich')
+ e.concretize()
+
+ assert any('hdf5@myversion' in spec for _, spec in e.concretized_specs())