Add buildcache to reusable specs
This commit is contained in:
parent
31dfad9c16
commit
be2cf16b67
@ -241,11 +241,16 @@ def find_built_spec(self, spec):
|
|||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
self.regenerate_spec_cache()
|
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:
|
if find_hash not in self._mirrors_for_spec:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return self._mirrors_for_spec[find_hash]
|
return self._mirrors_for_spec[find_hash]
|
||||||
|
|
||||||
def update_spec(self, spec, found_list):
|
def update_spec(self, spec, found_list):
|
||||||
|
@ -90,7 +90,7 @@ def _patchelf():
|
|||||||
|
|
||||||
# Check if patchelf spec is installed
|
# Check if patchelf spec is installed
|
||||||
spec = spack.spec.Spec('patchelf')
|
spec = spack.spec.Spec('patchelf')
|
||||||
spec._old_concretize()
|
spec._old_concretize(deprecation_warning=False)
|
||||||
exe_path = os.path.join(spec.prefix.bin, "patchelf")
|
exe_path = os.path.join(spec.prefix.bin, "patchelf")
|
||||||
if spec.package.installed and os.path.exists(exe_path):
|
if spec.package.installed and os.path.exists(exe_path):
|
||||||
return exe_path
|
return exe_path
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
|
|
||||||
import spack
|
import spack
|
||||||
|
import spack.binary_distribution
|
||||||
import spack.bootstrap
|
import spack.bootstrap
|
||||||
import spack.cmd
|
import spack.cmd
|
||||||
import spack.compilers
|
import spack.compilers
|
||||||
@ -1563,21 +1564,41 @@ def define_installed_packages(self, possible):
|
|||||||
possible (dict): result of Package.possible_dependencies() for
|
possible (dict): result of Package.possible_dependencies() for
|
||||||
specs in this solve.
|
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():
|
with spack.store.db.read_transaction():
|
||||||
for spec in spack.store.db.query(installed=True):
|
for spec in spack.store.db.query(installed=True):
|
||||||
# tell the solver about any installed packages that could
|
_facts_from_concrete_spec(spec)
|
||||||
# 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))
|
|
||||||
|
|
||||||
# this describes what constraints it imposes on the solve
|
# Specs from configured buildcaches
|
||||||
self.impose(h, spec, body=True)
|
try:
|
||||||
self.gen.newline()
|
index = spack.binary_distribution.update_cache_and_get_specs()
|
||||||
|
for spec in index:
|
||||||
# add OS to possible OS's
|
_facts_from_concrete_spec(spec)
|
||||||
self.possible_oses.add(spec.os)
|
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):
|
def setup(self, driver, specs, tests=False, reuse=False):
|
||||||
"""Generate an ASP program with relevant constraints for specs.
|
"""Generate an ASP program with relevant constraints for specs.
|
||||||
@ -1701,7 +1722,14 @@ def __init__(self, specs):
|
|||||||
|
|
||||||
def hash(self, pkg, h):
|
def hash(self, pkg, h):
|
||||||
if pkg not in self._specs:
|
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:
|
else:
|
||||||
# ensure that if it's already there, it's correct
|
# ensure that if it's already there, it's correct
|
||||||
spec = self._specs[pkg]
|
spec = self._specs[pkg]
|
||||||
|
@ -629,6 +629,8 @@ node_target_mismatch(Parent, Dependency)
|
|||||||
:- depends_on(Parent, Dependency),
|
:- depends_on(Parent, Dependency),
|
||||||
not node_target_match(Parent, Dependency).
|
not node_target_match(Parent, Dependency).
|
||||||
|
|
||||||
|
:- node(Package), node_target(Package, Target), not target(Target).
|
||||||
|
|
||||||
#defined node_target_set/2.
|
#defined node_target_set/2.
|
||||||
#defined package_target_weight/3.
|
#defined package_target_weight/3.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user