Build P4python For Maya

09 Nov 2021

Autodesk Maya 2020 and lower uses a version of python 2.7 compiled with Visual Studio 2015 (v140 build tools). This means we can’t use p4python version installed directly with pip because it is compiled with a different version of visual studio. To use p4python in Maya, it needs to be compiled from scratch using the same build tools as the python version in Maya.

You can download the already compiled version here

OpenSSL

The last version of p4python must be compiled with OpenSSL. To do so, we also need to compile OpenSSL using visual studio 2015 build tools.

Prerequisites

Sources

Compile OpenSSL

OpenSSL can be build statically or dynamicly. If we build statically, it will be included into the resulting p4python library. This means that users using p4python, won’t need to have openssl library installed. Since we want to having any external dependencies, we will build openssl statically with the no-shared keyword.

If you don’t have nasm installed, you can specify no-asm to build without nasm. Withou nasm, some function might be slower.

The first line, activate visual studio build tools. Then, we configure openssl build for win x64 You must replace {openssl out path} with the desired output path.

Open an administrator command prompt and navigate to openssl folder.

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
perl Configure VC-WIN64A no-shared --prefix={openssl out path}.
nmake
nmake install

Compile P4Python

To step to build p4python are fairly simples. Open an administrator command prompt and navigate to p4python folder.

With INCLUDE we can tell visual studio where are python headers files.

Replace {version} with your installed maya version. The path might be different if you’ve installed Maya to a custom location.

Replace {openssl out path} with the output path used above. Path must be absolute.

Replace {p4api folder} with the p4api downloaded before. Path must be absolute.

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
set INCLUDE=C:\Program Files\Autodesk\Maya{version}\include\Python
C:\Program Files\Autodesk\Maya{version}\bin\mayapy.exe setup.py build --apidir {p4api folder} --ssl {openssl out path}\lib