You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-python/h5py/files/h5py-2.5.0-mpi4py2.backport

56 lines
2.2 KiB

commit 364a77403199087168786234554f459e7d985063
Author: Lawrence Mitchell <lawrence.mitchell@imperial.ac.uk>
Date: Tue Nov 3 14:18:48 2015 +0000
setup: Support building with current mpi4py version
mpi4py migrated the mpi4py.mpi_c module to mpi4py.libmpi in April 2014.
After the release of v1.3.1 but before v2. Sniff this in setup
configure and import MPI types from the appropriate module in h5p.pyx,
to allow building with MPI on and modern mpi4py versions.
diff --git a/h5py/h5p.pyx b/h5py/h5p.pyx
index da175dd..8a1cbb0 100644
--- a/h5py/h5p.pyx
+++ b/h5py/h5p.pyx
@@ -25,7 +25,11 @@ from h5py import _objects
from ._objects import phil, with_phil
if MPI:
- from mpi4py.mpi_c cimport MPI_Comm, MPI_Info, MPI_Comm_dup, MPI_Info_dup, \
+ if MPI4PY_V2:
+ from mpi4py.libmpi cimport MPI_Comm, MPI_Info, MPI_Comm_dup, MPI_Info_dup, \
+ MPI_Comm_free, MPI_Info_free
+ else:
+ from mpi4py.mpi_c cimport MPI_Comm, MPI_Info, MPI_Comm_dup, MPI_Info_dup, \
MPI_Comm_free, MPI_Info_free
# Initialization
diff --git a/setup_build.py b/setup_build.py
index ccc0f27..e49a4e8 100644
--- a/setup_build.py
+++ b/setup_build.py
@@ -162,14 +162,22 @@ class h5py_build_ext(build_ext):
# Rewrite config.pxi file if needed
if not op.isfile(config_file) or config.rebuild_required:
with open(config_file, 'wb') as f:
+ if config.mpi:
+ import mpi4py
+ from distutils.version import StrictVersion
+ v2 = StrictVersion(mpi4py.__version__) > StrictVersion("1.3.1")
+ else:
+ v2 = False
s = """\
# This file is automatically generated by the h5py setup script. Don't modify.
DEF MPI = %(mpi)s
+DEF MPI4PY_V2 = %(mpi4py_v2)s
DEF HDF5_VERSION = %(version)s
DEF SWMR_MIN_HDF5_VERSION = (1,9,178)
"""
s %= {'mpi': bool(config.mpi),
+ 'mpi4py_v2': bool(v2),
'version': tuple(int(x) for x in config.hdf5_version.split('.'))}
s = s.encode('utf-8')
f.write(s)