About

Supporting the site

App Repository‎ > ‎

python-2.7.3

Overview

Python requires zlib, openssl, ncurses, bzip, SQlite3 and libffi.

Python is not very cross-compile friendly because it uses some binaries generated during the compilation procedure for the rest of the compilation. Therefore we do a two-pass compilation, one natively to get the required binaries, and once again to cross-compile. All the dependencies are statically linked to make deployment easier.

Acknowledgements

The original version of the patch used to make python cross-compilable comes from here. The patch used in this version is augmented to allow static compilation using libraries not on the standard locations.

Preparation

Make sure you have a cross-compiling virtual machine properly setup, and to source the appropriate cross-compilation environment variables before starting the cross-compilation.

Compilation

Native compilation of Python:

cd ~/code/
. ~/uncrosscompile.sh
wget -O Python-2.7.3.tgz http://python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar zxf Python-2.7.3.tgz
mv Python-2.7.3 Python-2.7.3-native
cd Python-2.7.3-native/
make clean && make
cd ..

Cross-compilation:

cd ~/code/

export DEST=/mnt/DroboFS/Shares/DroboApps/python2
export DEPS=/mnt/DroboFS/Shares/DroboApps/python2deps
export CFLAGS="$CFLAGS -Os -fPIC -ffunction-sections -fdata-sections"
export LDFLAGS="$LDFLAGS -Wl,--gc-sections"

wget -O zlib-1.2.7.tar.gz http://zlib.net/zlib-1.2.7.tar.gz
tar zxf zlib-1.2.7.tar.gz
cd zlib-1.2.7/
./configure --prefix=$DEPS --static
make clean && make && make install
cd ..

wget http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar zxf bzip2-1.0.6.tar.gz 
cd bzip2-1.0.6/
sed -i -e "s/all: libbz2.a bzip2 bzip2recover test/all: libbz2.a bzip2 bzip2recover/" Makefile
make clean && make CC=$CC AR=$AR RANLIB=$RANLIB CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64" && make install PREFIX=$DEPS
cd ..

wget -O openssl-1.0.1e.tar.gz http://www.openssl.org/source/openssl-1.0.1e.tar.gz
tar zxf openssl-1.0.1e.tar.gz
cd openssl-1.0.1e/
./Configure --prefix=$DEPS --openssldir=$DEST/etc/ssl --with-zlib-include=$DEPS/include --with-zlib-lib=$DEPS/lib no-shared no-zlib-dynamic threads linux-armv4 -DL_ENDIAN $CFLAGS $LDFLAGS
make -j1 clean && make -j1 && make -j1 install_sw
cd ..

wget -O ncurses-5.9.tar.gz http://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz
tar zxf ncurses-5.9.tar.gz
cd ncurses-5.9/
./configure --host=arm-none-linux-gnueabi --prefix=$DEPS --without-shared
make clean && make && make install
cd ..

wget -O sqlite-autoconf-3071502.tar.gz http://sqlite.org/sqlite-autoconf-3071502.tar.gz
tar zxf sqlite-autoconf-3071502.tar.gz
cd sqlite-autoconf-3071502/
./configure --host=arm-none-linux-gnueabi --prefix=$DEPS --disable-shared
make clean && make && make install
cd ..

wget -O libffi-3.0.12.tar.gz ftp://sourceware.org/pub/libffi/libffi-3.0.12.tar.gz
tar zxf libffi-3.0.12.tar.gz
cd libffi-3.0.12/
./configure --host=arm-none-linux-gnueabi --prefix=$DEPS --disable-shared
make clean && make && make install
cd ..

wget -O Python-2.7.3.tgz http://python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar zxf Python-2.7.3.tgz
cd Python-2.7.3/
cp ../Python-2.7.3-native/python hostpython
cp ../Python-2.7.3-native/Parser/pgen hostpgen
wget -O python-drobo.patch http://www.droboports.com/app-repository/python-2-7-3/python-drobo.patch
patch -N < python-drobo.patch
PKG_CONFIG_LIBDIR=$DEPS/lib/pkgconfig ./configure --host=arm-none-linux-gnueabi --prefix=$DEST --enable-shared --with-system-ffi CPPFLAGS="-I$DEPS/include -I$DEPS/include/ncurses -I$TOOLCHAIN/arm-none-linux-gnueabi/libc/usr/include" LDFLAGS="$LDFLAGS -L$DEPS/lib -Wl,-rpath,$DEST/lib"
make clean && make install CROSS_COMPILE_TARGET=yes CROSS_COMPILE=arm-none-linux-gnueabi- HOSTARCH=arm-none-linux-gnueabi HOSTPYTHON=./hostpython HOSTPGEN=./hostpgen HOSTPATH=../Python-2.7.3-native/build/lib.linux-i686-2.7
find $DEST -name "test" -exec rm -fr "{}" \;
find $DEST -name "tests" -exec rm -fr "{}" \;
$STRIP -s -R .comment -R .note -R .note.ABI-tag $DEST/bin/python2.7
chmod u+w $DEST/lib/libpython2.7.so.1.0
$STRIP -s -R .comment -R .note -R .note.ABI-tag $DEST/lib/libpython2.7.so.1.0
chmod u-w $DEST/lib/libpython2.7.so.1.0
$STRIP -s -R .comment -R .note -R .note.ABI-tag $DEST/lib/python2.7/lib-dynload/*.so

Packaging

cd $DEST
mkdir tmp
chmod a+rwx tmp
~/bin/package.sh

Final remarks

Ready to install versions can be found in the subpages below. Please visit the DroboSpace forums to leave your comments, suggestions and feedback.

ċ
python-drobo.patch
Download
  9k v. 1 Mar 8, 2013, 2:16 AM Ricardo Padilha
Subpages (2): Drobo5N DroboFS
Comments