PDA

View Full Version : Android : Standalone python scripts



Anant Shrivastava
08-12-2011, 12:40 AM
most of you might already be aware about SL4A, this is a slight change in approach

right now it allows you to run python applications however current security black/white hacking softwares were made with either gui or with complex command line options, both of which fail miserably on sl4a.

now to make this work on android device i needed a standalone python execution script.
i even found one http://code.google.com/p/python-for-android/source/browse/python-build/standalone_python.sh

But then again problem started as this script was giving error in terms of relative referencing of files specially relative folder referencing.

so i have customized the script and using following script.



PW=`pwd`
export EXTERNAL_STORAGE=/mnt/sdcard
export LANG=en
PYTHONPATH=/mnt/sdcard/com.googlecode.pythonforandroid/extras/python
PYTHONPATH=${PYTHONPATH}:/data/data/com.googlecode.pythonforandroid/files/python/lib/python2.6/lib-dynload
export PYTHONPATH
export TEMP=/mnt/storage/com.googlecode.pythonforandroid/extras/python/tmp
export PYTHON_EGG_CACHE=$TEMP
export PYTHONHOME=/data/data/com.googlecode.pythonforandroid/files/python
export LD_LIBRARY_PATH=/data/data/com.googlecode.pythonforandroid/files/python/lib
cd $PW
/data/data/com.googlecode.pythonforandroid/files/python/bin/python $@


named it as py
stored in /system/bin/py
chmod 755 /system/bin/py

now i can run any python script by appending py in front of scripts on terminal.

Original threads
BLOG : http://blog.anantshri.info/android-standalone-python/
XDA Thread : http://forum.xda-developers.com/showthread.php?t=1213719