[PyQt] PyQt / SIP from an embedded Python interpreter

Johan Thelin johan.thelin at pelagicore.com
Mon Jun 10 12:59:01 BST 2013


Hi,

On 8 June 2013 11:00, Phil Thompson <phil at riverbankcomputing.com> wrote:
> On Fri, 7 Jun 2013 23:44:17 +0200, Johan Thelin
> <johan.thelin at pelagicore.com> wrote:
>> Hi,
>>
>> I've been experimenting with using PyQt and SIP from a Python
>> interpreter embedded into a larger C++ application. I do this on Linux
>> (Kubuntu 13.04), Qt 5 and PyQt/SIP from last Wednesday (June 5th).
>> This gives me an unresolved symbol, _Py_NoneStruct, when importing
>> PyQt5.QtCore. However, adding -lpython2.7 to sip and QtCore, it works.
>> I guess the import statement does a dlopen, and it fails to resolve
>> the symbols, despite them being linked into my host application for
>> some odd reason.
>>
>> So, to the point. Am I doing something wrong here? Should things just
>> work? I've tried the -Wl,-E and -rdynamic, which was what Google
>> indicated could help. Alas, no luck with them.
>
> You could look at how the Designer plugin is built as that is doing
> something similar.
>
>> If I'm not doing something wrong, do you want my patches to SIP and
> PyQt5?
>
> Always happy to consider patches.

I've attached the patch that I've applied to PyQt5 snapshot. It relies
on pkg-config, which, imho, is the right way to do it, but adds a
build-time dependency to PyQt. The same effect could be achieved by
hardcoding the LIBS variable to include -lpython2.7.

As for sip, I've successfully built it after having configured it with
a "LIBS+=-lpython2.7". Now the import works flawlessly, even from my
embedded interpretor.

Cheers,

Johan Thelin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pyqt-pkgconfig-python.patch
Type: application/octet-stream
Size: 2861 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20130610/db2032bc/attachment.obj>


More information about the PyQt mailing list