[Pythonmac-SIG] py2app sip recipe and Qt plugins

Marc-Antoine Parent maparent at acm.org
Sat Sep 19 15:31:53 CEST 2009


Good day!
I was trying my hand at wrapping a PyQt application, and I stumbled on  
the plugin issue that seems to have plagued many here, where the  
plugins load another copy of the Qt frameworks, indicated as such:

On Mac OS X, you might be loading two sets of Qt binaries into the  
same process. Check that all plugins are compiled against the right Qt  
binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of  
binaries are being loaded.

I looked a bit at how to fix this, and here is what worked for me. I  
have not yet written code to automate this process; but this  
description may be useful to people willing to fix executables by hand.

a) copy the plugin directory from /Developer/Applications/Qt/plugins  
to dist/<application.app>/Contents/plugins

b) Create a file dist/<application.app>/Contents/Resources/qt.conf
with contents as follows:
[Paths]
qt_plugpath=plugins

The path is relative to Contents. Another path could be chosen, that  
could be more congenial to py2app.

c) Adjust the paths of the plugins with install_name_tool. Eg, from  
the shell:

find dist/<application.app>/Contents/plugins -type f -exec  
install_name_tool -change QtGui.framework/Versions/4/QtGui  
@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui  {} ';'
find dist/<application.app>/Contents/plugins -type f -exec  
install_name_tool -change QtGui.framework/Versions/4/QtCore  
@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore  {}  
';'
(and so on if you need QtWebKit etc.)

Cheers,
Marc-Antoine Parent



More information about the Pythonmac-SIG mailing list