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.
This commit is contained in:
Massimiliano Culpo 2021-05-06 19:19:10 +02:00 committed by GitHub
parent 2ba493cd63
commit f83ec4d46f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View File

@ -724,6 +724,24 @@ def concretize_specs_together(*abstract_specs, **kwargs):
Returns: Returns:
List of concretized specs 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): def make_concretization_repository(abstract_specs):
"""Returns the path to a temporary repository created to contain """Returns the path to a temporary repository created to contain
a fake package that depends on all of the abstract specs. a fake package that depends on all of the abstract specs.

View File

@ -2454,3 +2454,18 @@ def test_does_not_rewrite_rel_dev_path_when_keep_relative_is_set(tmpdir):
print(e.dev_specs) print(e.dev_specs)
assert e.dev_specs['mypkg1']['path'] == '../build_folder' assert e.dev_specs['mypkg1']['path'] == '../build_folder'
assert e.dev_specs['mypkg2']['path'] == '/some/other/path' assert e.dev_specs['mypkg2']['path'] == '/some/other/path'
@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())