wiredfool

Compiling PIL with the G4 tiff patch, Encore

I had to compile the Python Imaging Library again (first time), this time on OSX Tiger, and I found that the previous patch that I’d published was missing some bits. In the meantime, PIL had revved to 1.1.6. I also needed to figure out how to compile libjpeg and libtiff in universal form.

The updated PIL Group4 tiff read patch is here. This is a very basic update from this patch, which was for 1.1.4. I don’t vouch for it’s correctness, but it’s working for me. YMMV.

I went back and forth on compiling the libraries in a universal build and trying to make the PIL a ppc-only build, but in the end, the universal libraries were easier to do. This page got me there for both of them.

For libjpeg, run the configure, then edit the makefile to set the c and ld flags:

CFLAGS= -O2 -I$(srcdir) -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
LDFLAGS= -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk  

Then make as normal.

For libtiff, set the environment variables:

export SDK=/Developer/SDKs/MacOSX10.4u.sdk
export CFLAGS="-isysroot ${SDK} -arch ppc -arch i386"
export CXXFLAGS="-isysroot ${SDK} -arch ppc -arch i386"

and run the configure command with the following options:

./configure --disable-dependency-tracking \
CXXFLAGS="${CXXFLAGS} -DMACX=1 -DWORDS\_BIGENDIAN=\_\_BIG\_ENDIAN\_\_" \
CFLAGS="${CFLAGS} -DMACX=1 -DWORDS\_BIGENDIAN=\_\_BIG\_ENDIAN\_\_"

PIL needs the private libtiff headers, so you need the build directory around and included in the library pointers section of the setup.py file. The other libraries that PIL uses are included in OSX: freetype is included in the X11 packages and zlib is in the base developer install. My library pointer section looks like:

FREETYPE_ROOT = libinclude('/Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/')
JPEG\_ROOT =  '/Users/erics/Sites/wce-trunk/client/depends/jpeg-6b/'
TIFF\_ROOT = '/usr/local/lib', '/Users/erics/Sites/wce-trunk/client/depends/tiff-3.8.2/libtiff/'
ZLIB\_ROOT = "/usr/lib", "/Developer/SDKs/MacOSX10.4u.sdk/usr/include"
TCL\_ROOT = None

(Where I’m ignoring TCL). You’ll need to edit the paths for the tiff and jpeg roots.

Finally, you should be able to build the PIL with the command “python setup.py build\_ext -i”. The selftest.py should run cleanly and not error out. The install is then the standard “sudo python setup.py install”.

No comments

No comments yet. Be the first.

Leave a reply

You must be logged in to post a comment.