I think I became a little too crazy over cross compiling. For reasons now unknown to me, I decided that I wanted Python 3 on my Beaglebone. Having just learned how to cross-compile, I was perhaps a bit ambitious. In the end, I believe I cross-compiled successfully, but I have issues actually running Python 3 on the BB (perhaps due to PYTHONPATH issues?). Anyway, I’m a bit overloaded with other projects at the moment so I don’t think I can see this through. But I figured I’d write a post showing at least how to compile.
First I found a great site on how to cross-compile. Unfortunately, it appears offline now. A cached page is here and the real page, which is broken, is here. In his example he shows to cross-compile Nano and the key line is where he shows how to run configure:
./configure --host=arm-angstrom-linux-gnueabi --prefix=/home/vmplanet/gccexamples/nano/nano_out/
The host parameter tells configure to setup for arm-angstrom and the prefix parameter will be the root folder when you run
make install. This allows you to easily copy that directory to your Beaglebone for installation.
Apparently, prior to Python 3.3.1, one must patch the Python source to allow for cross-compiling. But, new to Python 3.3.1, this is no longer the case. You can now pass
--host parameters to configure (like above). For more information on this, see the Python 3.3.1 what’s new and look at the build section. Or, see the python checkin mailing list for the issue resolutions here and here.
The final incantation that worked for me was (I’m not sure if the
CC parameter is needed):
CONFIG_SITE=config.site ./configure CC="arm-angstrom-linux-gnueabi-gcc" --build=x86_64-ubuntu-linux --host=arm-angstrom-linux-gnueabi --disable-ipv6 --prefix=~/beaglebone/
I was using Ubuntu and you need to change the build parameter if you have a different architecture. The CONFIG_SITE was another hack I made. Configure grumbled about these missing lines in the config.site file and this was the easiest (but perhaps not the correct) way to silence its grumblings. Essentially, I created a
config.site file in the root of the source directory with the following lines:
I then ran
make altinstall to make sure all the Python 3.3 stuff with have the suffix 3.3. I sftp’ed the files to the Beaglebone and exploded the tar file in the root directory of the file system, but when I run
python3.3 I get the following error:
Could not find platform independent libraries <prefix> Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to [:<exec_prefix>] Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings' Aborted beaglebone:~$
I tried various
PYTHONPATH tweaks, but none seem to do the trick. So, I’m using Python 2.7.2 for the time being. If you happen to successfully get Python 3.3.1 installed, I’d love to hear about it 🙂