2007-10-29

Build PIL on Mac OSX

This entry attempts to give instructions for how to build the Python Imaging Library (PIL) on Mac OSX.

#download and untar the jpeg library

#see here for location http://www.ijg.org/
curl http://path/to/jpegsrc.v6b.tar.gz | tar zxf -
#change directory to
cd jpeg-6b
#run configure
./configure CFLAGS='-fPIC'
#run make
make
#Run make install
sudo make install
#run ranlib
ranlib libjpeg.a
#copy the lib file to lib
cp libjpeg.a /usr/local/lib
#copy headers to include
cp *.h /usr/local/include
#make this your real python
PYTHON_COMMAND="/path/to/your/python"
#get and untar the PIL source
curl http://path/to/Imaging-1.1.6.tar.gz | tar zxf -
# cd
cd Imaging-1.1.6
# copy setup out of it's way
mv setup.py setup.py.tmp
# set up a replacement command
# you can do edit setup.py by hand if you wish
SED_CMD="s|JPEG_ROOT = None|JPEG_ROOT = libinclude(\"/usr/local/lib\")|; s|ZLIB_ROOT = None|ZLIB_ROOT = libinclude(\"/usr/local/lib\")|;"
#replace the stock jpg locations with the new ones you made
cat setup.py.tmp | sed -e "$SED_CMD" > setup.py
#build it
$PYTHON_COMMAND setup.py build_ext -i
#test it
$PYTHON_COMMAND selftest.py
#install it
sudo $PYTHON_COMMAND setup.py install

No comments: