From abc162cf3b39ae1907e4bad3b27cb704feb4f0a8 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Tue, 19 Apr 2022 21:32:59 +0200 Subject: environment.py: write lockfile last (#30039) This makes it easier to write `spack.lock: spack.yaml` type of rules in `Makefiles`. --- lib/spack/spack/environment/environment.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py index b6875653df..720819695b 100644 --- a/lib/spack/spack/environment/environment.py +++ b/lib/spack/spack/environment/environment.py @@ -1897,10 +1897,14 @@ class Environment(object): fs.mkdirp(pkg_dir) spack.repo.path.dump_provenance(dep, pkg_dir) - # write the lock file last + self._update_and_write_manifest(raw_yaml_dict, yaml_dict) + + # Write the lock file last. This is useful for Makefiles + # with `spack.lock: spack.yaml` rules, where the target + # should be newer than the prerequisite to avoid + # redundant re-concretization. with fs.write_tmp_and_move(self.lock_path) as f: sjson.dump(self._to_lockfile_dict(), stream=f) - self._update_and_write_manifest(raw_yaml_dict, yaml_dict) else: with fs.safe_remove(self.lock_path): self._update_and_write_manifest(raw_yaml_dict, yaml_dict) -- cgit v1.2.3-60-g2f50