petsc4py: Cython 0.29.34 creating broken header and very different header layout
This issue was picked up in the context of FEniCS CI.
Cython recently released 0.29.34 (vs long standing 0.29.33) and it's creating very different (and some broken) headers for petsc4py.
[ 23%] Building CXX object CMakeFiles/cpp.dir/dolfinx/wrappers/dolfinx.cpp.o
In file included from /Users/jack.hale/fenicsx-main/src/dolfinx/python/dolfinx/wrappers/common.cpp:10:
In file included from /Users/jack.hale/fenicsx-main/src/dolfinx/python/dolfinx/wrappers/caster_petsc.h:9:
In file included from /Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/petsc4py.h:10:
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:411:151: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_Comm = __Pyx_ImportType(module, "petsc4py.PETSc", "Comm", sizeof(struct PyPetscCommObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscCommObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:414:157: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_Object = __Pyx_ImportType(module, "petsc4py.PETSc", "Object", sizeof(struct PyPetscObjectObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscObjectObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:417:157: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_Viewer = __Pyx_ImportType(module, "petsc4py.PETSc", "Viewer", sizeof(struct PyPetscViewerObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscViewerObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:420:157: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_Random = __Pyx_ImportType(module, "petsc4py.PETSc", "Random", sizeof(struct PyPetscRandomObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscRandomObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:423:157: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_Device = __Pyx_ImportType(module, "petsc4py.PETSc", "Device", sizeof(struct PyPetscDeviceObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscDeviceObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:426:178: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_DeviceContext = __Pyx_ImportType(module, "petsc4py.PETSc", "DeviceContext", sizeof(struct PyPetscDeviceContextObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscDeviceContextObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:429:145: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_IS = __Pyx_ImportType(module, "petsc4py.PETSc", "IS", sizeof(struct PyPetscISObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscISObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:432:154: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_LGMap = __Pyx_ImportType(module, "petsc4py.PETSc", "LGMap", sizeof(struct PyPetscLGMapObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscLGMapObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:435:145: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_SF = __Pyx_ImportType(module, "petsc4py.PETSc", "SF", sizeof(struct PyPetscSFObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscSFObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:438:148: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_Vec = __Pyx_ImportType(module, "petsc4py.PETSc", "Vec", sizeof(struct PyPetscVecObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscVecObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:441:154: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_Space = __Pyx_ImportType(module, "petsc4py.PETSc", "Space", sizeof(struct PyPetscSpaceObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscSpaceObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:444:166: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_DualSpace = __Pyx_ImportType(module, "petsc4py.PETSc", "DualSpace", sizeof(struct PyPetscDualSpaceObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscDualSpaceObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:447:145: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_FE = __Pyx_ImportType(module, "petsc4py.PETSc", "FE", sizeof(struct PyPetscFEObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscFEObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:450:151: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_Quad = __Pyx_ImportType(module, "petsc4py.PETSc", "Quad", sizeof(struct PyPetscQuadObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscQuadObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:453:160: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_Scatter = __Pyx_ImportType(module, "petsc4py.PETSc", "Scatter", sizeof(struct PyPetscScatterObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscScatterObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:456:160: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_Section = __Pyx_ImportType(module, "petsc4py.PETSc", "Section", sizeof(struct PyPetscSectionObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscSectionObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:459:148: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_Mat = __Pyx_ImportType(module, "petsc4py.PETSc", "Mat", sizeof(struct PyPetscMatObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscMatObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:462:184: error: expected expres
sion
__pyx_ptype_8petsc4py_5PETSc_MatPartitioning = __Pyx_ImportType(module, "petsc4py.PETSc", "MatPartitioning", sizeof(struct PyPetscMatPartitioningObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscMatPartitioningObject),
^
/Users/jack.hale/fenicsx-main/lib/python3.10/site-packages/petsc4py/include/petsc4py/../../PETSc_api.h:465:166: error: expected expression
__pyx_ptype_8petsc4py_5PETSc_NullSpace = __Pyx_ImportType(module, "petsc4py.PETSc", "NullSpace", sizeof(struct PyPetscNullSpaceObject), __PYX_GET_STRUCT_ALIGNMENT(struct PyPetscNullSpaceObject),
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
gmake[2]: *** [CMakeFiles/cpp.dir/build.make:104: CMakeFiles/cpp.dir/dolfinx/wrappers/common.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
This type of error can be recreated on different platforms using various versions of PETSc (3.19.0 and 3.18.x). The directory structure between an old working petsc4py (1) and this newly cythonised petsc4py (2) is also quite different:
(1) include/
PETSc.pxd __init__.pyx petsc4py.PETSc.h petsc4py.h
__init__.pxd numpy.h petsc4py.PETSc_api.h petsc4py.i
(2) include/../
PETSc.h PETSc.py __init__.py __pycache__ lib
PETSc.pxd PETSc_api.h __main__.py include
Edited by Jack S. Hale