From 2ad975760fcee5aca05a0a482c1c673979e38e9c Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Wed, 3 Jun 2015 23:50:59 +0200 Subject: [PATCH] Work around a bug in Cython with using my mpi4py --- python/libsharp/libsharp_mpi.pyx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/python/libsharp/libsharp_mpi.pyx b/python/libsharp/libsharp_mpi.pyx index 402b4f6..e819a77 100644 --- a/python/libsharp/libsharp_mpi.pyx +++ b/python/libsharp/libsharp_mpi.pyx @@ -1,10 +1,17 @@ -from mpi4py.MPI cimport Comm +cdef extern from "mpi.h": + ctypedef void *MPI_Comm + cdef extern from "Python.h": object PyLong_FromVoidPtr(void*) +cdef extern: + ctypedef class mpi4py.MPI.Comm [object PyMPICommObject]: + cdef MPI_Comm ob_mpi + cdef unsigned flags + # For compatibility with mpi4py <= 1.3.1 # Newer versions could use the MPI._addressof function -def _addressof(comm): +def _addressof(Comm comm): cdef void *ptr = NULL - ptr = &(comm).ob_mpi + ptr = &comm.ob_mpi return PyLong_FromVoidPtr(ptr)