[petsc-users] Issues Compiling petsc4py with Cython

maitri ksh maitri.ksh at gmail.com
Tue Jun 25 13:35:29 CDT 2024


I am currently working on integrating petsc4py, but I am encountering
persistent compilation issues related to Cython. Below are the details of
my setup and the errors I am facing. I would greatly appreciate any
assistance or guidance on how to resolve these issues.
System Configuration:

   - *PETSc Architecture*: linux-gnu-c-debug
   - *Python Environment*: Python 3.6 (virtual environment)
   - *Cython Version*: 3.0.10
   - *Compiler*: /gcc11.2/bin/gcc

 During the build process, I received multiple warnings and errors related
to the use of noexcept, nogil, and except in function declarations. Here
are some of the specific errors:

cythonizing 'petsc4py.PETSc.pyx' -> 'petsc4py.PETSc.c'
warning: petsc4py.PETSc.pyx:1:0: Dotted filenames ('petsc4py.PETSc.pyx')
are deprecated. Please use the normal Python package directory layout.
/home/maitri.ksh/Maitri/petsc/petsc4py/myenv/lib64/python3.6/site-packages/Cython/Compiler/Main.py:381:
FutureWarning: Cython directive 'language_level' not set, using '3str' for
now (Py3). This has changed from earlier releases! File:
include/petsc4py/PETSc.pxd
  tree = Parsing.p_module(s, pxd, full_module_name)
warning: PETSc/PETSc.pyx:53:48: The keyword 'nogil' should appear at the
end of the function signature line. Placing it before 'except' or
'noexcept' will be disallowed in a future version of Cython.
warning: PETSc/petscvec.pxi:406:79: The keyword 'nogil' should appear at
the end of the function signature line. Placing it before 'except' or
'noexcept' will be disallowed in a future version of Cython.
warning: PETSc/petscvec.pxi:411:79: The keyword 'nogil' should appear at
the end of the function signature line. Placing it before 'except' or
'noexcept' will be disallowed in a future version of Cython.
...

Error compiling Cython file:
...
PETSc/petscobj.pxi:91:29: Cannot assign type 'int (void *) except? -1
nogil' to 'int (*)(void *) noexcept'. Exception values are incompatible.
Suggest adding 'noexcept' to the type of 'PetscDelPyDict'.
...
PETSc/cyclicgc.pxi:34:20: Cannot assign type 'int (PyObject *, visitproc,
void *) except? -1' to 'traverseproc *'. Exception values are incompatible.
Suggest adding 'noexcept' to the type of 'tp_traverse'.
...
PETSc/cyclicgc.pxi:35:20: Cannot assign type 'int (PyObject *) except? -1'
to 'inquiry *'. Exception values are incompatible. Suggest adding
'noexcept' to the type of 'tp_clear'.
...
PETSc/PETSc.pyx:351:17: Cannot assign type 'void (void) except * nogil' to
'void (*)(void) noexcept'. Exception values are incompatible. Suggest
adding 'noexcept' to the type of 'finalize'.
error: Cython failure: 'petsc4py.PETSc.pyx' -> 'petsc4py.PETSc.c'

Any advice on building petsc4py in environments similar to mine would be
greatly appreciated.
Thanks,
Maitri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240625/764dbe2d/attachment.html>


More information about the petsc-users mailing list