This is an updated version for Maya 2014' PyQt build instructions.
This is an updated version of the Maya 2013 build instructions for PyQt and PySide (here). The very good news is that with Maya 2014, there is no more need to build PySide as it is coming by default in Maya :)
libxml, openSSL, OpenAL, python2.7, qt-4.8.2-64, and tbb are also coming by default in the Maya include and lib folder, so unless you have a very specific need, you would not need to rebuild any of those libraries like before. Note as well that there is a 'C:\Program Files\Autodesk\Maya2014\support\opensource' folder now which contains some of the community source. http://www.autodesk.com/lgplsource is also a location you want to remember for future.
I'll come back later with instructions to rebuild Qt itself for those who needs to, but again you do not need to build Qt to build PyQt anymore.
Maya 2014 also includes most of the tools we need to build PyQt without the need of compiling Qt source & tools - so in this post we will see the easy way to build PyQt.
Download SIP and PyQt source from 'http://www.riverbankcomputing.co.uk' - here I downloaded 'sip-4.14.5' and 'PyQt-win-gpl-4.10'. Unzip them in one folder, then you should get something like this:
Mac
/Users/cyrille/Documents/_Maya2014Scripts/sip-4.14.5
/Users/cyrille/Documents/_Maya2014Scripts/PyQt-mac-gpl-4.10
'/Users/cyrille/Documents/_Maya2014Scripts' being my local folder. Now the instructions, and bash scripts to build that stuff.
Follow the instructions from the API docs to setup your environment (Developer Resources > API Guide > Setting up your build environment > Mac OS X environment, in the Maya Documentation)
Untar the /devkit/include/qt-4.8.2-include.tar.gz into /devkit/include/Qt
Copy /Resources/qt.conf into /bin/qt.conf and edit it like this:
[Paths] Prefix= Libraries=../MacOS Binaries=../bin Headers=../../../devkit/include/Qt Data=.. Plugins=../qt-plugins Translations=../qt-translations
Untar the qt-4.8.2-64-mkspecs.tar.gz into $MAYA_LOCATION/Maya.app/Contents/bin/mkspecs Unfortunately, this file is not present in the Maya Mac distribution, so you either need to get it from your Window or Linux Maya distribution, or from the Qt Mac source. Make sure the qconfig.pri looks like this:
qconfig.pri
#configuration CONFIG += release def_files_disabled exceptions no_mocdepend stl x86_64 qt #qt_framework QT_ARCH = macosx QT_EDITION = OpenSource QT_CONFIG += minimal-config small-config medium-config large-config full-config no-pkg-config dwarf2 phonon phonon-backend accessibility opengl reduce_exports ipv6 getaddrinfo ipv6ifname getifaddrs png no-freetype system-zlib nis cups iconv openssl corewlan concurrent xmlpatterns multimedia audio-backend svg script scripttools declarative release x86_64 qt #qt_framework #versioning QT_VERSION = 4.8.2 QT_MAJOR_VERSION = 4 QT_MINOR_VERSION = 8 QT_PATCH_VERSION = 2 #namespaces QT_LIBINFIX = QT_NAMESPACE = QT_NAMESPACE_MAC_CRC = QT_GCC_MAJOR_VERSION = 4 QT_GCC_MINOR_VERSION = 2 QT_GCC_PATCH_VERSION = 1
You also need to create copy of the Qt lib files as fake .dylib files from the /MacOS directory. The script below will give you the commands to run to do that.
Build & Install SIP
#!/usr/bin/env bash MAYAQTBUILD="`dirname \"$0\"`" # Relative export MAYAQTBUILD="`( cd \"$MAYAQTBUILD\" && pwd )`" # Absolutized and normalized cd $MAYAQTBUILD export SIPDIR=$MAYAQTBUILD/sip-4.14.5 export MAYA_LOCATION=/Applications/Autodesk/maya2014 cd $SIPDIR $MAYA_LOCATION/Maya.app/Contents/bin/mayapy ./configure.py --arch=x86_64 make sudo make install
Build & Install PyQt
#!/usr/bin/env bash MAYAQTBUILD="`dirname \"$0\"`" # Relative export MAYAQTBUILD="`( cd \"$MAYAQTBUILD\" && pwd )`" # Absolutized and normalized cd $MAYAQTBUILD export MAYA_LOCATION=/Applications/Autodesk/maya2014 export QTDIR=$MAYA_LOCATION/Maya.app/Contents export QMAKESPEC=$QTDIR/mkspecs/macx-g++ export INCDIR_QT=$MAYA_LOCATION/devkit/include/Qt export LIBDIR_QT=$QTDIR/MacOS if [ ! -f $QMAKESPEC/qmake.conf ]; then echo "You need to install qt-4.8.2-64-mkspecs.tar.gz in $QTDIR/mkspecs !" exit fi if [ ! -f $INCDIR_QT/QtCore/qdir.h ]; then echo "You need to uncompress $MAYA_LOCATION/devkit/include/qt-4.8.2-include.tar.gz in $INCDIR_QT !" exit fi # qt.conf - /Applications/Autodesk/maya2014/Maya.app/Contents/Resources if [ ! -f $QTDIR/bin/qt.conf ]; then echo "You need to copy $QTDIR/Resources/qt.conf in $QTDIR/bin !" exit fi test=`grep "Data=../.." $QTDIR/bin/qt.conf` if [ ! -z "$test" ]; then echo "You need to edit $QTDIR/bin/qt.conf to use 'Data=..'" exit fi test=`grep "Headers=../../include" $QTDIR/bin/qt.conf` if [ ! -z "$test" ]; then echo "You need to edit $QTDIR/bin/qt.conf to use 'Headers=../../../devkit/include/Qt'" exit fi test=`grep "Libraries=../lib" $QTDIR/bin/qt.conf` if [ ! -z "$test" ]; then echo "You need to edit $QTDIR/bin/qt.conf to use 'Libraries =../MacOS'" exit fi test=`grep "Plugins = qt-plugins" $QTDIR/bin/qt.conf` if [ ! -z "$test" ]; then echo "You need to edit $QTDIR/bin/qt.conf to use 'Plugins=../qt-plugins'" exit fi test=`grep "Translations = qt-translations" $QTDIR/bin/qt.conf` if [ ! -z "$test" ]; then echo "You need to edit $QTDIR/bin/qt.conf to use 'Translations=../qt-translations'" exit fi for mod in Core Declarative Designer DesignerComponents Gui Help Multimedia Network OpenGL Script ScriptTools Sql Svg WebKit Xml XmlPatterns do if [ ! -f $QTDIR/MacOS/libQt${mod}.dylib ]; then echo "You need to copy a fake Qt$mod dylib - cp $QTDIR/MacOS/Qt$mod $QTDIR/MacOS/libQt${mod}.dylib !" #cp $QTDIR/MacOS/Qt$mod $QTDIR/MacOS/libQt${mod}.dylib exit fi done if [ ! -f $QTDIR/MacOS/libphonon.dylib ]; then echo "You need to copy a fake phonon dylib - cp $QTDIR/MacOS/phonon $QTDIR/MacOS/libphonon.dylib !" #cp $QTDIR/MacOS/phonon $QTDIR/MacOS/libphonon.dylib exit fi export DYLD_LIBRARY_PATH=$QTDIR/MacOS export DYLD_FRAMEWORK_PATH=$QTDIR/Frameworks export SIPDIR=$MAYAQTBUILD/sip-4.14.5 export PYQTDIR=$MAYAQTBUILD/PyQt-mac-gpl-4.10 cd $PYQTDIR export PATH=$QTDIR/bin:$PATH $QTDIR/bin/mayapy ./configure.py LIBDIR_QT=$LIBDIR_QT INCDIR_QT=$INCDIR_QT MOC=$QTDIR/bin/moc -w --no-designer-plugin -g make -j 8 sudo make install
You're done! go to the testing paragraph at the end of the article.
Linux
/home/cyrille/Documents/_Maya2014Scripts/sip-4.14.5
/home/cyrille/Documents/_Maya2014Scripts/PyQt-mac-gpl-4.10
'/home/cyrille/Documents/_Maya2014Scripts' being my local folder. Now the instructions, and bash scripts to build that stuff.
Follow the instructions from the API docs to setup your environment (Developer Resources > API Guide > Setting up your build environment > Linux environments (64 bit), in the Maya Documentation).
Edit your qt.conf file (/usr/autodesk/maya2014-x64/bin) like below
[Paths]
Prefix=
Libraries=../lib
Binaries=../bin
Headers=../include/Qt
Data=../
Plugins=../qt-plugins
Translations=../qt-translations
Untar the /include/qt-4.8.2-include.tar.gz into /include/Qt
Untart the /mkspecs/qt-4.8.2-mkspecs.tar.gz into /mkspecs
Make qmake, moc executables from the Maya bin directory
sudo chmod aog+x /usr/autodesk/maya2014-x64/bin/moc sudo chmod aog+x /usr/autodesk/maya2014-x64/bin/qmake
Build & Install SIP
#!/usr/bin/env bash MAYAQTBUILD="`dirname \"$0\"`" # Relative export MAYAQTBUILD="`( cd \"$MAYAQTBUILD\" && pwd )`" # Absolutized and normalized cd $MAYAQTBUILD export SIPDIR=$MAYAQTBUILD/sip-4.14.5 export MAYA_LOCATION=/usr/autodesk/maya2014-x64 cd $SIPDIR $MAYA_LOCATION/bin/mayapy ./configure.py make sudo make install
Build & Install PyQt
#!/usr/bin/env bash MAYAQTBUILD="`dirname \"$0\"`" # Relative export MAYAQTBUILD="`( cd \"$MAYAQTBUILD\" && pwd )`" # Absolutized and normalized cd $MAYAQTBUILD export MAYA_LOCATION=/usr/autodesk/maya2014-x64 export QTDIR=$MAYA_LOCATION export QMAKESPEC=$QTDIR/mkspecs/linux-g++-64 export INCDIR_QT=$MAYA_LOCATION/include/Qt export LIBDIR_QT=$QTDIR/lib if [ ! -f $QMAKESPEC/qmake.conf ]; then echo "You need to install qt-4.8.2-mkspecs.tar.gz in $QTDIR/mkspecs !" exit fi if [ ! -f $INCDIR_QT/QtCore/qdir.h ]; then echo "You need to uncompress $MAYA_LOCATION/include/qt-4.8.2-include.tar.gz in $INCDIR_QT !" exit fi # qt.conf - /Applications/Autodesk/maya2014/Maya.app/Contents/Resources if [ ! -f $QTDIR/bin/qt.conf ]; then echo "You need to copy $QTDIR/Resources/qt.conf in $QTDIR/bin !" exit fi test=`grep "Headers=../include/Qt" $QTDIR/bin/qt.conf` if [ -z "$test" ]; then echo "You need to edit $QTDIR/bin/qt.conf to use 'Headers=../include/Qt'" exit fi export SIPDIR=$MAYAQTBUILD/sip-4.14.5 export PYQTDIR=$MAYAQTBUILD/PyQt-x11-gpl-4.10 cd $PYQTDIR export PATH=$QTDIR/bin:$PATH $QTDIR/bin/mayapy ./configure.py LIBDIR_QT=$LIBDIR_QT INCDIR_QT=$INCDIR_QT MOC=$QTDIR/bin/moc -w --no-designer-plugin -g make -j 8 sudo make install
You're done! go to the testing paragraph at the end of the article.
Windows
D:\__sdkext\_Maya2014 Scripts\sip-4.14.5
D:\__sdkext\_Maya2014 Scripts\PyQt-win-gpl-4.10
'D:\__sdkext\_Maya2014 Scripts' being my local folder. Now the instructions and scripts to build that stuff.
Follow the instructions from the API docs to setup your environment (Developer Resources > API Guide > Setting up your build environment > Windows environment (64‐bit), in the Maya Documentation)
Edit your qt.conf file (C:\Program Files\Autodesk\Maya2014\bin) like below
[Paths]
Prefix=
Libraries=../lib
Binaries=../bin
Headers=../include/Qt
Data=../
Plugins=../qt-plugins
Translations=../qt-translations
Unzip the /include/qt-4.8.2-64-include.tar.gz into /include/Qt
Unzip the /mkspecs/qt-4.8.2-64-mkspecs.tar.gz into /mkspecs
Build & Install SIP
@echo off set MAYAQTBUILD=%~dp0 set MAYAQTBUILD=%MAYAQTBUILD:~0,-1% if exist v:\nul subst v: /d subst v: "%MAYAQTBUILD%" v: set SIPDIR=v:\sip-4.14.5 set MSVC_DIR=C:\Program Files (x86)\Microsoft Visual Studio 10.0 if [%LIBPATH%]==[] call "%MSVC_DIR%\VC\vcvarsall" amd64 set MAYA_LOCATION=C:\Program Files\Autodesk\Maya2014 set INCLUDE=%INCLUDE%;%MAYA_LOCATION%\include\python2.7;%MAYA_LOCATION%\Python\include set LIB=%LIB%;%MAYA_LOCATION%\lib cd %SIPDIR% "%MAYA_LOCATION%\bin\mayapy" configure.py nmake nmake install
Build & Install PyQt
@echo off set MAYAQTBUILD=%~dp0 set MAYAQTBUILD=%MAYAQTBUILD:~0,-1% if exist v:\nul subst v: /d subst v: "%MAYAQTBUILD%" v: set MAYA_LOCATION=C:\Program Files\Autodesk\Maya2014 if exist m:\nul subst m: /d subst m: "%MAYA_LOCATION%" set MAYA_LOCATION=m: set QTDIR=%MAYA_LOCATION% set MSVC_VERSION=2010 set QMAKESPEC=%QTDIR%\mkspecs\win32-msvc%MSVC_VERSION% if not exist "%QMAKESPEC%\qmake.conf" ( echo "You need to uncompress %MAYA_LOCATION%\mkspecs\qt-4.8.2-64-mkspecs.tar.gz !" goto :end ) if not exist "%MAYA_LOCATION%\include\Qt\QtCore\qdir.h" ( echo "You need to uncompress %MAYA_LOCATION%\include\qt-4.8.2-64-include.tar.gz in %MAYA_LOCATION%\include\Qt !" goto :end ) findstr /L /C:"Headers=../include/Qt" %MAYA_LOCATION%\bin\qt.conf >nul 2>&1 if ERRORLEVEL 1 ( echo "You need to edit %MAYA_LOCATION%\bin\qt.conf to use 'Headers=../include/Qt'" goto :end ) set SIPDIR=v:\sip-4.14.5 set PYQTDIR=v:\PyQt-win-gpl-4.10 set MSVC_DIR=C:\Program Files (x86)\Microsoft Visual Studio 10.0 if [%LIBPATH%]==[] call "%MSVC_DIR%\VC\vcvarsall" amd64 set INCLUDE=%INCLUDE%;%MAYA_LOCATION%\include\python2.7;%MAYA_LOCATION%\Python\include set LIB=%LIB%;%MAYA_LOCATION%\lib cd %PYQTDIR% set PATH=%QTDIR%\bin;%PATH% "%MAYA_LOCATION%\bin\mayapy" configure.py LIBDIR_QT=%QTDIR%\lib INCDIR_QT=%QTDIR%\include\Qt MOC=%QTDIR%\bin\moc.exe -w --no-designer-plugin nmake nmake install :end pause
You're done! go to the testing paragraph at the end of the article.
Testing
Copy and paste this example in the Maya Script Editor (in a Python tab), and execute the code:
import sys from PyQt4 import QtGui class Example(QtGui.QWidget): def __init__(self): super(Example, self).__init__() self.initUI() def initUI(self): self.btn = QtGui.QPushButton('Dialog', self) self.btn.move(20, 20) self.btn.clicked.connect(self.showDialog) self.le = QtGui.QLineEdit(self) self.le.move(130, 22) self.setGeometry(300, 300, 290, 150) self.setWindowTitle('Input dialog') self.show() def showDialog(self): text, ok = QtGui.QInputDialog.getText(self, 'Input Dialog', 'Enter your name:') if ok: self.le.setText(str(text)) ex = Example()
If you see the dialog is showing, you are all set :)
is there any certain need at all to use PyQt? If I understand right differences to PySide are small.
Posted by: felix | April 23, 2013 at 08:01 AM
Hi Felix
No, if you are happy with PySide, use PySide since it comes with Maya by default. These build instructions are for people who cannot move easily to PySide for legacy reasons. There are few minors differences such as changing the imports, and the big one is
widget = shiboken.wrapInstance(long(ptr), QtCore.QObject)
you have to give shiboken (not sip) the actual type of object. You can't rely on sip to figure it out.
Otherwise, the port is very easy, but I know some people would prefer staying with PyQt.
-cyrille
Posted by: Cyrille Fauvel | April 23, 2013 at 08:10 AM
Thanks, I'm not a programmer but use some plugins that use PyQT. Is it possible to make an installer for OSX or an easier tutorial?
I got lost in the beginning already... :-/
Posted by: Peter | April 24, 2013 at 08:05 AM
Hi Peter
I wish I could, but unfortunately I am not allowed to ship binaries. This post assumes you got the developer environment for Maya 2014 setup as documented in the Maya API Online Help (using Xcode 3.2.1, OSX SDK 10.6 and gcc 4.2.1 for OSX) - if your Mac is setup properly.
-cyrille
Posted by: Cyrille Fauvel | April 24, 2013 at 08:42 AM
Hello Cyrille,
Nevermind my last comment. Did not realize these were .bat files. All is well. Thank you for these great tutorials.
Al.
Posted by: Al | April 30, 2013 at 08:32 PM