Compiling PyQt and QtWinMigrate for 3ds Max 2015

I am writing down my findings about this process as I was only able to finish because of people sharing their experiences online. If anyone wants to do this or something similar in the future, hopefully one or two things listed here will be useful.

I intended to create Python bindings for the QtWinMigrate library to be able to use the 3ds Max windows as a parent for custom PyQt widgets. Blur did this for their Py3dsMax package and currently there is no equal functionality for PySide in the MaxPlus Python API.

I was hoping that the binding would probably work for PySide as well, which in the end of course was a bit naive. Nevertheless I decided to give it a try, as part of the work was already done and available online in the form of sip files that define the actual Python binding to the C++ code.

The following is a complete rundown of my personal struggles, problems and (partially hacky) solutions. It will probably not be the same for you, should you try repeat it due to differences in platform, environment and/or tools. So this is mainly intended to give an overview of needed steps and a list of potential problems and workarounds to overcome them.

Please keep in mind I am far from being in expert in any of this. There is probably a less error-prone way of building all this and I am pretty sure I missed something due to lack of understanding, but hey, information is quite rare about the whole thing and it’s often like “lol just g++, ez lyfe bro” which is not particulary helpful for this specific application. Please be aware of the different licenses of the libraries and tools that are being used.

As a short overview this is what we have to do:

  • Build and install SIP
  • Build and install Qt
  • Build and install PyQt
  • Build and install QtWinmigrate
  • Build and install the QtWinmigrate Python bindings

We will have to use the same versions of the above tools as are being used in 3ds Max 2015. This is probably not crucial for all of them, but the following definitively have to match:

  • Python 2.7.3
  • Qt 4.8.5

Prerequisites

For compilation you need:

  • Python
  • The MSVC2010 compiler. I used Visual Studio 2012 Professional for this.
  • The MFC library. They come with Visual Studio Professional and above, but not with the Express versions.

We will use nmake (comes with Visual Studio) and qmake (comes with Qt) as our build tools.

Use the 3ds Max Python Installation

The easiest way to use the same Python version as in 3ds Max 2015 is to use the actual interpreter that comes with it. However this is not a good idea, as seemingly some of the tools in the build process are not made for paths with spaces in them, and the default C:\Program Files\Autodesk\3ds Max 2015\python has plenty of those.

Instead what you can safely do is copy and rename the C:\Program Files\Autodesk\3ds Max 2015\python directory to somewhere else, e.g. c:\python273_max2015.

For convenience you should then make this your default Python version. Simply modify your PATH variable to list the C:\python273_max2015 directory before any other Python version you may have installed. I recommend the handy Rapid Environment Editor for this, the default Windows interface for it is horrible.

Note: All commands below are executed within a VS2012 x64 Native Tools Command Prompt. It comes with Visual Studio and you can either launch it from the Windows Start Menu or by calling this in a cmd.exe:

"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" amd64

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.