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