summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2021-07-24 05:31:19 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2021-11-05 00:15:47 -0700
commitad5d632eebce4d2af797746ba02357a45836b560 (patch)
treec075d49d23a0d988c6ab61ea4948bffa4e84d544
parent288176326c8d52dea65084d6b1b8aab5f5df0369 (diff)
downloadspack-ad5d632eebce4d2af797746ba02357a45836b560.tar.gz
spack-ad5d632eebce4d2af797746ba02357a45836b560.tar.bz2
spack-ad5d632eebce4d2af797746ba02357a45836b560.tar.xz
spack-ad5d632eebce4d2af797746ba02357a45836b560.zip
add `--reuse` option to `spack solve`
-rw-r--r--lib/spack/spack/cmd/solve.py6
-rw-r--r--lib/spack/spack/solver/asp.py13
2 files changed, 13 insertions, 6 deletions
diff --git a/lib/spack/spack/cmd/solve.py b/lib/spack/spack/cmd/solve.py
index e2563ef0c8..123c68862d 100644
--- a/lib/spack/spack/cmd/solve.py
+++ b/lib/spack/spack/cmd/solve.py
@@ -68,6 +68,9 @@ def setup_parser(subparser):
'--stats', action='store_true', default=False,
help='print out statistics from clingo')
subparser.add_argument(
+ '--reuse', action='store_true', default=False,
+ help='reuse installed dependencies')
+ subparser.add_argument(
'specs', nargs=argparse.REMAINDER, help="specs of packages")
@@ -103,7 +106,8 @@ def solve(parser, args):
# dump generated ASP program
result = asp.solve(
- specs, dump=dump, models=models, timers=args.timers, stats=args.stats
+ specs, dump=dump, models=models, timers=args.timers, stats=args.stats,
+ reuse=args.reuse,
)
if 'solutions' not in dump:
return
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index e83b38cf8d..09a03543f8 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -440,7 +440,7 @@ class PyclingoDriver(object):
def solve(
self, solver_setup, specs, dump=None, nmodels=0,
- timers=False, stats=False, tests=False
+ timers=False, stats=False, tests=False, reuse=False,
):
timer = spack.util.timer.Timer()
@@ -457,7 +457,7 @@ class PyclingoDriver(object):
self.assumptions = []
with self.control.backend() as backend:
self.backend = backend
- solver_setup.setup(self, specs, tests=tests)
+ solver_setup.setup(self, specs, tests=tests, reuse=reuse)
timer.phase("setup")
# read in the main ASP program and display logic -- these are
@@ -1475,7 +1475,7 @@ class SpackSolverSetup(object):
for pkg, variant, value in sorted(self.variant_values_from_specs):
self.gen.fact(fn.variant_possible_value(pkg, variant, value))
- def setup(self, driver, specs, tests=False):
+ def setup(self, driver, specs, tests=False, reuse=False):
"""Generate an ASP program with relevant constraints for specs.
This calls methods on the solve driver to set up the problem with
@@ -1803,7 +1803,8 @@ def _develop_specs_from_env(spec, env):
#
# These are handwritten parts for the Spack ASP model.
#
-def solve(specs, dump=(), models=0, timers=False, stats=False, tests=False):
+def solve(specs, dump=(), models=0, timers=False, stats=False, tests=False,
+ reuse=False):
"""Solve for a stable model of specs.
Arguments:
@@ -1823,4 +1824,6 @@ def solve(specs, dump=(), models=0, timers=False, stats=False, tests=False):
spack.spec.Spec.ensure_valid_variants(s)
setup = SpackSolverSetup()
- return driver.solve(setup, specs, dump, models, timers, stats, tests)
+ return driver.solve(
+ setup, specs, dump, models, timers, stats, tests, reuse
+ )