Add buildcache to reusable specs

This commit is contained in:
Massimiliano Culpo 2021-11-03 20:59:11 +01:00 committed by Todd Gamblin
parent 31dfad9c16
commit be2cf16b67
4 changed files with 51 additions and 16 deletions

View File

@ -241,11 +241,16 @@ def find_built_spec(self, spec):
]
"""
self.regenerate_spec_cache()
return self.find_by_hash(spec.dag_hash())
find_hash = spec.dag_hash()
def find_by_hash(self, find_hash):
"""Same as find_built_spec but uses the hash of a spec.
Args:
find_hash (str): hash of the spec to search
"""
if find_hash not in self._mirrors_for_spec:
return None
return self._mirrors_for_spec[find_hash]
def update_spec(self, spec, found_list):

View File

@ -90,7 +90,7 @@ def _patchelf():
# Check if patchelf spec is installed
spec = spack.spec.Spec('patchelf')
spec._old_concretize()
spec._old_concretize(deprecation_warning=False)
exe_path = os.path.join(spec.prefix.bin, "patchelf")
if spec.package.installed and os.path.exists(exe_path):
return exe_path

View File

@ -30,6 +30,7 @@
import llnl.util.tty as tty
import spack
import spack.binary_distribution
import spack.bootstrap
import spack.cmd
import spack.compilers
@ -1563,21 +1564,41 @@ def define_installed_packages(self, possible):
possible (dict): result of Package.possible_dependencies() for
specs in this solve.
"""
seen = set()
def _facts_from_concrete_spec(spec):
# tell the solver about any installed packages that could
# be dependencies (don't tell it about the others)
h = spec.dag_hash()
if spec.name in possible and h not in seen:
# this indicates that there is a spec like this installed
self.gen.fact(fn.installed_hash(spec.name, h))
# this describes what constraints it imposes on the solve
self.impose(h, spec, body=True)
self.gen.newline()
# add OS to possible OS's
self.possible_oses.add(spec.os)
# add the hash to the one seen so far
seen.add(h)
# Specs from local store
with spack.store.db.read_transaction():
for spec in spack.store.db.query(installed=True):
# tell the solver about any installed packages that could
# be dependencies (don't tell it about the others)
if spec.name in possible:
# this indicates that there is a spec like this installed
h = spec.dag_hash()
self.gen.fact(fn.installed_hash(spec.name, h))
_facts_from_concrete_spec(spec)
# this describes what constraints it imposes on the solve
self.impose(h, spec, body=True)
self.gen.newline()
# add OS to possible OS's
self.possible_oses.add(spec.os)
# Specs from configured buildcaches
try:
index = spack.binary_distribution.update_cache_and_get_specs()
for spec in index:
_facts_from_concrete_spec(spec)
except spack.binary_distribution.FetchCacheError:
# this is raised when no mirrors had indices.
# TODO: update mirror configuration so it can indicate that the source cache
# TODO: (or any mirror really) doesn't have binaries.
pass
def setup(self, driver, specs, tests=False, reuse=False):
"""Generate an ASP program with relevant constraints for specs.
@ -1701,7 +1722,14 @@ def __init__(self, specs):
def hash(self, pkg, h):
if pkg not in self._specs:
self._specs[pkg] = spack.store.db.get_by_hash(h)[0]
try:
# try to get the candidate from the store
self._specs[pkg] = spack.store.db.get_by_hash(h)[0]
except TypeError:
# the dag hash was not in the DB, try buildcache
s = spack.binary_distribution.binary_index.find_by_hash(h)
# see specifications in spack.binary_distribution.BinaryCacheIndex
self._specs[pkg] = s[0]['spec']
else:
# ensure that if it's already there, it's correct
spec = self._specs[pkg]

View File

@ -629,6 +629,8 @@ node_target_mismatch(Parent, Dependency)
:- depends_on(Parent, Dependency),
not node_target_match(Parent, Dependency).
:- node(Package), node_target(Package, Target), not target(Target).
#defined node_target_set/2.
#defined package_target_weight/3.