summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2021-11-03 20:59:11 +0100
committerTodd Gamblin <tgamblin@llnl.gov>2021-11-05 00:15:47 -0700
commitbe2cf16b6734cab7a5c82a810b300d4efc30931e (patch)
treea354ef9b4471938396657c972af247be523a5e09 /lib
parent31dfad9c16fd6c8cb7d6f07af449a2daf8c58f11 (diff)
downloadspack-be2cf16b6734cab7a5c82a810b300d4efc30931e.tar.gz
spack-be2cf16b6734cab7a5c82a810b300d4efc30931e.tar.bz2
spack-be2cf16b6734cab7a5c82a810b300d4efc30931e.tar.xz
spack-be2cf16b6734cab7a5c82a810b300d4efc30931e.zip
Add buildcache to reusable specs
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/binary_distribution.py9
-rw-r--r--lib/spack/spack/relocate.py2
-rw-r--r--lib/spack/spack/solver/asp.py54
-rw-r--r--lib/spack/spack/solver/concretize.lp2
4 files changed, 51 insertions, 16 deletions
diff --git a/lib/spack/spack/binary_distribution.py b/lib/spack/spack/binary_distribution.py
index 0cf254b582..0a23896b8f 100644
--- a/lib/spack/spack/binary_distribution.py
+++ b/lib/spack/spack/binary_distribution.py
@@ -241,11 +241,16 @@ class BinaryCacheIndex(object):
]
"""
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):
diff --git a/lib/spack/spack/relocate.py b/lib/spack/spack/relocate.py
index 78c5d72b23..14bc0e1953 100644
--- a/lib/spack/spack/relocate.py
+++ b/lib/spack/spack/relocate.py
@@ -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
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index 69f25b39b9..0c483d8dfc 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -30,6 +30,7 @@ import llnl.util.lang
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 @@ class SpackSolverSetup(object):
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 @@ class SpecBuilder(object):
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]
diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp
index e96094a4e7..7919af0770 100644
--- a/lib/spack/spack/solver/concretize.lp
+++ b/lib/spack/spack/solver/concretize.lp
@@ -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.