summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/common/arguments.py8
-rw-r--r--lib/spack/spack/cmd/solve.py6
-rw-r--r--lib/spack/spack/cmd/spec.py21
-rw-r--r--lib/spack/spack/spec.py14
4 files changed, 33 insertions, 16 deletions
diff --git a/lib/spack/spack/cmd/common/arguments.py b/lib/spack/spack/cmd/common/arguments.py
index 1b173bf584..bea8ccea90 100644
--- a/lib/spack/spack/cmd/common/arguments.py
+++ b/lib/spack/spack/cmd/common/arguments.py
@@ -320,3 +320,11 @@ the build yourself. Format: %%Y%%m%%d-%%H%%M-[cdash-track]"""
default=None,
help=cdash_help['buildstamp']
)
+
+
+@arg
+def reuse():
+ return Args(
+ '--reuse', action='store_true', default=False,
+ help='reuse installed dependencies'
+ )
diff --git a/lib/spack/spack/cmd/solve.py b/lib/spack/spack/cmd/solve.py
index 897eebfa4b..dc1fcf4ced 100644
--- a/lib/spack/spack/cmd/solve.py
+++ b/lib/spack/spack/cmd/solve.py
@@ -44,7 +44,8 @@ def setup_parser(subparser):
# Below are arguments w.r.t. spec display (like spack spec)
arguments.add_common_arguments(
- subparser, ['long', 'very_long', 'install_status'])
+ subparser, ['long', 'very_long', 'install_status', 'reuse']
+ )
subparser.add_argument(
'-y', '--yaml', action='store_const', dest='format', default=None,
const='yaml', help='print concrete spec as yaml')
@@ -68,9 +69,6 @@ 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")
diff --git a/lib/spack/spack/cmd/spec.py b/lib/spack/spack/cmd/spec.py
index 592da60388..7c1375210a 100644
--- a/lib/spack/spack/cmd/spec.py
+++ b/lib/spack/spack/cmd/spec.py
@@ -28,7 +28,8 @@ for further documentation regarding the spec syntax, see:
spack help --spec
"""
arguments.add_common_arguments(
- subparser, ['long', 'very_long', 'install_status'])
+ subparser, ['long', 'very_long', 'install_status', 'reuse']
+ )
subparser.add_argument(
'-y', '--yaml', action='store_const', dest='format', default=None,
const='yaml', help='print concrete spec as YAML')
@@ -64,7 +65,7 @@ def spec(parser, args):
name_fmt = '{namespace}.{name}' if args.namespaces else '{name}'
fmt = '{@version}{%compiler}{compiler_flags}{variants}{arch=architecture}'
install_status_fn = spack.spec.Spec.install_status
- kwargs = {
+ tree_kwargs = {
'cover': args.cover,
'format': name_fmt + fmt,
'hashlen': None if args.very_long else 7,
@@ -81,11 +82,15 @@ def spec(parser, args):
if not args.specs:
tty.die("spack spec requires at least one spec")
+ concretize_kwargs = {
+ 'reuse': args.reuse
+ }
+
for spec in spack.cmd.parse_specs(args.specs):
# With -y, just print YAML to output.
if args.format:
if spec.name in spack.repo.path or spec.virtual:
- spec.concretize()
+ spec.concretize(**concretize_kwargs)
# The user can specify the hash type to use
hash_type = getattr(ht, args.hash_type)
@@ -98,13 +103,13 @@ def spec(parser, args):
continue
with tree_context():
- kwargs['hashes'] = False # Always False for input spec
+ tree_kwargs['hashes'] = False # Always False for input spec
print("Input spec")
print("--------------------------------")
- print(spec.tree(**kwargs))
+ print(spec.tree(**tree_kwargs))
- kwargs['hashes'] = args.long or args.very_long
+ tree_kwargs['hashes'] = args.long or args.very_long
print("Concretized")
print("--------------------------------")
- spec.concretize()
- print(spec.tree(**kwargs))
+ spec.concretize(**concretize_kwargs)
+ print(spec.tree(**tree_kwargs))
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 08625eaa82..7268142537 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -2597,7 +2597,7 @@ class Spec(object):
msg += " For each package listed, choose another spec\n"
raise SpecDeprecatedError(msg)
- def _new_concretize(self, tests=False):
+ def _new_concretize(self, tests=False, reuse=False):
import spack.solver.asp
if not self.name:
@@ -2607,7 +2607,7 @@ class Spec(object):
if self._concrete:
return
- result = spack.solver.asp.solve([self], tests=tests)
+ result = spack.solver.asp.solve([self], tests=tests, reuse=reuse)
result.raise_if_unsat()
# take the best answer
@@ -2625,17 +2625,23 @@ class Spec(object):
self._dup(concretized)
self._mark_concrete()
- def concretize(self, tests=False):
+ def concretize(self, tests=False, reuse=False):
"""Concretize the current spec.
Args:
tests (bool or list): if False disregard 'test' dependencies,
if a list of names activate them for the packages in the list,
if True activate 'test' dependencies for all packages.
+ reuse (bool): if True try to maximize reuse of already installed
+ specs, if False don't account for installation status.
"""
if spack.config.get('config:concretizer') == "clingo":
- self._new_concretize(tests)
+ self._new_concretize(tests, reuse=reuse)
else:
+ if reuse:
+ msg = ('maximizing reuse of installed specs is not '
+ 'possible with the original concretizer')
+ raise spack.error.SpecError(msg)
self._old_concretize(tests)
def _mark_root_concrete(self, value=True):