py-mpi4py: create mpi.cfg file, this file is removed since v4.0.0, but API is retained #47584
Co-authored-by: t. chantrait <teddy.chantrait@cea.fr>
This commit is contained in:
parent
9760089089
commit
bf5e6b4aaf
@ -2,6 +2,7 @@
|
||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||
#
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
import os
|
||||
|
||||
from spack.package import *
|
||||
|
||||
@ -50,3 +51,35 @@ def setup_build_environment(self, env):
|
||||
def cythonize(self):
|
||||
with working_dir(self.build_directory):
|
||||
python(join_path("conf", "cythonize.py"))
|
||||
|
||||
def create_mpi_config_file(self, cfg_fn):
|
||||
"""
|
||||
create mpi.cfg file introduced since version 4.0.0.
|
||||
see https://mpi4py.readthedocs.io/en/stable/mpi4py.html#mpi4py.get_config
|
||||
"""
|
||||
mpi_spec = self.spec["mpi"]
|
||||
include_dirs = mpi_spec.headers.directories
|
||||
library_dirs = mpi_spec.libs.directories
|
||||
with open(cfg_fn, "w") as cfg:
|
||||
cfg.write("[mpi]\n")
|
||||
cfg.write("mpi_dir = {}\n".format(mpi_spec.prefix))
|
||||
cfg.write("mpicc = {}\n".format(mpi_spec.mpicc))
|
||||
cfg.write("mpicxx = {}\n".format(mpi_spec.mpicxx))
|
||||
cfg.write("\n")
|
||||
cfg.write("## define_macros =\n")
|
||||
cfg.write("## undef_macros =\n")
|
||||
cfg.write("include_dirs = {}\n".format(include_dirs))
|
||||
cfg.write("## libraries = mpi\n")
|
||||
cfg.write("library_dirs = {}\n".format(library_dirs))
|
||||
cfg.write("## runtime_library_dirs = %(mpi_dir)s/lib\n")
|
||||
cfg.write("\n")
|
||||
cfg.write("## extra_compile_args =\n")
|
||||
cfg.write("## extra_link_args =\n")
|
||||
cfg.write("## extra_objects =\n")
|
||||
|
||||
@run_after("install", when="@4:")
|
||||
def install_cfg(self):
|
||||
python_dir = join_path(self.prefix, python_platlib, "mpi4py")
|
||||
cfg_fn = join_path(python_dir, "mpi.cfg")
|
||||
if not os.path.isfile(cfg_fn):
|
||||
self.create_mpi_config_file(cfg_fn)
|
||||
|
Loading…
Reference in New Issue
Block a user