Compile PIL Maya & Python

Compile PIL for Maya & Python

When I needed to compile PIL (Python Image Library) for Maya & Python 2.7.3 64 bit, there was very little useful information on the interwebs about it so I figured I’d jot down the steps I went through here.

The tough part for me was to figure out how to get the jpeg and zlib dependency libraries compiled and included.

PIL Source

  1. Download the source code for PIL for whatever Python version you need.
  2. Extract to some folder (Example C:/temp/PIL). Clarification: The archive contains a folder called Imaging-Version#, in the example here that directory is removed so that the files therein lives in C:/temp/PIL

The dependency libraries

You can find the source to all the available dependency libraries in C:/temp/PIL/README

Jpeg Support

  1. Extract the archive (Example C:/temp/jpeg-9)
  2. Open up a Visual Studio 2010 64 Command Prompt (Start -> All programs -> Microsoft Visual Studio 2010 -> Visual Studio Tools -> Visual Studio x64 Win64 Command Prompt (2010)
  3. Run the following commands:
  1. You now have a jpeg.vcxproj (C:/temp/jpeg-9/jpeg.vcxproj). Double click this file to open in VS2010.
  2. Go to Build->Configuration Manager->Active Solution Platform->New… and choose x64 in the drop down
  3. Close and Build Solution (F6). Once the build is complete, you will have a directory x64/Release (C:/temp/jpeg-9/x64/Release)
  4. Create a new directory in C:/temp/PIL called lib (C:/temp/PIL/lib)
  5. Inside the new directory, create another directory called jpeg (C:/temp/PIL/lib/jpeg)
  6. Copy all the FILES from the C:/temp/jpeg-9/x64/Release and all the FILES from C:/temp/jpeg-9 into the C:/temp/PIL/lib/jpeg folder.
  7. Open up C:/temp/PIL/setup.py for edit and set the jpeg root like below:
  1. To verify all went well with the jpeg dependency, in your VS Command prompt type:
Note
The path to your Python install may not be the same as mine.
  1. You should see in the Setup Summary that jpeg support is available.

PNG Support (zlib)

Note: I used the latest version from here

  1. Extract the archive (Example C:/temp/zlib-1.2.8)
  2. Go to C:/temp/zlib-1.2.8/contrib/vstudio/vc10
  3. According to this page, there is a bug in the VS2010 solution. You fix it by right clicking on the zlibstat project (zlibstat.vcxproj) find and remove all instances of ZLIB_WINAPI; in the file (using your favorite text editor). When done, save it.
  4. Double click zlibvc.vcxproj to open it in VS2010.
  5. Go to Build->Configuration Manager->Active Solution Platform->New… and choose x64 in the drop down
  6. Close and Build Solution (F6). Once the build is complete, you will have a directory x64/Release (C:/temp/zlib-1.2.8/contrib/vstudio/vc10/x64/Release)
  7. Now type the following into your VS2010 64 bit command prompt (Source Info):
  1. Inside the C:/temp/PIL/lib directory, create another directory called zlib (C:/temp/PIL/lib/zlib)
  2. Copy the source FILES in C:/temp/zlib-1.2.8 and all the files in C:/temp/zlib-1.2.8/contrib/vstudio/vc10/x64/Release to C:/temp/PIL/lib/zlib
  3. Open up C:/temp/PIL/setup.py for edit and set the jpeg root like below:
  1. To verify all went well with the jpeg dependency, in your VS 64 bit Command prompt type:
Note
The path to your Python install may not be the same as mine.
  1. You should see in the Setup Summary that — ZLIB (PNG/ZIP) support available.

Compile the final build

  1. Go to C:tempPILbuild and delete all directories from there.
  2. Go back to the VS 64 bit Command prompt and type:
  1. The files in the folder C:tempPILbuildlib.win-amd64-2.7 is your new PIL module.

OR...

...just want to bypass all this “fun”and download the PIL package below.

Download PIL 64

Spread the knowledge

About the Author

Christian Akesson

Facebook Twitter Google+

Senior Technical Artist at Daybreak Games. Maya user since beta 1 in 1999.