summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorteddy <teddy.chantrait@gmail.com>2024-11-29 20:28:21 +0100
committerGitHub <noreply@github.com>2024-11-29 13:28:21 -0600
commitbf5e6b4aafe5c0e6e86c98a0fd6fcb4f252f0aeb (patch)
tree196612b3ba84b379f2e9d0b668481b965336891a /var
parent9760089089aff60b6761d5eccf284d317ac50a0c (diff)
downloadspack-bf5e6b4aafe5c0e6e86c98a0fd6fcb4f252f0aeb.tar.gz
spack-bf5e6b4aafe5c0e6e86c98a0fd6fcb4f252f0aeb.tar.bz2
spack-bf5e6b4aafe5c0e6e86c98a0fd6fcb4f252f0aeb.tar.xz
spack-bf5e6b4aafe5c0e6e86c98a0fd6fcb4f252f0aeb.zip
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>
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/py-mpi4py/package.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/py-mpi4py/package.py b/var/spack/repos/builtin/packages/py-mpi4py/package.py
index c447e700a1..430e32c57b 100644
--- a/var/spack/repos/builtin/packages/py-mpi4py/package.py
+++ b/var/spack/repos/builtin/packages/py-mpi4py/package.py
@@ -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 @@ class PyMpi4py(PythonPackage):
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)