Create statically linked python interpreter with depdendencies

To facilitate the running of tests on machines that run outdated versions of python (e.x. planetlab) we want a way to compile python 2.7 as statically linked binary.

I did some cursory research and testing to get this working, but have reached the point where I can build a python binary that is statically linked, but it does not include all the compiled modules required by ooniprobe.

I my machine I did so with:


CC="gcc -m32" LDFLAGS="-L/lib32 -L/usr/lib32 -L`pwd`/lib32 -Wl,-rpath,/lib32 -Wl,-rpath,/usr/lib32" ./configure LDFLAGS="-static -static-libgcc" CPPFLAGS="-static"

This is required because it's 64 bit on a 32bit machine it's probably sufficient to do


./configure LDFLAGS="-static -static-libgcc" CPPFLAGS="-static"

Here are a collection of links that may be useful.

http://stackoverflow.com/questions/1150373/compile-the-python-interpreter-statically

https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/667470

http://sourceware.org/bugzilla/show_bug.cgi?id=13490

http://stackoverflow.com/questions/9541609/using-linux-c-shared-and-static-libraries-in-a-same-program

http://www.airs.com/blog/archives/category/programming/page/23

http://askubuntu.com/questions/63711/building-a-static-version-of-python

https://bugzilla.redhat.com/show_bug.cgi?id=606830

http://stackoverflow.com/questions/47953/what-are-the-advantages-of-packaging-your-python-library-application-as-an-egg