veni vidi Scripsi

PIL, JPEG and Freetype support on Mac OS X Lion when using Virtualenv

Assuming you're using virtualenv and pip and working in your virutalenv ((your-env)username@computer:~$).

  1. Download PIL, but do not install it:

    $ pip install --no-install PIL
    
  2. For Freetype support: edit setup.py in {your-virtualenv-folder}/build/PIL. On line 40 change FREETYPE­_­ROOT = None to FREETYPE­_­ROOT = libinclude('/usr/X11'):

    # Library pointers.
    #
    # Use None to look for the libraries in well-known library locations.
    Theme: Basic Nature
    
    # Use a string to specify a single directory, for both the library and
    # the include files.  Use a tuple to specify separate directories:
    # (libpath, includepath).  Examples:
    #
    # JPEG_ROOT = "/home/libraries/jpeg-6b"
    # TIFF_ROOT = "/opt/tiff/lib", "/opt/tiff/include"
    #
    # If you have "lib" and "include" directories under a common parent,
    # you can use the "libinclude" helper:
    #
    # TIFF_ROOT = libinclude("/opt/tiff")
    
    TCL_ROOT = None
    JPEG_ROOT = None
    ZLIB_ROOT = None
    TIFF_ROOT = None
    FREETYPE_ROOT = libinclude('/usr/X11')
    LCMS_ROOT = None
    
    # FIXME: add mechanism to explicitly *disable* the use of a library
    # --------------------------------------------------------------------
    
  3. Get libjpeg (choose any version, when I installed v9 was the latest):

    $ curl -O http://www.ijg.org/files/jpegsrc.v9.tar.gz
    $ tar zxvf jpegsrc.v9.tar.gz
    $ cd jpeg-9/
    $ ./configure
    $ make
    $ sudo make install
    
  4. Install PIL:

    $ pip install PIL
    

Done!

Resources

Installing Gettext on Mac OS X Lion » « Getting htaccess to work on a Mac (Lion) with Apache and using symlinks