[petsc-users] Issues Compiling petsc4py with Cython

Stefano Zampini stefano.zampini at gmail.com
Wed Jun 26 07:40:11 CDT 2024


> It was a version incompatibility issue, resolved by configuring it with
petsc.

Note that "configuring with PETSc" is not a standard Python installation
procedure.
You should be able to install it in your virtual environment by just doing

$ ... activate venv ....
$ cd src/binding/petsc4py
$ PETSC_DIR=... ; PETSC_ARCH=....; pip install .

see also https://urldefense.us/v3/__https://petsc.org/release/petsc4py/install.html__;!!G_uCfscf7eWS!YOhounZLijkMQ6SoKMm5OyCugdS8yKtXQk2bpNiYOjsdPUTHQ3ceL1eZnBJM23hEv1qL6F9eyGtWgoGV_Gqu4mZKXuJJWGQ$ 

Il giorno mer 26 giu 2024 alle ore 14:30 maitri ksh <maitri.ksh at gmail.com>
ha scritto:

> It was a version incompatibility issue, resolved by configuring it with
> petsc. Thank you stefano & satish. On Wed, Jun 26, 2024 at 12: 34 AM Satish
> Balay <balay. anl@ fastmail. org> wrote: Best to get latest petsc and
> build petsc4py along
> ZjQcmQRYFpfptBannerStart
> This Message Is From an External Sender
> This message came from outside your organization.
>
> ZjQcmQRYFpfptBannerEnd
> It was a version incompatibility issue, resolved by configuring it with
> petsc. Thank you stefano & satish.
>
> On Wed, Jun 26, 2024 at 12:34 AM Satish Balay <balay.anl at fastmail.org>
> wrote:
>
>> Best to get latest petsc and build petsc4py along with petsc:
>>
>> For example:
>>
>> balay at petsc-gpu-02:/scratch/balay$ wget -q
>> https://urldefense.us/v3/__https://web.cels.anl.gov/projects/petsc/download/release-snapshots/petsc-3.21.2.tar.gz__;!!G_uCfscf7eWS!YOhounZLijkMQ6SoKMm5OyCugdS8yKtXQk2bpNiYOjsdPUTHQ3ceL1eZnBJM23hEv1qL6F9eyGtWgoGV_Gqu4mZKbmitMG8$ 
>> <https://urldefense.us/v3/__https://web.cels.anl.gov/projects/petsc/download/release-snapshots/petsc-3.21.2.tar.gz__;!!G_uCfscf7eWS!ZtQZK7hSb7b0O7qL1NxuDxYo3aNcfvkMEs6i_bMC-NNUYojWqG8zVItjnY-Kvihf1GDSMdRoUuj7yOs32AUG7ysB$>
>> balay at petsc-gpu-02:/scratch/balay$ tar -xf petsc-3.21.2.tar.gz
>> balay at petsc-gpu-02:/scratch/balay$ cd petsc-3.21.2/
>> balay at petsc-gpu-02:/scratch/balay/petsc-3.21.2$ ./configure
>> --download-mpich --download-fblaslapack --download-mpi4py --with-petsc4py=1
>> && make && make check && make petsc4pytest
>>
>> =============================================================================================
>>                          Configuring PETSc to compile on your system
>>
>> =============================================================================================
>> <snip>
>> testPlaceArray (test_vec.TestVecShared) ... ok
>> testPlaceArray (test_vec.TestVecShared) ... ok
>> <snip>
>> Ran 6154 tests in 134.314s
>> OK
>> =====================================
>> balay at petsc-gpu-02:/scratch/balay/petsc-3.21.2$
>>
>>
>> Satish
>>
>> On Tue, 25 Jun 2024, Stefano Zampini wrote:
>>
>> > Which version of petsc4py is it?
>> >
>> > Il giorno mar 25 giu 2024 alle ore 20:35 maitri ksh <
>> maitri.ksh at gmail.com>
>> > ha scritto:
>> >
>> > > 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
>> > > ZjQcmQRYFpfptBannerStart
>> > > This Message Is From an External Sender
>> > > This message came from outside your organization.
>> > >
>> > > ZjQcmQRYFpfptBannerEnd
>> > >
>> > > 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
>> > >
>> >
>> >
>> >
>>
>>

-- 
Stefano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240626/67060902/attachment-0001.html>


More information about the petsc-users mailing list