python header puzzle

Marco Atzeri
Fri Jan 1 18:33:03 GMT 2021

Hi All,

trying to build postgresql 12.X with python3 interface, I hit an
interesting issue

all headers

are including

#                       if defined(__CYGWIN__)
#                               define PyMODINIT_FUNC 
__declspec(dllexport) PyObject*
#                       else /* __CYGWIN__ */
#                               define PyMODINIT_FUNC PyObject*
#                       endif /* __CYGWIN__ */

and the postgresql python 3 interface has in the code and the header

the following lines:

PyMODINIT_FUNC PyInit_plpy(void);

PyMODINIT_FUNC PyInit_plpy(void)...

Unfortunately the shared lib produced is crippled and does not
export correctly the symbols.

Changing the lines in

extern PyObject* PyInit_plpy(void);

PyObject* PyInit_plpy(void)..

solves the problem and pass all tests.

At first glance the Python headers seem the wrong one; the postgresql
code has no special  CYGWIN handling in that point, just the note

  * Must have external linkage, because PyMODINIT_FUNC does dllexport on
  * Windows-like platforms.

Comments ?
Any one seeing similar issue with Python3 code ?

For what I see the usage of PyMODINIT_FUNC is very limited
only python-cffi and python-lxml seem to use it in their headers



More information about the Cygwin mailing list