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

2007-10-24

Undoing transactions in a broken Plone/Zope

Today there was a situation where someone made a permission change that made Plone inaccessible. The ZMI was also inaccessible (by design (not mine)). We could get access to the filesystem, however. So after a couple attempts at undos through in debug....There were issues with permissions and RESPONSE objects and all the other Zope machinery. So I tried mounting a ZODB directly and undoing transactions. The following worked great for me:


filename = "/Users/reedobrien/instances/zeo/msrd/var/Data.fs"
import ZODB.FileStorage
import ZODB.DB
storage = ZODB.FileStorage.FileStorage(filename)
DB = ZODB.DB(storage)
txs = DB.undoLog()[::-1]
DB.undo(id=txs[0]['id'])
import transaction; transaction.commit()


Maybe the wrong way and YMMV, but it stayed in one piece for me.