Python and PyQt on the Sharp Zaurus A300

The A300 doesn't have much internal RAM, so the best bet for running Python on it is the Python Zaurus Image which puts most of python in a cramfs image which is stored on the SD card and mounted in the right place via loopback.

One minor wrinkle is that the PyQt included doesn't work on the A300 -- if you try to import qt you get an error:

ImportError: /home/QtPalmtop/lib/ undefined symbol: __8QLibraryRC7QStringQ28QLibrary6Policy

This is apparently because the Qt shipped with the A300 is weird in that this symbol is in rather than Full details are available (if you can read Japanese!), but to cut a long story short the simplest of the three approaches he suggests is just to edit the .so files in the Python distribution to refer to instead of (libqpe depends on libqte so doing this provides a strict superset of the required symbols so it all works out OK.)

Here's a script which does this automatically to create a python24.img.fixed from the python24.img file. You'll need mkcramfs and cramfsck.

#!/bin/sh -e
# Given a cramfs python24.img, unpack it, fix the .so files
# which refer to to refer to, and repack.
# This is a workaround for a bug/incompatibility in the Qt
# shipped in the Zaurus A300 ROM.

if [ $# -ne 1 ]; then
   echo "Usage: fix-zaurus-python-image python.img"
   exit 1

if [ $(id -u) -ne 0 ]; then
   echo "Sorry, you must be root to get permissions right"
   exit 1


if [ -e "$DIR" ]; then
   echo "$DIR seems to already exist, aborting"
   exit 1

# Make sure sed isn't playing silly games with non-ASCII charsets
export LANG=C
export LC_CTYPE=C

echo "Unpacking $IMG in $DIR..."
mkdir "$DIR"
cramfsck -x "$DIR/ext" "$IMG"
for LIB in "$DIR"/ext/site-packages/*.so; do
   echo "Patching $LIB..."
   sed -e 's/' < "$LIB" > "$"
   mv "$" "$LIB"
echo "Building new image file..."
mkcramfs "$DIR/ext" "$IMG.fixed"
echo "Cleaning up..."
rm -rf "$DIR"
echo "Done, new file is $IMG.fixed"

This page written by Peter Maydell (