From 7d50a6ae6e295fec5652cde911bc5ec29134d8bc Mon Sep 17 00:00:00 2001 From: Chris Green Date: Mon, 19 Aug 2024 12:25:20 -0500 Subject: [PATCH] Make prefix-finding robust against uninstalled build dependencies --- bin/build-spack-env.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/build-spack-env.sh b/bin/build-spack-env.sh index ef0e46b..238d6ee 100755 --- a/bin/build-spack-env.sh +++ b/bin/build-spack-env.sh @@ -786,16 +786,23 @@ _maybe_cache_binaries() { # avoid unnecessary overhead. { cat > "$TMP/location_cmds.py" <<\EOF -import spack.cmd import spack.environment +import spack.store + +all_hashes = spack.environment.active_environment().all_hashes() + + +def print_prefix_for_hash(spec, hash): + matching_specs = spack.store.STORE.db.query(hash, hashes=all_hashes, installed=True) + if len(matching_specs) == 1: + print(spec, matching_specs[0].prefix) -env = spack.environment.active_environment() EOF } || _die "I/O error writing to $TMP/location_cmds.py" for hash in ${hashes_to_cache_tmp[*]:+"${hashes_to_cache_tmp[@]}"}; do _report $DEBUG_4 "scheduling location lookup of $hash" - echo 'print("'"$hash"'", spack.cmd.disambiguate_spec("'"/${hash//*\///}"'", env, False).prefix)' >> "$TMP/location_cmds.py" + echo 'print_prefix_for_hash("'"$hash"'", "'"/${hash//*\///}"'")' >> "$TMP/location_cmds.py" done || _die "I/O error writing to $TMP/location_cmds.py" local hashes_to_cache=(