builtin: self.spec[self.name].command -> self.command (#49582)
* builtin: self.spec[self.name].command -> self.command * python-venv: ensure return type is Executable instead of Executable | None
This commit is contained in:
parent
34efcb686c
commit
963519d2b2
@ -319,7 +319,7 @@ def install_test(self):
|
||||
)
|
||||
|
||||
# Spack's logs don't handle colored output well
|
||||
bazel = Executable(self.spec["bazel"].command.path)
|
||||
bazel = Executable(self.command.path)
|
||||
bazel(
|
||||
"--output_user_root=/tmp/spack/bazel/spack-test",
|
||||
"build",
|
||||
@ -332,7 +332,7 @@ def install_test(self):
|
||||
assert exe(output=str) == "Hi!\n"
|
||||
|
||||
def setup_dependent_package(self, module, dependent_spec):
|
||||
module.bazel = Executable(self.spec["bazel"].command.path)
|
||||
module.bazel = Executable(self.command.path)
|
||||
|
||||
@property
|
||||
def parallel(self):
|
||||
|
@ -169,7 +169,7 @@ def check_install(self):
|
||||
os.environ.pop("CLIKPATH", "")
|
||||
os.environ.pop("PLANCKLIKE", "")
|
||||
|
||||
exe = spec["cosmomc"].command.path
|
||||
exe = self.command.path
|
||||
args = []
|
||||
if spec.satisfies("+mpi"):
|
||||
# Add mpirun prefix
|
||||
|
@ -1005,7 +1005,7 @@ def write_specs_file(self):
|
||||
specs_file = join_path(self.spec_dir, "specs")
|
||||
with open(specs_file, "w") as f:
|
||||
# can't extend the builtins without dumping them first
|
||||
f.write(self.spec["gcc"].command("-dumpspecs", output=str, error=os.devnull).strip())
|
||||
f.write(self.command("-dumpspecs", output=str, error=os.devnull).strip())
|
||||
|
||||
f.write("\n\n# Generated by Spack\n\n")
|
||||
|
||||
@ -1179,7 +1179,7 @@ def _post_buildcache_install_hook(self):
|
||||
|
||||
# Setting up the runtime environment shouldn't be necessary here.
|
||||
relocation_args = []
|
||||
gcc = self.spec["gcc"].command
|
||||
gcc = self.command
|
||||
specs_file = os.path.join(self.spec_dir, "specs")
|
||||
dryrun = gcc("test.c", "-###", output=os.devnull, error=str).strip()
|
||||
if not dryrun:
|
||||
|
@ -120,4 +120,4 @@ def setup_dependent_package(self, module, dependent_spec):
|
||||
install_tree('bin', prefix.bin)
|
||||
"""
|
||||
# Add a go command/compiler for extensions
|
||||
module.go = self.spec["go"].command
|
||||
module.go = self.command
|
||||
|
@ -36,7 +36,7 @@ def configure_args(self):
|
||||
@run_after("install")
|
||||
@on_package_attributes(run_tests=True)
|
||||
def install_test(self):
|
||||
jq = self.spec["jq"].command
|
||||
jq = self.command
|
||||
f = os.path.join(os.path.dirname(__file__), "input.json")
|
||||
|
||||
assert jq(".bar", input=f, output=str) == "2\n"
|
||||
|
@ -244,7 +244,7 @@ def apply_patch(self, other):
|
||||
|
||||
def setup_dependent_package(self, module, dependent_spec):
|
||||
# Make plumed visible from dependent packages
|
||||
module.plumed = dependent_spec["plumed"].command
|
||||
module.plumed = self.command
|
||||
|
||||
@property
|
||||
def plumed_inc(self):
|
||||
|
@ -54,7 +54,7 @@ def bindir(self):
|
||||
def command(self):
|
||||
"""Returns a python Executable instance"""
|
||||
python_name = "python" if self.spec.satisfies("platform=windows") else "python3"
|
||||
return which(python_name, path=self.bindir)
|
||||
return which(python_name, path=self.bindir, required=True)
|
||||
|
||||
def _get_path(self, name) -> str:
|
||||
return self.command(
|
||||
|
@ -1373,8 +1373,7 @@ def add_files_to_view(self, view, merge_map, skip_if_exists=True):
|
||||
|
||||
def test_hello_world(self):
|
||||
"""run simple hello world program"""
|
||||
# do not use self.command because we are also testing the run env
|
||||
python = self.spec["python"].command
|
||||
python = self.command
|
||||
|
||||
msg = "hello world!"
|
||||
out = python("-c", f'print("{msg}")', output=str.split, error=str.split)
|
||||
@ -1382,7 +1381,7 @@ def test_hello_world(self):
|
||||
|
||||
def test_import_executable(self):
|
||||
"""ensure import of installed executable works"""
|
||||
python = self.spec["python"].command
|
||||
python = self.command
|
||||
|
||||
out = python("-c", "import sys; print(sys.executable)", output=str.split, error=str.split)
|
||||
assert self.spec.prefix in out
|
||||
|
Loading…
Reference in New Issue
Block a user