python header puzzle

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

python header puzzle

Cygwin list mailing list
Hi All,

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

all headers
/usr/include/python{3.6-3.8}/pyport.h

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
src/pl/plpython/plpy_plpymodule.{h,c}

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


Regards

Marco
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: python header puzzle

Cygwin list mailing list
On Fri, 1 Jan 2021 19:33:03 +0100, Marco Atzeri via Cygwin

> Hi All,
>
> trying to build postgresql 12.X with python3 interface, I hit an
> interesting issue
>
> all headers
> /usr/include/python{3.6-3.8}/pyport.h
>
> 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
> src/pl/plpython/plpy_plpymodule.{h,c}
>
> 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

How about like this, though it should need more refinements.

A cygport file is attached, or placed at
https://github.com/cygwin-lem/cygwin-pkg/tree/w_postgresql-12.5-1/postgresql

Regards,

Lem


--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

postgresql.cygport (11K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: python header puzzle

Cygwin list mailing list
On Sat, 02 Jan 2021 07:30:05 +0900, Lemures Lemniscati

> On Fri, 1 Jan 2021 19:33:03 +0100, Marco Atzeri via Cygwin
> > Hi All,
> >
> > trying to build postgresql 12.X with python3 interface, I hit an
> > interesting issue
> >
> > all headers
> > /usr/include/python{3.6-3.8}/pyport.h
> >
> > 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
> > src/pl/plpython/plpy_plpymodule.{h,c}
> >
> > 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
>
>
> How about like this, though it should need more refinements.
>
> A cygport file is attached, or placed at
> https://github.com/cygwin-lem/cygwin-pkg/tree/w_postgresql-12.5-1/postgresql
>
I'm sorry. I was wrong.

Regards,

Lem
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: python header puzzle

Cygwin list mailing list
On 02.01.2021 03:13, Lemures Lemniscati via Cygwin wrote:
> On Sat, 02 Jan 2021 07:30:05 +0900, Lemures Lemniscati
>> On Fri, 1 Jan 2021 19:33:03 +0100, Marco Atzeri via Cygwin
>>> Hi All,
>>>
>>> trying to build postgresql 12.X with python3 interface, I hit an
>>> interesting issue
>>>

>>
>> A cygport file is attached, or placed at
>> https://github.com/cygwin-lem/cygwin-pkg/tree/w_postgresql-12.5-1/postgresql
>>
> I'm sorry. I was wrong.
>
> Regards,
>
> Lem

Hi Lem,
Maybe next time; just remember to trim replies.

I am currently using python-cffi to see is I should modify
PyMODINIT_FUNC in the python code or in the packages.

There are other additional puzzling cripped DLL cases.

I am using
https://www.dependencywalker.com/
to verify if the symbol list is correcly exported. When crippled there
is usually only one symbol

Regards
Marco

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple