How to rebuild PySide2 for Maya 2017

Maya 2017 is moving to QT 5.6.1 and PySide2. PySide2 is currently still in alpha stage, so it’s not as stable as it could be. We will continue to update it in our service packages. However, if you want to upgrade yourself, you can download and build it easily.

Maya 2017 is built with MSVC2012, so we cannot introduce other vc runtime in our build environment. So we will build QT 5.6.1 with MSVC2012 and the Python shipped with Maya.

It’s a good idea to backup the Pyside2 files shipped with Maya before you are trying to replace them.

Here is a list:

Maya2017/bin/pyside2.dll
Maya2017/bin/pyside2-uic
Maya2017/bin/shiboken2.dll
Maya2017/lib/pyside2.lib
Maya2017/lib/shiboken2.lib
Maya2017/Python/Lib/site-packages/shiboken2.pyd
Maya2017/Python/Lib/site-packages/PySide2
Maya2017/Python/Lib/site-packages/pyside2uic

Let’s begin to build PySide2 now. First, you’ll need to download the source code of QT 5.6.1 and compile it with MSVC2012 64bit. You can find our modified QT package here and check the guide for building and installing customized QT 5.6.1 on windows.

Then you’ll need to get the latest code from the PySide2 repo. For example:

git clone https://codereview.qt-project.org/pyside/pyside-setup --branch dev --recursive

After cloning the repo, we need to prepare for MayaPy. First, create a folder named Libs inside of Maya2017/Python folder then copy python27.lib from Maya2017/lib into it. Copy Maya2017/include/python2.7 into Maya2017/Python also. After that, we can build Pyside2 with following command in VS2012 x64 native tools :

mayapy.exe setup.py build --ignore-git --qmake=%QT5.6.1_MSVC2012_BuildPath%qmake.exe --cmake="C:Program Files (x86)CMakebincmake.exe" --jobs=9 --jom

We are using CMake 3.3.x here. JOM is a parallel build tool for QT, you can download it from QT’s website or inside of QtCreator. Please make sure you’ve added JOM’s path into your path environment variable.

It will take about 10 minutes to build Pyside2. Once it is done, go to pyside_install folder and replace the Maya2017bin folder with the files inside the pyside_installpy2.7-qt5.6.1-64bit-releasebin folder;Maya2017Pythonlibsite-packages with pyside_installpy2.7-qt5.6.1-64bit-releaselibsite-packages and Maya2017lib with the files in pyside_installpy2.7-qt5.6.1-64bit-releaselib.

Please make sure to backup the original file, as if there is any other issues caused by the replacement, you can use the original file to revert this workaround.


Comments

7 responses to “How to rebuild PySide2 for Maya 2017”

  1. Christian Akesson Avatar
    Christian Akesson

    Hi there,
    We are trying to build PySide2 for Python 2.7 in Win 10. We managed to compile to a wheel where you would have to have Qt installed on the system. We would like to compile to where Qt does not need to be installed on the system to use PySide2.
    Would we follow the same steps outlined above, but instead of using mayapy, we would use the python 2.7 executable?
    It’s hard to find info on this as it stands right now, so any information on this would be very helpful. There must be many studios, that want to build a PySide2 installer that does not require Qt to be installed.
    Thanks for putting solid information out there,
    Christian Akesson | Senior Technical Artist | Daybreak Games

  2. Martin Karlsson Avatar
    Martin Karlsson

    I have to say that for someone that is not familiar with compiling Qt the bundled instructions in “howToBuildQtOnWindows_m2017.txt” are severely lacking.
    What is the “icu53_1” reference?
    What is “your normal options” for configure.exe?
    The general tone of the instructions makes me feel like they were written for people who does this stuff on a frequent basis.
    I would really appreciate a better set of instructions.

  3. Martin Karlsson Avatar
    Martin Karlsson

    Instructions says “See https://doc-snapshots.qt.io/qt5-5.4/windows-building.html for Qt building notes” but that page is a 404.

  4. Martin Karlsson Avatar
    Martin Karlsson

    Getting below warnings- can someone please help clarify:
    C:\qt\qt-adsk-5.6.1\qtbase\src\network\access\qnetworkaccessdebugpipebackend_p.h(0): Note: No relevant classes found. No output generated.
    cl : Command line warning D9002 : ignoring unknown option ‘-arch:SSE2’
    cl : Command line warning D9002 : ignoring unknown option ‘-arch:SSE2’
    cl : Command line warning D9002 : ignoring unknown option ‘-arch:SSE2’
    cl : Command line warning D9002 : ignoring unknown option ‘-arch:SSE2’
    cl : Command line warning D9002 : ignoring unknown option ‘-arch:SSE2’
    C:\qt\qt-adsk-5.6.1\qtbase\src\network\access\qnetworkaccessdebugpipebackend_p.h(0): Note: No relevant classes found. No output generated.
    cl : Command line warning D9002 : ignoring unknown option ‘-arch:SSE2’
    cl : Command line warning D9002 : ignoring unknown option ‘-arch:SSE2’
    cl : Command line warning D9002 : ignoring unknown option ‘-arch:SSE2’
    cl : Command line warning D9002 : ignoring unknown option ‘-arch:SSE2’
    cl : Command line warning D9002 : ignoring unknown option ‘-arch:SSE2’
    Checking for ntddmodm… no
    Checking for jasper… no
    Checking for libmng… no
    Checking for libtiff… no
    Checking for libwebp… no
    Checking for language… no
    Checking for socketcan… no
    Checking for socketcan_fd… no
    Project WARNING: Cannot compile the module with your compiler, missing C++11 language features.

  5. Martin Karlsson Avatar
    Martin Karlsson

    After a full day of tinkering I got a Qt build done; however, when I try to compile PySide2 it seems like the build is bad.
    Get errors about missing dll files in the “…qt-build-561\qtbase\bin...” directory and the below error [note the messed up filepath “C:/qt/qt-build-561/qtbase/C:/qt/qt-adsk-5.6.1/qtbase//mkspecs/win32-msvc2012”]:
    [Start error]
    CMake Error at C:/qt/qt-build-561/qtbase/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:15 (message):
    The imported target “Qt5::Core” references the file
    “C:/qt/qt-build-561/qtbase/C:/qt/qt-adsk-5.6.1/qtbase//mkspecs/win32-msvc2012”
    but this file does not exist. Possible reasons include:
    * The file was deleted, renamed, or moved to another location.
    * An install or uninstall procedure did not complete successfully.
    * The installation package was faulty and contained
    “C:/qt/qt-build-561/qtbase/lib/cmake/Qt5Core/Qt5CoreConfigExtras.cmake”
    but not all the files it references.
    [End error]

  6. Chengxi Li Avatar
    Chengxi Li

    Hi,
    I was in training last week. I’ll look at this issue this week.
    Yours,
    Li

  7. Chengxi Li Avatar
    Chengxi Li

    Hi Christian,
    Using python 2.7 should be OK. But we recommend to use Python built with VS2012 to avoid any potential runtime issues. That’s the reason why I am using mayapy.
    I think you can’t build PySide without a QT environment. But once it is built, you can copy the binary outputs to other computers you need.
    Yours,
    Li

Leave a Reply to Martin KarlssonCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading