abelcarreras / posym

Point symmetry analysis tool for theoretical chemistry objects
MIT License
17 stars 4 forks source link

compilation issue with gcc #9

Closed ledragna closed 2 months ago

ledragna commented 3 months ago

Hi,

I wanted to try your really interesting library but I faced problems installing it both via pypi both cloning the git repository.

In both the cases the process stops when compiling the c code:

gcc -fno-strict-overflow -DNDEBUG -g -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -ffat-lto-objects -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -fPIC -I/usr/lib/python3.12/site-packages/numpy/_core/include -I/home/marco/virtual-env/chem/include -I/usr/include/python3.12 -c c/integrals.c -o build/temp.linux-x86_64-cpython-312/c/integrals.o -std=c99 -fopenmp
      In file included from /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1909,
                       from /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarrayobject.h:12,
                       from /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/arrayobject.h:5,
                       from c/integrals.c:5:
      /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
         17 | #warning "Using deprecated NumPy API, disable it with " \
            |  ^~~~~~~
      c/integrals.c: In function ‘PolyProduct’:
      c/integrals.c:215:50: error: passing argument 1 of ‘PyArray_DATA’ from incompatible pointer type [-Wincompatible-pointer-types]
        215 |     double *polyCoeff    = (double*)PyArray_DATA(polyCoeffArray);
            |                                                  ^~~~~~~~~~~~~~
            |                                                  |
            |                                                  PyObject * {aka struct _object *}
      /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1508:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
       1508 | PyArray_DATA(const PyArrayObject *arr)
            |              ~~~~~~~~~~~~~~~~~~~~~^~~
      c/integrals.c:216:50: error: passing argument 1 of ‘PyArray_DATA’ from incompatible pointer type [-Wincompatible-pointer-types]
        216 |     double *polyCoeff2   = (double*)PyArray_DATA(polyCoeff2Array);
            |                                                  ^~~~~~~~~~~~~~~
            |                                                  |
            |                                                  PyObject * {aka struct _object *}
      /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1508:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
       1508 | PyArray_DATA(const PyArrayObject *arr)
            |              ~~~~~~~~~~~~~~~~~~~~~^~~
      c/integrals.c:218:37: error: passing argument 1 of ‘PyArray_DIM’ from incompatible pointer type [-Wincompatible-pointer-types]
        218 |     int  maxLim1 = (int)PyArray_DIM(polyCoeffArray, 0);
            |                                     ^~~~~~~~~~~~~~
            |                                     |
            |                                     PyObject * {aka struct _object *}
      /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1532:34: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
       1532 | PyArray_DIM(const PyArrayObject *arr, int idim)
            |             ~~~~~~~~~~~~~~~~~~~~~^~~
      c/integrals.c:219:37: error: passing argument 1 of ‘PyArray_DIM’ from incompatible pointer type [-Wincompatible-pointer-types]
        219 |     int  maxLim2 = (int)PyArray_DIM(polyCoeff2Array, 0);
            |                                     ^~~~~~~~~~~~~~~
            |                                     |
            |                                     PyObject * {aka struct _object *}
      /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1532:34: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
       1532 | PyArray_DIM(const PyArrayObject *arr, int idim)
            |             ~~~~~~~~~~~~~~~~~~~~~^~~
      c/integrals.c: In function ‘GaussianIntegral’:
      c/integrals.c:290:50: error: passing argument 1 of ‘PyArray_DATA’ from incompatible pointer type [-Wincompatible-pointer-types]
        290 |     double *polyCoeff    = (double*)PyArray_DATA(polyCoeffArray);
            |                                                  ^~~~~~~~~~~~~~
            |                                                  |
            |                                                  PyObject * {aka struct _object *}
      /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1508:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
       1508 | PyArray_DATA(const PyArrayObject *arr)
            |              ~~~~~~~~~~~~~~~~~~~~~^~~
      c/integrals.c:291:46: error: passing argument 1 of ‘PyArray_DATA’ from incompatible pointer type [-Wincompatible-pointer-types]
        291 |     double *center   = (double*)PyArray_DATA(centerArray);
            |                                              ^~~~~~~~~~~
            |                                              |
            |                                              PyObject * {aka struct _object *}
      /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1508:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
       1508 | PyArray_DATA(const PyArrayObject *arr)
            |              ~~~~~~~~~~~~~~~~~~~~~^~~
      c/integrals.c:293:35: error: passing argument 1 of ‘PyArray_DIM’ from incompatible pointer type [-Wincompatible-pointer-types]
        293 |     int maxLim = (int)PyArray_DIM(polyCoeffArray, 0);
            |                                   ^~~~~~~~~~~~~~
            |                                   |
            |                                   PyObject * {aka struct _object *}
      /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1532:34: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
       1532 | PyArray_DIM(const PyArrayObject *arr, int idim)
            |             ~~~~~~~~~~~~~~~~~~~~~^~~
      c/integrals.c: In function ‘GaussianIntegral2’:
      c/integrals.c:394:50: error: passing argument 1 of ‘PyArray_DATA’ from incompatible pointer type [-Wincompatible-pointer-types]
        394 |     double *polyCoeff    = (double*)PyArray_DATA(polyCoeffArray);
            |                                                  ^~~~~~~~~~~~~~
            |                                                  |
            |                                                  PyObject * {aka struct _object *}
      /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1508:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
       1508 | PyArray_DATA(const PyArrayObject *arr)
            |              ~~~~~~~~~~~~~~~~~~~~~^~~
      c/integrals.c:395:46: error: passing argument 1 of ‘PyArray_DATA’ from incompatible pointer type [-Wincompatible-pointer-types]
        395 |     double *center   = (double*)PyArray_DATA(centerArray);
            |                                              ^~~~~~~~~~~
            |                                              |
            |                                              PyObject * {aka struct _object *}
      /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1508:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
       1508 | PyArray_DATA(const PyArrayObject *arr)
            |              ~~~~~~~~~~~~~~~~~~~~~^~~
      c/integrals.c:397:35: error: passing argument 1 of ‘PyArray_DIM’ from incompatible pointer type [-Wincompatible-pointer-types]
        397 |     int maxLim = (int)PyArray_DIM(polyCoeffArray, 0);
            |                                   ^~~~~~~~~~~~~~
            |                                   |
            |                                   PyObject * {aka struct _object *}
      /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1532:34: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
       1532 | PyArray_DIM(const PyArrayObject *arr, int idim)
            |             ~~~~~~~~~~~~~~~~~~~~~^~~
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

My system: GCC: gcc version 14.1.1 20240522 (GCC) python: 3.12.4 (main, Jun 7 2024, 06:33:07) [GCC 14.1.1 20240522] on linux cython: 3.0.10-5 numpy: 2.0.0-1

However it installs successfully in colab, do you think this may related with the newer gcc version?

Thanks for your help

Marco

abelcarreras commented 3 months ago

Yeah, it is very possible. Have you tried to add -Wincompatible-pointer-types option to setup.py as a temporal solution? meanwhile I will try to fix this.

abelcarreras commented 3 months ago

Also in pypi I uploaded wheels up to python 3.11. If you can prepare a python environment with this python version and install posym from pypi it will probably work.

ledragna commented 3 months ago

Hi Abel, thanks for the quick reply The first option -Wincompatible-pointer-types didn't worked for me. I'll try the second and I'll let you know. Actually, I think this is probably related to the new numpy C-API

abelcarreras commented 3 months ago

Thanks for the info. I will try to find some time to check all this out. It is quite annoying because I have several codes that will need to be updated to support both numpy 1.x and 2.x.

abelcarreras commented 2 months ago

I fixed the issue and now It should compile with the latest version of numpy. Just waiting for github actions to deploy to pypi.

ledragna commented 2 months ago

Hi, sorry, I freshly cloned the repository and retried to compile it, but I still got errors. Am I missing something? compilation_out.log

abelcarreras commented 2 months ago

Ok, I fixed the other c file. Can you try to compile it again?

ledragna commented 2 months ago

OK I confirm that it compiles and works perfectly now. Thanks!

abelcarreras commented 2 months ago

Great! I’m closing this issue then