Wednesday 20 June 2012

Cross-compiling Python for arm, with muddle

This week I needed to cross-compile Python. The "local" platform is an x86, and the target is an ARM. My specific purpose is to be able to use the KBUS Python bindings on the target platform, which means I also care about things like ctypes.

Unfortunately, Python is not terribly simple to cross-compile, partly because it relies on building itself twice. Luckily, someone else has already documented what to do - namely Paul Gibson at http://randomsplat.com/id5-cross-compiling-python-for-embedded-linux.html. That blog post describes the problem, provides the necessary patches for several versions of Python, and then describes how to build it at the command line.

(At time of writing, it doesn't have a patch for Python 2.7.3, but 2.7.2 is recent enough for our purposes, and still available from http://www.python.org/download/releases/2.7.2)

So the issue becomes simply how to amend the procedure for a muddle environment.