Note: WCL stands for Windows Command Line in this wiki page.
Given the software stack already present in ParaView's installers for Windows, adding PyQt4 to the software stack is a useful toolkit for using along with Python and VTK. Nonetheless, beware to not use PyQt4 directly from within ParaView, since it's very likely to lead to a crash.
This page focuses on Windows only, because these software stacks are usually already available on Linux Distributions and possibly for Mac OS X. Another useful note is that there is another project named Python(x,y) which provides a more complete Python-based software stack; the only issue is that even though it provides VTK and PyQt4, it does not provide ParaView.
Given that we want to add PyQt4 to the software stack in ParaView 4.1.0, there are 3 requirements we need to build PyQt4:
This may seem strange that ParaView 4.1.0 itself isn't necessary, but the idea here is that PyQt4 only needs to be built with the same MSVC, Python and Qt versions as ParaView 4.1.0 was built.
Advice: if you need to build both the 32 and 64-bit builds, then install each Python version in separate folders, for example:
C:\Python27\Win32
C:\Python27\Win64
In additon, we'll be assuming on this wiki page that Qt 4.8.2 is installed in the following folders:
C:\Qt\4.8.2
C:\Qt\4.8.2_x64
After installing all of the requirements (don't forget that 32 and/or 64-bit architectures have to be installer mostly separately), begin creating the development environment for building and installing PyQt4:
W:\PyQt4-sandbox
W:\PyQt4-sandbox\PyQt4-Qt4.8.2-Python2.7.3-win64
Now this is a somewhat tricy part, because we have to prepare a Windows Command Line (WCL) environment with all of the necessary tools for building SIP and PyQt4. The instructions will be given in separate subsections:
First you need to find the batch file that starts up the WCL environment with MSVC 2008 32-bit. For example, at C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin
you should be able to find the batch file vcvars32.bat
, but more specifically you can find also there the Windows shortcut file Visual Studio 2008 Command Prompt
. Double-click on that shortcut file and it will start a new WCL with the necessary MSVC 2008 building tools ready to be used.
Now, in this WCL we need to activate 2 additional environments: Qt and Python. To activate Qt, it should be as simple as running these commands:
cd C:\Qt\4.8.2
call QtVars.bat
Next, to activate Python, run these commands:
cd C:\Python27\Win32
set PYTHONHOME=%CD%
set PATH=%PATH%;%CD%
Now you can move on to the next section: Building SIP
First you need to find the batch file that starts up the WCL environment with MSVC 2008 64-bit. For example, at C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin
you should be able to find the batch file vcvarsx86_amd64.bat
, but more specifically you can find also there the Windows shortcut file Visual Studio 2008 x64 Win64 Command Prompt
. Double-click on that shortcut file and it will start a new WCL with the necessary MSVC 2008 x64 building tools ready to be used.
Now, in this WCL we need to activate 2 additional environments: Qt and Python. To activate Qt, it should be as simple as running these commands:
cd C:\Qt\4.8.2_x64
call QtVars.bat
Next, to activate Python, run these commands:
cd C:\Python27\Win64
set PYTHONHOME=%CD%
set PATH=%PATH%;%CD%
Now you can move on to the next section: Building SIP
With the WCL ready to use MSVC, Qt and Python, we now need to build SIP, which is needed for later building PyQt4. In theory, it should be as simple as running the following commands (this is an example for 64-bit):
set PYQT4_PATH=W:\PyQt4-sandbox\PyQt4-Qt4.8.2-Python2.7.3-win64
cd /d w:\PyQt4-sandbox\sip-4.16.2
python configure.py --bindir %PYQT4_PATH%\bin --destdir %PYQT4_PATH%\Lib\site-packages --incdir %PYQT4_PATH%\include --sipdir %PYQT4_PATH%\Lib\sip --platform win32-msvc2008
nmake
nmake install
set PATH=%PATH%;%PYQT4_PATH%\bin
Note: The platform option is the same win32-msvc2008
for both 32 and 64-bit.
Now you can move on to the next section, namely Building PyQt4.
The next steps assume you've followed the previous sections. In addition, if you need to perform 2 builds, one per architecture, it's best to use different source code folders for each build.
The following commands should do the trick:
cd W:\PyQt4-sandbox\PyQt-win-gpl-4.11.1
python configure-ng.py --confirm-license --bindir %PYQT4_PATH%\bin --destdir %PYQT4_PATH%\Lib\site-packages --sip-incdir %PYQT4_PATH%\include --sipdir %PYQT4_PATH%\Lib\sip --no-designer-plugin
set CL= /MP
nmake release
nmake install
Note: The option --no-designer-plugin
was necessary because the debug version of Python was not used.
There are two main steps to quickly packaging:
Create a file named PyQt4env.bat
in the main folder for the installation of PyQt4, for example, in W:\PyQt4-sandbox\PyQt4-Qt4.8.2-Python2.7.3-win64
, with the following content:
set PYTHONPATH=%~dp0Lib\site-packages;%PYTHONPATH%
set PATH=%PATH%;%~dp0bin
Now, you can call this batch file from whatever batch file that activates your WCL environment, for example, by running:
call P:\PyQt4-Qt4.8.2-Python2.7.3-win64\PyQt4env.bat
You can either do it interactively through Windows Explorer (right-click on the folder and compress), or you can use the following command, from within the sandbox folder where the installation was made:
7z a -sfx -t7z -mx=9 -ms=on -mmt=on PyQt4-Qt4.8.2-Python2.7.3-win32-r1.exe PyQt4-Qt4.8.2-Python2.7.3-win32
7z a -sfx -t7z -mx=9 -ms=on -mmt=on PyQt4-Qt4.8.2-Python2.7.3-win64-r1.exe PyQt4-Qt4.8.2-Python2.7.3-win64
There are several ways that this can now be installed:
PyQt4-Qt4.8.2-Python2.7.3-win*
directly inside the main folder of where Python 2.7.3 is installed, so that the folder Lib\site-packages\PyQt4
is placed at Python's Lib\site-packages
folder. PyQt4-Qt4.8.2-Python2.7.3-win*\Lib\site-packages
inside ParaView's folder ParaView-4.1.0\lib\ParaView-4.1\site-packages
or inside the folder ParaView-4.1.0\bin\Lib\site-packages
.