About

Supporting the site

App Repository‎ > ‎Archives‎ > ‎

python-2.7.2

Overview

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

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.

This version uses better compiler flags and the latest releases of the dependencies. It is a much smaller package than the previous one.

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.

Compilation

sudo apt-get install build-essential patch

export DEST=/mnt/DroboFS/Shares/DroboApps/python2
cd ~/code/

wget http://zlib.net/zlib-1.2.6.tar.gz
tar zxf zlib-1.2.6.tar.gz
cd zlib-1.2.6
CFLAGS="$CFLAGS -O3" ./configure --prefix=$DEST --static
make clean && make
ZLIB=`pwd`
cd ..

wget http://www.openssl.org/source/openssl-1.0.1.tar.gz
tar zxf openssl-1.0.1.tar.gz
cd openssl-1.0.1
./Configure linux-generic32 -DL_ENDIAN --prefix=$DEST --openssldir=$DEST/etc/ssl no-shared no-zlib-dynamic --with-zlib-include=$ZLIB --with-zlib-lib=$ZLIB
sed -i -e "s/CFLAG= /CFLAG=${CFLAGS} /g" Makefile
make clean && make && make install_sw
rm -fr $DEST/bin $DEST/include $DEST/lib $DEST/misc
OPENSSL=`pwd`
cd ..

wget http://ftp.gnu.org/pub/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=$DEST --without-shared
make clean && make
cd include
ln -s curses.h ncurses.h
cd ..
NCURSES=`pwd`
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/
make clean
make libbz2.a CC=$CC AR=$AR RANLIB=$RANLIB CFLAGS="$CFLAGS -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64"
BZIP=`pwd`
cd ..

wget http://www.sqlite.org/sqlite-autoconf-3071000.tar.gz
tar zxf sqlite-autoconf-3071000.tar.gz
cd sqlite-autoconf-3071000/
CFLAGS="$CFLAGS -O3" ./configure --host=arm-none-linux-gnueabi --prefix=$DEST --disable-shared
make clean && make
SQLITE=`pwd`
cd ..

wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz
tar zxf Python-2.7.2.tgz
cd Python-2.7.2/
. ~/uncrosscompile.sh
./configure
make python Parser/pgen
mv python hostpython
mv Parser/pgen Parser/hostpgen
make distclean

. ~/crosscompile.sh
wget -O Python-2.7.2-drobofs.patch http://www.droboports.com/app-repository/python-2-7-2/Python-2.7.2-drobofs.patch
patch -p1 < Python-2.7.2-drobofs.patch CFLAGS="$CFLAGS -I$ZLIB -I$OPENSSL/include -I$NCURSES/include -I$BZIP -I$SQLITE" LDFLAGS="$LDFLAGS -L$ZLIB -L$OPENSSL -L$NCURSES/lib -L$BZIP -L$SQLITE/.libs" LIBS="-lsqlite3 -lncurses -lssl -lcrypto -lz -ldl" ./configure --host=arm-none-linux-gnueabi --prefix=$DEST make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen CROSS_COMPILE=arm-none-linux-gnueabi- CROSS_COMPILE_TARGET=yes HOSTARCH=arm-none-linux-gnueabi make install prefix=$DEST HOSTPYTHON=./hostpython CROSS_COMPILE=arm-none-linux-gnueabi- CROSS_COMPILE_TARGET=yes $STRIP $DEST/bin/* chmod u+w $DEST/lib/libpython2.7.a $STRIP $DEST/lib/lib*.a chmod u-w $DEST/lib/libpython2.7.a $STRIP $DEST/lib/python2.7/config/lib*.a

Packaging

cd $DEST
~/bin/package.sh

Installing

Download the TGZ file below and place it in you DroboApps share. If you do not have SSH access, reboot your Drobo. Otherwise, SSH in and type:

/usr/bin/DroboApps.sh install

Final remarks

This is not a conventional DroboApp in the sense that once installed, it is ready for use. This one just makes the Python binaries and libraries available for further use, and does not attempt to change the DroboFS configuration in any way. A good start to make it easier to use can be found here. Also, you can create a link to the perl binary in the proper folder in an SSH session like this:

cd /usr/bin
ln -s /mnt/DroboFS/Shares/DroboApps/python2/bin/python .

To get easy_install execute these commands after Python is installed on the DroboFS:

mkdir -p /mnt/DroboFS/Shares/DroboApps/python2/tmp
cd /mnt/DroboFS/Shares/DroboApps/python2/tmp
export TMPDIR=/mnt/DroboFS/Shares/DroboApps/python2/tmp
wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
sh setuptools-0.6c11-py2.7.egg --prefix=/mnt/DroboFS/Shares/DroboApps/python2

Note: You should replace the above URL for the setuptools.egg with the latest from the easy_install page.

Please visit the DroboSpace forums to leave your comments, suggestions and feedback.

ċ
Python-2.7.2-drobofs.patch
Download
  9k v. 2 Mar 23, 2012, 8:17 AM Ricardo Padilha
ċ
python2.tgz
Download
  11800k v. 2 Mar 23, 2012, 8:32 AM Ricardo Padilha
Comments