builtin: replace self.spec[self.name] with self (take 2) (#49579)

Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
Massimiliano Culpo 2025-03-19 12:28:57 +01:00 committed by GitHub
parent 3a715c3e07
commit 26f7b2c066
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 39 additions and 83 deletions

View File

@ -37,13 +37,11 @@ class AwsOfiRccl(AutotoolsPackage):
# To enable this plug-in to work with RCCL add it to the LD_LIBRARY_PATH
def setup_run_environment(self, env):
aws_ofi_rccl_home = self.spec["aws-ofi-rccl"].prefix
env.prepend_path("LD_LIBRARY_PATH", aws_ofi_rccl_home.lib)
env.prepend_path("LD_LIBRARY_PATH", self.prefix.lib)
# To enable this plug-in to work with RCCL add it to the LD_LIBRARY_PATH
def setup_dependent_run_environment(self, env, dependent_spec):
aws_ofi_rccl_home = self.spec["aws-ofi-rccl"].prefix
env.prepend_path("LD_LIBRARY_PATH", aws_ofi_rccl_home.lib)
env.prepend_path("LD_LIBRARY_PATH", self.prefix.lib)
def configure_args(self):
spec = self.spec

View File

@ -54,7 +54,7 @@ def test_smoke_test(self):
cmake(
self.prefix.share.DIY.examples.smoke_test,
f"-DMPI_HOME={spec['mpi'].prefix}",
f"-DCMAKE_PREFIX_PATH={spec['diy'].prefix}",
f"-DCMAKE_PREFIX_PATH={self.prefix}",
)
cmake("--build", ".")
ctest("--verbose")

View File

@ -28,10 +28,8 @@ def install(self, spec, prefix):
@run_after("install")
def check_install(self):
print("Attempt to call 'dust' with '--version'")
dust = Executable(join_path(self.spec["dust"].prefix.bin, "dust"))
dust = Executable(join_path(self.prefix.bin, "dust"))
output = dust("--version", output=str.split)
print("stdout received fromm dust is '{}".format(output))
assert "Dust " in output
def test_run(self):

View File

@ -35,13 +35,8 @@ class Freeipmi(AutotoolsPackage):
def configure_args(self):
# FIXME: If root checking of root installation is added fix this:
# Discussed in issue #4432
tty.warn(
"Requires 'root' for bmc-watchdog.service installation to" " /lib/systemd/system/ !"
)
args = [
"--prefix={0}".format(prefix),
"--with-systemdsystemunitdir=" + self.spec["freeipmi"].prefix.lib.systemd.system,
tty.warn("Requires 'root' for bmc-watchdog.service installation to /lib/systemd/system/")
return [
f"--prefix={self.prefix}",
f"--with-systemdsystemunitdir={self.prefix.lib.systemd.system}",
]
return args

View File

@ -34,9 +34,5 @@ def autoreconf(self, spec, prefix):
bash("autogen.sh")
def configure_args(self):
args = [
"--disable-manpages",
"--with-bashcompletiondir="
+ join_path(self.spec["kmod"].prefix, "share", "bash-completion", "completions"),
]
return args
completions = join_path(self.prefix, "share", "bash-completion", "completions")
return ["--disable-manpages", f"--with-bashcompletiondir={completions}"]

View File

@ -36,8 +36,4 @@ class Lxc(AutotoolsPackage):
depends_on("m4", type="build")
def configure_args(self):
args = [
"bashcompdir="
+ join_path(self.spec["lxc"].prefix, "share", "bash-completion", "completions")
]
return args
return [f"bashcompdir={join_path(self.prefix, 'share', 'bash-completion', 'completions')}"]

View File

@ -291,10 +291,7 @@ def setup_run_environment(self, env):
# Find openspeedshop library path
oss_libdir = find_libraries(
"libopenss-framework",
root=self.spec["openspeedshop-utils"].prefix,
shared=True,
recursive=True,
"libopenss-framework", root=self.prefix, shared=True, recursive=True
)
env.prepend_path("LD_LIBRARY_PATH", os.path.dirname(oss_libdir.joined()))

View File

@ -42,10 +42,8 @@ def autoreconf(self, spec, prefix):
def configure_args(self):
args = [
"--enable-parallel-netcdf",
"--with-web-server-path={0}/html".format(
self.spec["ophidia-analytics-framework"].prefix
),
f"--with-web-server-path={self.prefix}/html",
"--with-web-server-url=http://127.0.0.1/ophidia",
"--with-ophidiaio-server-path={0}".format(self.spec["ophidia-io-server"].prefix),
f"--with-ophidiaio-server-path={self.spec['ophidia-io-server'].prefix}",
]
return args

View File

@ -748,19 +748,15 @@ def use_x11():
def test_smoke_test(self):
"""Simple smoke test for ParaView"""
spec = self.spec
pvserver = Executable(spec["paraview"].prefix.bin.pvserver)
pvserver = Executable(self.prefix.bin.pvserver)
pvserver("--help")
def test_pvpython(self):
"""Test pvpython"""
spec = self.spec
if "~python" in spec:
if "~python" in self.spec:
raise SkipTest("Package must be installed with +python")
pvpython = Executable(spec["paraview"].prefix.bin.pvpython)
pvpython = Executable(self.prefix.bin.pvpython)
pvpython("-c", "import paraview")
def test_mpi_ensemble(self):
@ -771,8 +767,8 @@ def test_mpi_ensemble(self):
raise SkipTest("Package must be installed with +mpi and +python")
mpirun = spec["mpi"].prefix.bin.mpirun
pvserver = spec["paraview"].prefix.bin.pvserver
pvpython = Executable(spec["paraview"].prefix.bin.pvpython)
pvserver = self.prefix.bin.pvserver
pvpython = Executable(self.prefix.bin.pvpython)
with working_dir("smoke_test_build", create=True):
with Popen(

View File

@ -121,8 +121,7 @@ def check_install(self):
with working_dir(checkdir, create=True):
source = join_path(os.path.dirname(self.module.__file__), "example1.c")
cflags = spec["pocl"].headers.cpp_flags.split()
# ldflags = spec["pocl"].libs.ld_flags.split()
ldflags = ["-L%s" % spec["pocl"].prefix.lib, "-lOpenCL", "-lpoclu"]
ldflags = [f"-L{self.prefix.lib}", "-lOpenCL", "-lpoclu"]
output = compile_c_and_execute(source, cflags, ldflags)
compare_output_file(
output, join_path(os.path.dirname(self.module.__file__), "example1.out")

View File

@ -89,6 +89,6 @@ def test_make(self):
test_dir = join_path(self.test_suite.current_test_cache_dir, self.test_src_dir)
with working_dir(test_dir):
cmake = self.spec["cmake"].command
cmake("-DCMAKE_PREFIX_PATH=" + self.spec["rocm-clang-ocl"].prefix, ".")
cmake(f"-DCMAKE_PREFIX_PATH={self.prefix}", ".")
make = which("make")
make()

View File

@ -80,9 +80,8 @@ def test_cmake(self):
"""Test cmake"""
test_dir = join_path(self.test_suite.current_test_cache_dir, self.test_src_dir)
with working_dir(test_dir, create=True):
prefixes = ";".join([self.spec["rocm-cmake"].prefix])
cc_options = ["-DCMAKE_PREFIX_PATH=" + prefixes, "."]
cmake = which(self.spec["cmake"].prefix.bin.cmake)
cc_options = [f"-DCMAKE_PREFIX_PATH={self.prefix}", "."]
cmake = self.spec["cmake"].command
cmake(*cc_options)
make()
make("clean")

View File

@ -67,7 +67,7 @@ def setup_run_environment(self, env):
env.prepend_path("PYTHONPATH", self.spec.prefix.share.tixi.python)
# allow ctypes to find the tixi library
libs = ":".join(self.spec["tixi"].libs.directories)
libs = ":".join(self.libs.directories)
if sys.platform == "darwin":
env.prepend_path("DYLD_FALLBACK_LIBRARY_PATH", libs)
else:

View File

@ -80,9 +80,7 @@ def install(self, spec, prefix):
# Replace stage dir -> installed src dir in tkConfig
filter_file(
stage_src,
installed_src,
join_path(self.spec["tk"].libs.directories[0], "tkConfig.sh"),
stage_src, installed_src, join_path(self.libs.directories[0], "tkConfig.sh")
)
@run_after("install")
@ -92,8 +90,7 @@ def symlink_wish(self):
def test_tk_help(self):
"""run tk help"""
tk = self.spec["tk"].command
tk("-h")
self.command("-h")
def test_tk_load(self):
"""check that tk can be loaded"""
@ -112,15 +109,11 @@ def command(self):
# Although we symlink wishX.Y to wish, we also need to support external
# installations that may not have this symlink, or may have multiple versions
# of Tk installed in the same directory.
return Executable(
os.path.realpath(self.prefix.bin.join("wish{0}".format(self.version.up_to(2))))
)
return Executable(os.path.realpath(self.prefix.bin.join(f"wish{self.version.up_to(2)}")))
@property
def libs(self):
return find_libraries(
["libtk{0}".format(self.version.up_to(2))], root=self.prefix, recursive=True
)
return find_libraries([f"libtk{self.version.up_to(2)}"], root=self.prefix, recursive=True)
def _find_script_dir(self):
# Put more-specific prefixes first

View File

@ -2,8 +2,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import sys
from spack.package import *
@ -47,9 +45,6 @@ def headers(self):
return HeaderList([])
def install(self, spec, prefix):
if sys.platform != "darwin":
raise InstallError("vecLibFort can be installed on macOS only")
filter_file(r"^PREFIX=.*", "", "Makefile")
make_args = []
@ -57,13 +52,13 @@ def install(self, spec, prefix):
if spec.satisfies("%gcc@6:"):
make_args += ["CFLAGS=-flax-vector-conversions"]
make_args += ["PREFIX=%s" % prefix, "install"]
make_args += [f"PREFIX={prefix}", "install"]
make(*make_args)
# test
fc = which("fc")
flags = ["-o", "tester", "-O", "tester.f90"]
flags.extend(spec["veclibfort"].libs.ld_flags.split())
flags.extend(self.libs.ld_flags.split())
fc(*flags)
Executable("./tester")()

View File

@ -276,20 +276,16 @@ def cmake_args(self):
def test_smoke_test(self):
"""Build and run ctests"""
spec = self.spec
if "+examples" not in spec:
if "+examples" not in self.spec:
raise SkipTest("Package must be installed with +examples")
testdir = "smoke_test_build"
with working_dir(testdir, create=True):
cmake = Executable(spec["cmake"].prefix.bin.cmake)
ctest = Executable(spec["cmake"].prefix.bin.ctest)
cmakeExampleDir = spec["vtk-m"].prefix.share.doc.VTKm.examples.smoke_test
cmake(*([cmakeExampleDir, "-DVTKm_ROOT=" + spec["vtk-m"].prefix]))
cmake(*(["--build", "."]))
ctest(*(["--verbose"]))
cmake = Executable(self.spec["cmake"].prefix.bin.cmake)
ctest = Executable(self.spec["cmake"].prefix.bin.ctest)
cmake(self.prefix.share.doc.VTKm.examples.smoke_test, f"-DVTKm_ROOT={self.prefix}")
cmake("--build", ".")
ctest("--verbose")
@run_after("install")
@on_package_attributes(run_tests=True)

View File

@ -185,9 +185,9 @@ def test_smoke_test(self, source_dir=None):
cmake = Executable(spec["cmake"].prefix.bin.cmake)
ctest = Executable(spec["cmake"].prefix.bin.ctest)
cmake(*([".", "-DZFP_ROOT=" + spec["zfp"].prefix]))
cmake(*(["--build", "."]))
ctest(*(["--verbose"]))
cmake(".", f"-DZFP_ROOT={self.prefix}")
cmake("--build", ".")
ctest("--verbose")
@run_after("install")
def copy_test_files(self):