diff options
author | Tobias Ribizel <mail@ribizel.de> | 2024-10-15 15:52:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-15 13:52:31 +0000 |
commit | 834ed2f1172a120b5d1008293b0d40df8c3459a8 (patch) | |
tree | bd02a40eca9668c05080199b199e3113856921a5 | |
parent | 73069045ae803db6da7a531262939657f2088d09 (diff) | |
download | spack-834ed2f1172a120b5d1008293b0d40df8c3459a8.tar.gz spack-834ed2f1172a120b5d1008293b0d40df8c3459a8.tar.bz2 spack-834ed2f1172a120b5d1008293b0d40df8c3459a8.tar.xz spack-834ed2f1172a120b5d1008293b0d40df8c3459a8.zip |
env depfile: generate Makefile with absolute script path (#46966)
Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
-rw-r--r-- | lib/spack/spack/environment/depfile.py | 3 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/env.py | 20 | ||||
-rw-r--r-- | share/spack/templates/depfile/Makefile | 2 |
3 files changed, 19 insertions, 6 deletions
diff --git a/lib/spack/spack/environment/depfile.py b/lib/spack/spack/environment/depfile.py index 06dc8f157d..38d673192b 100644 --- a/lib/spack/spack/environment/depfile.py +++ b/lib/spack/spack/environment/depfile.py @@ -9,11 +9,13 @@ depfiles from an environment. import os import re +import shlex from enum import Enum from typing import List, Optional import spack.deptypes as dt import spack.environment.environment as ev +import spack.paths import spack.spec import spack.traverse as traverse @@ -226,6 +228,7 @@ class MakefileModel: "install_deps_target": self._target("install-deps"), "any_hash_target": self._target("%"), "jobserver_support": self.jobserver_support, + "spack_script": shlex.quote(spack.paths.spack_script), "adjacency_list": self.make_adjacency_list, "phony_convenience_targets": " ".join(self.phony_convenience_targets), "pkg_ids_variable": self.pkg_identifier_variable, diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index 70e2c56e41..d1d35e6f5e 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -3953,7 +3953,7 @@ def test_environment_depfile_makefile(depfile_flags, expected_installs, tmpdir, ) # Do make dry run. - out = make("-n", "-f", makefile, output=str) + out = make("-n", "-f", makefile, "SPACK=spack", output=str) specs_that_make_would_install = _parse_dry_run_package_installs(out) @@ -3991,7 +3991,7 @@ def test_depfile_works_with_gitversions(tmpdir, mock_packages, monkeypatch): env("depfile", "-o", makefile, "--make-disable-jobserver", "--make-prefix=prefix") # Do a dry run on the generated depfile - out = make("-n", "-f", makefile, output=str) + out = make("-n", "-f", makefile, "SPACK=spack", output=str) # Check that all specs are there (without duplicates) specs_that_make_would_install = _parse_dry_run_package_installs(out) @@ -4053,7 +4053,12 @@ def test_depfile_phony_convenience_targets( # Phony install/* target should install picked package and all its deps specs_that_make_would_install = _parse_dry_run_package_installs( - make("-n", picked_spec.format("install/{name}-{version}-{hash}"), output=str) + make( + "-n", + picked_spec.format("install/{name}-{version}-{hash}"), + "SPACK=spack", + output=str, + ) ) assert set(specs_that_make_would_install) == set(expected_installs) @@ -4061,7 +4066,12 @@ def test_depfile_phony_convenience_targets( # Phony install-deps/* target shouldn't install picked package specs_that_make_would_install = _parse_dry_run_package_installs( - make("-n", picked_spec.format("install-deps/{name}-{version}-{hash}"), output=str) + make( + "-n", + picked_spec.format("install-deps/{name}-{version}-{hash}"), + "SPACK=spack", + output=str, + ) ) assert set(specs_that_make_would_install) == set(expected_installs) - {picked_package} @@ -4121,7 +4131,7 @@ post-install: $(addprefix example/post-install/,$(example/SPACK_PACKAGE_IDS)) make = Executable("make") # Do dry run. - out = make("-n", "-C", str(tmpdir), output=str) + out = make("-n", "-C", str(tmpdir), "SPACK=spack", output=str) # post-install: <hash> should've been executed with ev.read("test") as test: diff --git a/share/spack/templates/depfile/Makefile b/share/spack/templates/depfile/Makefile index 4b76475267..cd9df1491c 100644 --- a/share/spack/templates/depfile/Makefile +++ b/share/spack/templates/depfile/Makefile @@ -1,4 +1,4 @@ -SPACK ?= spack -c config:install_status:false +SPACK ?= {{ spack_script }} -c config:install_status:false SPACK_INSTALL_FLAGS ?= # This variable can be used to add post install hooks |