Compare commits
1 Commits
v1.0.0-alp
...
features/r
Author | SHA1 | Date | |
---|---|---|---|
![]() |
771c4e4017 |
@@ -391,11 +391,17 @@ def preview_fn(args):
|
||||
constraints = spack.cmd.parse_specs(args.specs)
|
||||
specs = spack.store.find(constraints, multiple=True)
|
||||
|
||||
def status_fn(spec):
|
||||
if spack.relocate.is_relocatable(spec):
|
||||
return spec.install_stati.installed
|
||||
else:
|
||||
return spec.install_stati.unknown
|
||||
|
||||
# Cycle over the specs that match
|
||||
for spec in specs:
|
||||
print("Relocatable nodes")
|
||||
print("--------------------------------")
|
||||
print(spec.tree(status_fn=spack.relocate.is_relocatable))
|
||||
print(spec.tree(status_fn=status_fn))
|
||||
|
||||
|
||||
def check_fn(args):
|
||||
|
@@ -382,9 +382,14 @@ def add_concretizer_args(subparser):
|
||||
)
|
||||
subgroup.add_argument(
|
||||
'--reuse', action=ConfigSetAction, dest="concretizer:reuse",
|
||||
const=True, default=None,
|
||||
const="any", default=None,
|
||||
help='reuse installed dependencies/buildcaches when possible'
|
||||
)
|
||||
subgroup.add_argument(
|
||||
'--reuse-only', action=ConfigSetAction, dest="concretizer:reuse",
|
||||
const=True, default=None,
|
||||
help='operate as a binary package manager'
|
||||
)
|
||||
|
||||
|
||||
def add_s3_connection_args(subparser, add_help):
|
||||
|
@@ -873,7 +873,7 @@ def is_relocatable(spec):
|
||||
Raises:
|
||||
ValueError: if the spec is not installed
|
||||
"""
|
||||
if not spec.install_status():
|
||||
if not spec.installed():
|
||||
raise ValueError('spec is not installed [{0}]'.format(str(spec)))
|
||||
|
||||
if spec.external or spec.virtual:
|
||||
|
@@ -14,7 +14,10 @@
|
||||
'type': 'object',
|
||||
'additionalProperties': False,
|
||||
'properties': {
|
||||
'reuse': {'type': 'boolean'},
|
||||
'reuse': {
|
||||
'anyOf': [{'type': 'boolean'},
|
||||
{'type': 'string'}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1740,7 +1740,10 @@ def setup(self, driver, specs):
|
||||
|
||||
if self.reuse:
|
||||
self.gen.h1("Installed packages")
|
||||
self.gen.fact(fn.optimize_for_reuse())
|
||||
if self.reuse is True:
|
||||
self.gen.fact(fn.binary_package_manager())
|
||||
else:
|
||||
self.gen.fact(fn.optimize_for_reuse())
|
||||
self.gen.newline()
|
||||
self.define_installed_packages(specs, possible)
|
||||
|
||||
@@ -2087,7 +2090,7 @@ class Solver(object):
|
||||
|
||||
Properties of interest:
|
||||
|
||||
``reuse (bool)``
|
||||
``reuse (bool or str)``
|
||||
Whether to try to reuse existing installs/binaries
|
||||
|
||||
"""
|
||||
|
@@ -347,7 +347,7 @@ version_weight(Package, Weight) :- external_version(Package, Version, Weight).
|
||||
version(Package, Version) :- external_version(Package, Version, Weight).
|
||||
|
||||
% if a package is not buildable (external_only), only externals are allowed
|
||||
external(Package) :- external_only(Package), node(Package).
|
||||
external(Package) :- external_only(Package), build(Package), node(Package).
|
||||
|
||||
% a package is a real_node if it is not external
|
||||
real_node(Package) :- node(Package), not external(Package).
|
||||
@@ -862,6 +862,9 @@ impose(Hash) :- hash(Package, Hash).
|
||||
% if we haven't selected a hash for a package, we'll be building it
|
||||
build(Package) :- not hash(Package, _), node(Package).
|
||||
|
||||
% If we are acting as a binary package manager, we cannot build anything
|
||||
:- build(_), binary_package_manager().
|
||||
|
||||
% Minimizing builds is tricky. We want a minimizing criterion
|
||||
|
||||
% because we want to reuse what is avaialble, but
|
||||
@@ -881,6 +884,7 @@ build_priority(Package, 200) :- build(Package), node(Package).
|
||||
build_priority(Package, 0) :- not build(Package), node(Package).
|
||||
|
||||
#defined installed_hash/2.
|
||||
#defined binary_package_manager/0.
|
||||
|
||||
%-----------------------------------------------------------------------------
|
||||
% How to optimize the spec (high to low priority)
|
||||
|
@@ -4478,15 +4478,54 @@ def __str__(self):
|
||||
spec_str = " ^".join(d.format() for d in sorted_nodes)
|
||||
return spec_str.strip()
|
||||
|
||||
def install_status(self):
|
||||
install_stati = lang.enum(
|
||||
installed=0,
|
||||
upstream=1,
|
||||
binary=2,
|
||||
missing=3,
|
||||
missing_with_binary=4,
|
||||
unknown=5
|
||||
)
|
||||
install_status_symbols = {
|
||||
install_stati.installed: '@g{[+]}',
|
||||
install_stati.upstream: '@g{[^]}',
|
||||
install_stati.binary: '@K{ . }',
|
||||
install_stati.missing: '@r{[-]}',
|
||||
install_stati.missing_with_binary: '@r{[.]}',
|
||||
install_stati.unknown: '@K{ - }'
|
||||
}
|
||||
|
||||
def install_status(self, binary_status=True):
|
||||
"""Helper for tree to print DB install status."""
|
||||
if not self.concrete:
|
||||
return None
|
||||
try:
|
||||
record = spack.store.db.get_record(self)
|
||||
return record.installed
|
||||
except KeyError:
|
||||
return None
|
||||
return self.install_stati.unknown
|
||||
|
||||
binary = False
|
||||
if binary_status:
|
||||
import spack.binary_distribution as bindist
|
||||
try:
|
||||
binaries = [s.dag_hash()
|
||||
for s in bindist.update_cache_and_get_specs()
|
||||
]
|
||||
binary = self.dag_hash() in binaries
|
||||
except bindist.FetchCacheError:
|
||||
pass
|
||||
|
||||
upstream, record = spack.store.db.query_by_spec_hash(self.dag_hash())
|
||||
if not record and binary:
|
||||
return self.install_stati.binary
|
||||
elif not record:
|
||||
return self.install_stati.unknown
|
||||
elif upstream and record.installed:
|
||||
return self.install_stati.upstream
|
||||
elif record.installed:
|
||||
return self.install_stati.installed
|
||||
elif record and binary:
|
||||
return self.install_stati.missing_with_binary
|
||||
elif record:
|
||||
return self.install_stati.missing
|
||||
else:
|
||||
assert False, "invalid enum value"
|
||||
|
||||
def _installed_explicitly(self):
|
||||
"""Helper for tree to print DB install status."""
|
||||
@@ -4529,14 +4568,8 @@ def tree(self, **kwargs):
|
||||
|
||||
if status_fn:
|
||||
status = status_fn(node)
|
||||
if node.package.installed_upstream:
|
||||
out += clr.colorize("@g{[^]} ", color=color)
|
||||
elif status is None:
|
||||
out += clr.colorize("@K{ - } ", color=color) # !installed
|
||||
elif status:
|
||||
out += clr.colorize("@g{[+]} ", color=color) # installed
|
||||
else:
|
||||
out += clr.colorize("@r{[-]} ", color=color) # missing
|
||||
out += clr.colorize('%s ' % self.install_status_symbols[status],
|
||||
color=color)
|
||||
|
||||
if hashes:
|
||||
out += clr.colorize(
|
||||
|
Reference in New Issue
Block a user