SIP must be installed before building and using PyQt4. You can get the latest release of the SIP source code from http://www.riverbankcomputing.com/software/sip/download.
The SIP documentation can be found at http://pyqt.sourceforge.net/Docs/sip4/.
You can get the latest release of the GPL version of the PyQt4 source code from http://www.riverbankcomputing.com/software/pyqt/download.
If you are using the commercial version of PyQt4 then you should use the download instructions which were sent to you when you made your purchase. You must also download your license file.
After unpacking the source package (either a .tar.gz or a .zip file depending on your platform) you should then check for any README files that relate to your platform.
If you are using the commercial version of PyQt4 then you must copy your license file to the sip directory.
You need to make sure your environment variables are set properly for your development environment.
In order to configure the build of PyQt4 you need to run either the configure-ng.py or the configure.py script.
configure.py is the original configuration script that uses the build system of SIP v4 (i.e. the sip.sipconfig module). It will be supported for the life of PyQt4.
configure-ng.py is the new configuration script that uses Qt’s qmake program to do all the heavy lifting. It has the following advantages:
Users are encouraged to switch to using configure-ng.py in order to ease the future transition to SIP v5 and/or PyQt5.
New in version 4.10.1.
The configure-ng.py script is used to configure PyQt4 as follows:
python configure-ng.py
This assumes that the Python interpreter is on your path. Something like the following may be appropriate on Windows:
c:\python33\python configure-ng.py
If you have multiple versions of Python installed then make sure you use the interpreter for which you wish to build PyQt4 for.
The full set of command line options is:
Normally Qt is checked to see if it has been built as shared libraries. Some Linux distributions configure their Qt builds to make this check unreliable. This option ignores the result of the check and assumes that Qt has been built as shared libraries.
The pyuic4, pyrcc4 and pylupdate4 utilities will be installed in the directory <DIR>.
The C++ source files for a Python module will be concatenated. This results in significantly reduced compilation times. Most, but not all, C++ compilers can handle the large files that result. See also the --concatenate-split option.
If the --concatenate option is used to concatenate the C++ source files then this option determines how many files are created. The default is 1.
<FILE> contains the configuration of the PyQt4 build to be used instead of dynamically introspecting the system and is used when cross-compiling. The format of <FILE> will be documented in a later version when cross-compilation is fully supported.
Using this confirms that you accept the terms of the PyQt4 license.
Normally each PyQt4 module (except for the Qt module) is linked against the corresponding Qt library. This option creates a module called _qt which is linked against all the required Qt libraries and the other modules are stub modules that populate their module dictionaries from this one. This is useful when linking against static Qt libraries to eliminate the need to distribute the Qt libraries while minimising the memory footprint of the PyQt4 modules.
The dbus-python.h header file of the dbus-python package can be found in the directory <DIR>/dbus.
The PyQt4 modules will be built with debugging symbols. On Windows this requires that a debug version of Python is installed.
The Python plugin for Qt Designer will be installed in the directory <DIR>.
The PyQt4 Python package will be installed in the directory <DIR>. The default is the Python installation’s site-packages directory. If you use this option then the PYTHONPATH environment variable must include <DIR>.
Normally all PyQt4 modules are enabled and are built if the corresponding Qt library can be found. Using this option only those modules specifically enabled will be checked for and built. The option may be specified any number of times.
Display a help message.
All Qt v4 features that have been deprecated in Qt v5 will be disabled. This is useful when porting PyQt4 applications to PyQt5.
The Qt Designer plugin will not be built.
The PyQt4 modules will not contain automatically generated docstrings.
The PyQt4.api QScintilla API file is not installed even if QScintilla does appear to be installed.
The .sip files for the PyQt4 modules will not be installed.
Normally the header comments of each generated C/C++ source file includes a timestamp corresponding to when the file was generated. This option suppresses the inclusion of the timestamp.
If Qt has been built as static libraries then the static plugin <PLUGIN> will be linked with the appropriate PyQt4 module. The option may be specified any number of times.
On certain platforms the size of PyQt4 modules can be significantly reduced by redefining the C++ protected keyword as public during compilation. This option enables this behaviour and is the default on Linux and MacOS/X.
The default redefinition of protected to public during compilation on Linux and MacOS/X is disabled.
<FILE> is the name of the Python interpreter used in the pyuic4 wrapper. The default is platform dependent.
Qt’s qmake program is used to determine how your Qt installation is laid out. Normally qmake is found on your PATH. This option can be used to specify a particular instance of qmake to use. This option is not available on Windows where qmake must be on PATH.
The PyQt4.api QScintilla API file is installed even if QScintilla does not appear to be installed. This option is implied if the --qsci-api-destdir option is specified.
The QScintilla API file will be installed in the python subdirectory of the api subdirectory of the directory <DIR>.
The sip program is used to generate PyQt4’s C++ source code. Normally sip is found on your PATH. This option can be used to specify a particular instance of sip to use.
The sip.h header file can be found in the directory <DIR>.
The .sip files for the PyQt4 modules will be installed in the directory <DIR>.
The argument -spec SPEC will be passed to qmake. The default behaviour is platform specific. On Windows configure-ng.py will choose the value that is correct for the version of Python that is being used. (However if you have built Python yourself then you may need to explicitly specify <SPEC>.) On MacOS configure-ng.py will try and avoid macx-xcode if possible.)
The PyQt4 modules will be built as static libraries. This is useful when building a custom interpreter with the PyQt4 modules built in to the interpreter.
The generated PyQt4 modules contain additional tracing code that is enabled using SIP’s sip.settracemask() function.
The checking of signed Python interpreters using the VendorID package is enabled. See also the --vendorid-incdir and --vendorid-libdir options and Deploying Commercial PyQt4 Applications.
The header file of the VendorID package can be found in the directory <DIR>.
The library of the VendorID package can be found in the directory <DIR>.
Compiler commands and any output issued during configuration is displayed instead of being suppressed. Use this if configure-ng.py is having problems to see what exactly is going wrong.
Display the PyQt4 version number.
Any remaining command line arguments are expected to be in the form name=value or name+=value. Such arguments are added to any qmake .pro file created by configure-ng.py.
The configure.py script is used to configure PyQt4 as follows:
python configure.py
This assumes that the Python interpreter is on your path. Something like the following may be appropriate on Windows:
c:\python33\python configure.py
If you have multiple versions of Python installed then make sure you use the interpreter for which you wish to build PyQt4 for.
The full set of command line options is:
Normally Qt is checked to see if it has been built as shared libraries. Some Linux distributions configure their Qt builds to make this check unreliable. This option ignores the result of the check and assumes that Qt has been built as shared libraries.
The pyuic4, pyrcc4 and pylupdate4 utilities will be installed in the directory <DIR>.
The C++ source files for a Python module will be concatenated. This results in significantly reduced compilation times. Most, but not all, C++ compilers can handle the large files that result. See also the --concatenate-split option.
If the --concatenate option is used to concatenate the C++ source files then this option determines how many files are created. The default is 1.
Using this confirms that you accept the terms of the PyQt4 license.
Normally each PyQt4 module (except for the Qt module) is linked against the corresponding Qt library. This option creates a module called _qt which is linked against all the required Qt libraries and the other modules are stub modules that populate their module dictionaries from this one. This is useful when linking against static Qt libraries to eliminate the need to distribute the Qt libraries while minimising the memory footprint of the PyQt4 modules.
The dbus-python.h header file of the dbus-python package can be found in the directory <DIR>/dbus.
The PyQt4 modules will be built with debugging symbols. On Windows this requires that a debug version of Python is installed.
The PyQt4 Python package will be installed in the directory <DIR>. The default is the Python installation’s site-packages directory. If you use this option then the PYTHONPATH environment variable must include <DIR>.
Normally all PyQt4 modules are enabled and are built if the corresponding Qt library can be found. Using this option only those modules specifically enabled will be checked for and built. The option may be specified any number of times.
Display a help message.
All Qt v4 features that have been deprecated in Qt v5 will be disabled. This is useful when porting PyQt4 applications to PyQt5.
The Qt Designer plugin will not be built.
The PyQt4 modules will not contain automatically generated docstrings.
The PyQt4.api QScintilla API file is not installed even if QScintilla does appear to be installed.
The .sip files for the PyQt4 modules will not be installed.
Normally the header comments of each generated C/C++ source file includes a timestamp corresponding to when the file was generated. This option suppresses the inclusion of the timestamp.
If Qt has been built as static libraries then the static plugin <PLUGIN> will be linked with the appropriate PyQt4 module. The option may be specified any number of times.
The Qt Designer plugin that manages plugins implemented in Python will be installed in the designer subdirectory of the directory <DIR>.
On certain platforms the size of PyQt4 modules can be significantly reduced by redefining the C++ protected keyword as public during compilation. This option enables this behaviour and is the default on Linux and MacOS/X.
The default redefinition of protected to public during compilation on Linux and MacOS/X is disabled.
Qt’s qmake program is used to determine how your Qt installation is laid out. Normally qmake is found on your PATH. This option can be used to specify a particular instance of qmake to use. This option is not available on Windows.
The PyQt4.api QScintilla API file is installed even if QScintilla does not appear to be installed. This option is implied if the --qsci-api-destdir option is specified.
The QScintilla API file will be installed in the python subdirectory of the api subdirectory of the directory <DIR>.
The .sip files for the PyQt4 modules will be installed in the directory <DIR>.
The PyQt4 modules will be built as static libraries. This is useful when building a custom interpreter with the PyQt4 modules built in to the interpreter.
The generated PyQt4 modules contain additional tracing code that is enabled using SIP’s sip.settracemask() function.
When pyuic4 calls the Python interpreter on MacOS it will be run using the architecture <ARCH>. See the section Configuring SIP and PyQt4 for MacOS.
The checking of signed Python interpreters using the VendorID package is enabled. See also the --vendorid-incdir and --vendorid-libdir options and Deploying Commercial PyQt4 Applications.
The header file of the VendorID package can be found in the directory <DIR>.
The library of the VendorID package can be found in the directory <DIR>.
Compiler commands and any output issued during configuration is displayed instead of being suppressed. Use this if configure.py is having problems to see what exactly is going wrong.
Display the PyQt4 version number.
Note that this section only applies if you are using the configure.py script to configure PyQt4. The configure-ng.py script leaves it to Qt’s qmake program to handle the details. configure-ng.py does not support the creation of universal binaries.
Building applications for MacOS can be a complex process. Typically the following need to be taken into account:
If you are using a binary installer for Python and/or Qt then you also need to consider how they have been built regarding the above, and what bugs they have.
SIP’s and PyQt4’s configure.py scripts provide the necessary command line options to allow the correct configurations to be specified - the trick is to work out which options to use depending on the versions of Python and Qt you have installed.
SIP provides the following command line options to its configure.py script.
PyQt4 provides the --use-arch option that specifies which architecture certain PyQt4 tools (actually only pyuic4 at the moment) will use when running Python. For example, if your Qt installation is 32 bits, and your Python installation is 32 bits and 64 bits then you will need to specify --use-arch i386 to ensure that pyuic4 runs the 32 bit version of Python.
The next step is to build PyQt4 by running your platform’s make command. For example:
make
The final step is to install PyQt4 by running the following command:
make install
(Depending on your system you may require root or administrator privileges.)
This will install the various PyQt4 components.