spack spec: add --reuse argument
This commit is contained in:
parent
652fa663b5
commit
290f57c779
@ -320,3 +320,11 @@ def add_cdash_args(subparser, add_help):
|
|||||||
default=None,
|
default=None,
|
||||||
help=cdash_help['buildstamp']
|
help=cdash_help['buildstamp']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@arg
|
||||||
|
def reuse():
|
||||||
|
return Args(
|
||||||
|
'--reuse', action='store_true', default=False,
|
||||||
|
help='reuse installed dependencies'
|
||||||
|
)
|
||||||
|
@ -44,7 +44,8 @@ def setup_parser(subparser):
|
|||||||
|
|
||||||
# Below are arguments w.r.t. spec display (like spack spec)
|
# Below are arguments w.r.t. spec display (like spack spec)
|
||||||
arguments.add_common_arguments(
|
arguments.add_common_arguments(
|
||||||
subparser, ['long', 'very_long', 'install_status'])
|
subparser, ['long', 'very_long', 'install_status', 'reuse']
|
||||||
|
)
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'-y', '--yaml', action='store_const', dest='format', default=None,
|
'-y', '--yaml', action='store_const', dest='format', default=None,
|
||||||
const='yaml', help='print concrete spec as yaml')
|
const='yaml', help='print concrete spec as yaml')
|
||||||
@ -67,9 +68,6 @@ def setup_parser(subparser):
|
|||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'--stats', action='store_true', default=False,
|
'--stats', action='store_true', default=False,
|
||||||
help='print out statistics from clingo')
|
help='print out statistics from clingo')
|
||||||
subparser.add_argument(
|
|
||||||
'--reuse', action='store_true', default=False,
|
|
||||||
help='reuse installed dependencies')
|
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'specs', nargs=argparse.REMAINDER, help="specs of packages")
|
'specs', nargs=argparse.REMAINDER, help="specs of packages")
|
||||||
|
|
||||||
|
@ -28,7 +28,8 @@ def setup_parser(subparser):
|
|||||||
spack help --spec
|
spack help --spec
|
||||||
"""
|
"""
|
||||||
arguments.add_common_arguments(
|
arguments.add_common_arguments(
|
||||||
subparser, ['long', 'very_long', 'install_status'])
|
subparser, ['long', 'very_long', 'install_status', 'reuse']
|
||||||
|
)
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'-y', '--yaml', action='store_const', dest='format', default=None,
|
'-y', '--yaml', action='store_const', dest='format', default=None,
|
||||||
const='yaml', help='print concrete spec as YAML')
|
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}'
|
name_fmt = '{namespace}.{name}' if args.namespaces else '{name}'
|
||||||
fmt = '{@version}{%compiler}{compiler_flags}{variants}{arch=architecture}'
|
fmt = '{@version}{%compiler}{compiler_flags}{variants}{arch=architecture}'
|
||||||
install_status_fn = spack.spec.Spec.install_status
|
install_status_fn = spack.spec.Spec.install_status
|
||||||
kwargs = {
|
tree_kwargs = {
|
||||||
'cover': args.cover,
|
'cover': args.cover,
|
||||||
'format': name_fmt + fmt,
|
'format': name_fmt + fmt,
|
||||||
'hashlen': None if args.very_long else 7,
|
'hashlen': None if args.very_long else 7,
|
||||||
@ -81,11 +82,15 @@ def spec(parser, args):
|
|||||||
if not args.specs:
|
if not args.specs:
|
||||||
tty.die("spack spec requires at least one spec")
|
tty.die("spack spec requires at least one spec")
|
||||||
|
|
||||||
|
concretize_kwargs = {
|
||||||
|
'reuse': args.reuse
|
||||||
|
}
|
||||||
|
|
||||||
for spec in spack.cmd.parse_specs(args.specs):
|
for spec in spack.cmd.parse_specs(args.specs):
|
||||||
# With -y, just print YAML to output.
|
# With -y, just print YAML to output.
|
||||||
if args.format:
|
if args.format:
|
||||||
if spec.name in spack.repo.path or spec.virtual:
|
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
|
# The user can specify the hash type to use
|
||||||
hash_type = getattr(ht, args.hash_type)
|
hash_type = getattr(ht, args.hash_type)
|
||||||
@ -98,13 +103,13 @@ def spec(parser, args):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
with tree_context():
|
with tree_context():
|
||||||
kwargs['hashes'] = False # Always False for input spec
|
tree_kwargs['hashes'] = False # Always False for input spec
|
||||||
print("Input spec")
|
print("Input spec")
|
||||||
print("--------------------------------")
|
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("Concretized")
|
||||||
print("--------------------------------")
|
print("--------------------------------")
|
||||||
spec.concretize()
|
spec.concretize(**concretize_kwargs)
|
||||||
print(spec.tree(**kwargs))
|
print(spec.tree(**tree_kwargs))
|
||||||
|
@ -2597,7 +2597,7 @@ def ensure_no_deprecated(root):
|
|||||||
msg += " For each package listed, choose another spec\n"
|
msg += " For each package listed, choose another spec\n"
|
||||||
raise SpecDeprecatedError(msg)
|
raise SpecDeprecatedError(msg)
|
||||||
|
|
||||||
def _new_concretize(self, tests=False):
|
def _new_concretize(self, tests=False, reuse=False):
|
||||||
import spack.solver.asp
|
import spack.solver.asp
|
||||||
|
|
||||||
if not self.name:
|
if not self.name:
|
||||||
@ -2607,7 +2607,7 @@ def _new_concretize(self, tests=False):
|
|||||||
if self._concrete:
|
if self._concrete:
|
||||||
return
|
return
|
||||||
|
|
||||||
result = spack.solver.asp.solve([self], tests=tests)
|
result = spack.solver.asp.solve([self], tests=tests, reuse=reuse)
|
||||||
result.raise_if_unsat()
|
result.raise_if_unsat()
|
||||||
|
|
||||||
# take the best answer
|
# take the best answer
|
||||||
@ -2625,17 +2625,23 @@ def _new_concretize(self, tests=False):
|
|||||||
self._dup(concretized)
|
self._dup(concretized)
|
||||||
self._mark_concrete()
|
self._mark_concrete()
|
||||||
|
|
||||||
def concretize(self, tests=False):
|
def concretize(self, tests=False, reuse=False):
|
||||||
"""Concretize the current spec.
|
"""Concretize the current spec.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
tests (bool or list): if False disregard 'test' dependencies,
|
tests (bool or list): if False disregard 'test' dependencies,
|
||||||
if a list of names activate them for the packages in the list,
|
if a list of names activate them for the packages in the list,
|
||||||
if True activate 'test' dependencies for all packages.
|
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":
|
if spack.config.get('config:concretizer') == "clingo":
|
||||||
self._new_concretize(tests)
|
self._new_concretize(tests, reuse=reuse)
|
||||||
else:
|
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)
|
self._old_concretize(tests)
|
||||||
|
|
||||||
def _mark_root_concrete(self, value=True):
|
def _mark_root_concrete(self, value=True):
|
||||||
|
@ -1635,7 +1635,7 @@ _spack_restage() {
|
|||||||
_spack_solve() {
|
_spack_solve() {
|
||||||
if $list_options
|
if $list_options
|
||||||
then
|
then
|
||||||
SPACK_COMPREPLY="-h --help --show --models -l --long -L --very-long -I --install-status -y --yaml -j --json -c --cover -N --namespaces -t --types --timers --stats --reuse"
|
SPACK_COMPREPLY="-h --help --show --models -l --long -L --very-long -I --install-status --reuse -y --yaml -j --json -c --cover -N --namespaces -t --types --timers --stats"
|
||||||
else
|
else
|
||||||
_all_packages
|
_all_packages
|
||||||
fi
|
fi
|
||||||
@ -1644,7 +1644,7 @@ _spack_solve() {
|
|||||||
_spack_spec() {
|
_spack_spec() {
|
||||||
if $list_options
|
if $list_options
|
||||||
then
|
then
|
||||||
SPACK_COMPREPLY="-h --help -l --long -L --very-long -I --install-status -y --yaml -j --json -c --cover -N --namespaces --hash-type -t --types"
|
SPACK_COMPREPLY="-h --help -l --long -L --very-long -I --install-status --reuse -y --yaml -j --json -c --cover -N --namespaces --hash-type -t --types"
|
||||||
else
|
else
|
||||||
_all_packages
|
_all_packages
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user