[petsc-dev] petsc4py + Cython + DL_IMPORT/__imp_ ugliness

Aron Ahmadia aron at ahmadia.net
Wed Sep 25 16:55:26 CDT 2013


Has anybody successfully built petsc4py on a Windows box?  It looks like
some of the Cython logic is not quite right.

On Windows, Cython is trying to set the various functions in libpetsc4py.h
for external DLL import. This wouldn't be a problem, except these functions
are consumed *internally* by PETSc.pyx.

I'm not sure what the appropriate fix is here.  The current hack-patch is
to simply strip out the DL_IMPORT functions after Cythonizing:

I'm very welcome to better solutions.

BTW: petsc4py 3.4 tests are passing with the current fixes in maint, the
patch below, and the relocation of the seemingly randomly placed cyg*.dll
libraries.

A

diff -rupN src/src/libpetsc4py/libpetsc4py.h
src-fix-libpetsc4py-decls/src/libpetsc4py/libpetsc4py.h
--- src/src/libpetsc4py/libpetsc4py.h 2013-09-25 17:37:37.932555400 -0400
+++ src-fix-libpetsc4py-decls/src/libpetsc4py/libpetsc4py.h 2013-09-25
17:38:53.418590300 -0400
@@ -12,18 +12,18 @@
   #endif
 #endif

-__PYX_EXTERN_C DL_IMPORT(int) import_libpetsc4py(void);
-__PYX_EXTERN_C DL_IMPORT(PetscErrorCode) MatPythonGetContext(Mat, void **);
-__PYX_EXTERN_C DL_IMPORT(PetscErrorCode) MatPythonSetContext(Mat, void *);
-__PYX_EXTERN_C DL_IMPORT(PetscErrorCode) PCPythonGetContext(PC, void **);
-__PYX_EXTERN_C DL_IMPORT(PetscErrorCode) PCPythonSetContext(PC, void *);
-__PYX_EXTERN_C DL_IMPORT(PetscErrorCode) KSPPythonGetContext(KSP, void **);
-__PYX_EXTERN_C DL_IMPORT(PetscErrorCode) KSPPythonSetContext(KSP, void *);
-__PYX_EXTERN_C DL_IMPORT(PetscErrorCode) SNESPythonGetContext(SNES, void
**);
-__PYX_EXTERN_C DL_IMPORT(PetscErrorCode) SNESPythonSetContext(SNES, void
*);
-__PYX_EXTERN_C DL_IMPORT(PetscErrorCode) TSPythonGetContext(TS, void **);
-__PYX_EXTERN_C DL_IMPORT(PetscErrorCode) TSPythonSetContext(TS, void *);
-__PYX_EXTERN_C DL_IMPORT(PetscErrorCode) PetscPythonRegisterAll(void);
+__PYX_EXTERN_C int import_libpetsc4py(void);
+__PYX_EXTERN_C PetscErrorCode MatPythonGetContext(Mat, void **);
+__PYX_EXTERN_C PetscErrorCode MatPythonSetContext(Mat, void *);
+__PYX_EXTERN_C PetscErrorCode PCPythonGetContext(PC, void **);
+__PYX_EXTERN_C PetscErrorCode PCPythonSetContext(PC, void *);
+__PYX_EXTERN_C PetscErrorCode KSPPythonGetContext(KSP, void **);
+__PYX_EXTERN_C PetscErrorCode KSPPythonSetContext(KSP, void *);
+__PYX_EXTERN_C PetscErrorCode SNESPythonGetContext(SNES, void **);
+__PYX_EXTERN_C PetscErrorCode SNESPythonSetContext(SNES, void *);
+__PYX_EXTERN_C PetscErrorCode TSPythonGetContext(TS, void **);
+__PYX_EXTERN_C PetscErrorCode TSPythonSetContext(TS, void *);
+__PYX_EXTERN_C PetscErrorCode PetscPythonRegisterAll(void);

 #endif /* !__PYX_HAVE_API__libpetsc4py */
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20130925/26336e13/attachment.html>


More information about the petsc-dev mailing list