[PyQt] Wrong install name in dynamic libraries

Colin McPhail colin.mcphail at mac.com
Thu Feb 6 19:44:06 GMT 2014

Platform - PyQt5.2 Qt5.2 Python 3.3.3 Mac OS X 10.9.1

The Mac OS X dynamic libraries installed in the site-packages directory by
the PyQt5 build system have incorrect install names recorded in them. For
example QtCore.so has an install name of 'libQtCore.dylib', as shown by
   otool -D QtCore.so

The reason for this is that each library is created as libQtxxx.dylib, copied
to Qtxxx.so and then copied to .../site-packages/PyQt5/Qtxxx.so.  The initial
link command doesn't specify an install name and so the terminal name of the
output library ('libQtxxx.dylib') is used by default.

This doesn't cause a problem in normal use of PyQt5.  However, a recent post
by David Cortesi indicated that attempts to freeze an application for
distribution using cx_freeze failed because cx_freeze could not locate
libQtxxx.dylib files.  Off-list I suggested that David manually correct the
install names in his site-packages/PyQt5 direcory (using install_name_tool
-id commands) and he has indicated that the cx_freeze process was then able to

Below are two patches, for PyQt-gpl-5.2/configure.py and
QScintilla-gpl-2.8/Python/configure.py respectively, that set each dynamic
library's install name to the full path of the library after installation.

*** configure_orig.py	2014-02-04 15:43:08.000000000 +0000
--- configure.py	2014-02-06 12:54:52.000000000 +0000
*** 2234,2239 ****
--- 2234,2240 ----
  macx {
      QMAKE_LFLAGS += "-undefined dynamic_lookup"
+     QMAKE_LFLAGS += "-install_name $$absolute_path($$PY_MODULE, $$target.path)"
*** configure_orig.py	2014-02-05 22:43:08.000000000 +0000
--- configure.py	2014-02-06 17:26:55.000000000 +0000
*** 747,752 ****
--- 747,753 ----
  macx {
      QMAKE_LFLAGS += "-undefined dynamic_lookup"
+     QMAKE_LFLAGS += "-install_name $$absolute_path($$PY_MODULE, $$target.path)"
      QMAKE_POST_LINK = $$QMAKE_POST_LINK$$escape_expand(\\\\n\\\\t)$$quote(install_name_tool -change libqscintilla2.%s.dylib %s/libqscintilla2.%s.dylib $$PY_MODULE)
  ''' % (QSCI_API_MAJOR, target_config.qsci_lib_dir, QSCI_API_MAJOR))

I have rerun a PyQt5 and QScintilla installation and have confirmed visually
that the expected install names are now present in the dynamic libraries
installed into site-packages. 

-- Colin McPhail

More information about the PyQt mailing list