Skip to content

Instantly share code, notes, and snippets.

@shimizukawa
Last active December 11, 2015 17:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save shimizukawa/4634344 to your computer and use it in GitHub Desktop.
Save shimizukawa/4634344 to your computer and use it in GitHub Desktop.
PIL (Pillow) build procedure

PIL(Pillow) build on Windows (32bit)

If you want to build PIL on Windows, you need to prepare few external libraries. Although some libraries did not provide static library for windows 32/64 bits then you need to build these libraries by your hand too. Also, PIL will load by python at last then you are recommended to use same compiler with python to build libraries.

Target PIL and versions

PIL

1.1.7 for Python 2.4 (or Pillow-1.7.8)

PIL

1.1.7 for Python 2.5 (or Pillow-1.7.8)

PIL

1.1.7 for Python 2.6 (or Pillow-1.7.8)

PIL

1.1.7 for Python 2.7 (or Pillow-1.7.8)

Required compilers

Python-2.4(32bit)

VisualStudio 7.1 (1310) (or VisualStudio 2003 Toolkit + Windows SDK)

Python-2.5(32bit)

VisualStudio 7.1 (1310) (or VisualStudio 2003 Toolkit + Windows SDK)

Python-2.6(32bit)

VisualStudio 2008 (1500) (or VisualC++ 2008 Express)

Python-2.7(32bit)

VisualStudio 2008 (1500) (or VisualC++ 2008 Express)

You can choise production version or free version of VisualStudio.

Required libraries and versions

freetype2

2.4.6 src (for VC7, VC2008)

jpeg6b

6b 27-Mar-1998 lib (for VC7), lib (for VC2008)

LittleCMS

1.19 src

tcl

8.5.10 src

tk

8.5.10 src

zlib

1.2.4 src

Build process for Python-2.7

build freetype

  1. extract ft246.zip into C:\lib\freetype-2.4.6
  2. open builds\win32\vc2008\freetype.sln by VC2008
  3. do build with LIB Release + Win32
  4. done! You got objs\win32\vc2008\freetype246.lib.
  5. rename freetype246.lib to freetype.lib

Note: You can use freetype246.lib file for VC2008 and VC7.

build jpeg6b

  1. You can get built-static-lib from jpeg6b-vs2008.zip (for VS2008).
  2. extract lib and headers as bellow:

    C:\Lib\jpeg6-vs2008
       +-- lib\libjpeg.lib
       +-- include\*.h

build LittleCMS

  1. extract lcmls-1.19.tar.gz into C:\lib\lcms-1.19
  2. open Projects\VC2008\lcms.sln by VC2008
  3. do build with LIB Release + Win32
  4. done! You got Lib\MS\lcms.lib.

Note

You need to choice 1.x series of Little CMS for PIL.

validate this section.

build tcl/tk

  1. extract tcl8.5.10-src.tar.gz and tk8.5.10-src.tar.gz
  2. oepn Visual Studio 2008 Command prompt from start menu.
  3. cd C:\lib\tcl8.5.10\win
  4. nmake -f makefile.vc
  5. cd C:\lib\tk8.5.10\win
  6. set TCLDIR=C:\lib\tcl8.5.10
  7. nmake -f makefile.vc
  8. done! you got C:\lib\tcl8.5.10\win\Release_VC9\tcl85.lib and C:\lib\tk8.5.10\win\Release_VC9\tk850.lib

build zlib

  1. extract zlib124.zip into C:\lib\zlib-1.2.4
  2. open projects\visualc6\zlib.vcproj by VC2008
  3. do build
  4. done! You got projects\visualc6\zlib.vcproj\Win32_LIB_Release.

validate this section.

build PIL

  1. extract PIL source
  2. write setup.cfg:

    [build_ext]
    library_dirs = C:\lib\freetype-2.4.6\lib;C:\lib\jpeg6b-vs2008\lib;C:\lib\lcms-1.19\Lib\MS;C:\lib\tcl8.5.10\win\Release_VC9;C:\lib\tk8.5.10\win\Release_VC9;C:\lib\zlib-1.2.4\projects\visualc6\zlib.vcproj\Win32_LIB_Release;
    include_dirs = C:\lib\freetype-2.4.6\include;C:\lib\jpeg6b-vs2008\include;C:\lib\lcms-1.19\include;C:\lib\tcl8.5.10\generic;C:\lib\tk8.5.10\generic;C:\lib\tk8.5.10\xlib;C:\lib\zlib-1.2.4;
  3. build (with inplace option for selftest):

    python-2.7 -S setup.py build_ext -i build
  4. self test:

    python-2.7 -S selftest
  5. make windows installer:

    python-2.7 -S setup.py bdist_wininst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment