Skip to content

Commit 967df3c

Browse files
committed
try to bring pynacl to python-for-android. This is hard as pynacl use cffi, and require lot of libs be available in hostpython. And setuptools need to be installed. This shows a way we could handle thoses issues.
1 parent 80eb744 commit 967df3c

File tree

6 files changed

+202
-2
lines changed

6 files changed

+202
-2
lines changed

recipes/cffi/recipe.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
VERSION_cffi=${VERSION_cffi:-0.8.2}
4+
DEPS_cffi=(pycparser)
5+
URL_cffi=https://pypi.python.org/packages/source/c/cffi/cffi-0.8.2.tar.gz
6+
MD5_cffi=37fc88c62f40d04e8a18192433f951ec
7+
BUILD_cffi=$BUILD_PATH/cffi/$(get_directory $URL_cffi)
8+
RECIPE_cffi=$RECIPES_PATH/cffi
9+
10+
function prebuild_cffi() {
11+
true
12+
}
13+
14+
function build_cffi() {
15+
cd $BUILD_cffi
16+
17+
#try cp -f $BUILD_hostpython/build/lib.linux-x86_64-2.7/_io.so $BUILD_PATH/python-install/lib/python2.7/lib-dynload/_io.so
18+
#try cp -f $BUILD_hostpython/build/lib.linux-x86_64-2.7/unicodedata.so $BUILD_PATH/python-install/lib/python2.7/lib-dynload/unicodedata.so
19+
20+
push_arm
21+
22+
export LDFLAGS="$LDFLAGS -L$LIBS_PATH -L$BUILD_hostpython/Modules/_ctypes/libffi/src"
23+
export CFLAGS="$CFLAGS -I$BUILD_cffi/c -I$BUILD_hostpython/Modules/_ctypes/libffi_arm_wince"
24+
#export EXTRA_CFLAGS="--host linux-armv"
25+
26+
try $HOSTPYTHON setup.py build
27+
try $HOSTPYTHON setup.py install -O2
28+
29+
pop_arm
30+
}
31+
32+
function postbuild_cffi() {
33+
true
34+
}

recipes/hostpython/recipe.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
VERSION_hostpython=2.7.2
44
URL_hostpython=http://python.org/ftp/python/$VERSION_hostpython/Python-$VERSION_hostpython.tar.bz2
55
MD5_hostpython=ba7b2f11ffdbf195ee0d111b9455a5bd
6-
7-
# must be generated ?
86
BUILD_hostpython=$BUILD_PATH/hostpython/$(get_directory $URL_hostpython)
97
RECIPE_hostpython=$RECIPES_PATH/hostpython
108

9+
export HOSTPYTHON_SITEPACKAGES="$BUILD_PATH/hostpython/site-packages"
10+
export PYTHONPATH="$PYTHONPATH:$HOSTPYTHON_SITEPACKAGES/lib/python2.7:$HOSTPYTHON_SITEPACKAGES/lib/python2.7/site-packages"
11+
1112
function prebuild_hostpython() {
1213
cd $BUILD_hostpython
1314
try cp $RECIPE_hostpython/Setup Modules/Setup
@@ -36,6 +37,18 @@ function build_hostpython() {
3637
error "Unable to found the python executable?"
3738
exit 1
3839
fi
40+
41+
42+
# install setuptools for easier port of python extension
43+
cd $BUILD_PATH
44+
if [ ! -f setuptools-5.1.tar.gz ]; then
45+
try wget "https://pypi.python.org/packages/source/s/setuptools/setuptools-5.1.tar.gz#md5=c26e47ce8d7b46bd354e68301f410fb8"
46+
fi
47+
tar xzf setuptools-5.1.tar.gz
48+
cd setuptools-5.1
49+
echo $BUILD_hostpython/hostpython setup.py install --prefix $HOSTPYTHON_SITEPACKAGES
50+
51+
cp -a $BUILD_hostpython/build/lib.*/*.so $HOSTPYTHON_SITEPACKAGES/lib/python2.7
3952
}
4053

4154
function postbuild_hostpython() {

recipes/libsodium/recipe.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
VERSION_libsodium=${VERSION_libsodium:-0.5.0}
4+
URL_libsodium=https://download.libsodium.org/libsodium/releases/libsodium-$VERSION_libsodium.tar.gz
5+
DEPS_libsodium=(kivy)
6+
MD5_libsodium=6e61dbde3a6b06b898a0e18ca27ab161
7+
BUILD_libsodium=$BUILD_PATH/libsodium/$(get_directory $URL_libsodium)
8+
RECIPE_libsodium=$RECIPES_PATH/libsodium
9+
10+
function prebuild_libsodium() {
11+
true
12+
}
13+
14+
function shouldbuild_libsodium() {
15+
if [ -f "$BUILD_libsodium/lib/libsodium.a" ]; then
16+
DO_BUILD=0
17+
fi
18+
}
19+
20+
function build_libsodium() {
21+
cd $BUILD_libsodium
22+
#read -p "try to build, Press enter to continue (smurfy)..."
23+
push_arm
24+
25+
try ./configure --build=i686-pc-linux-gnu --host=arm-linux-eabi --prefix=$BUILD_libsodium/build/
26+
try make install
27+
28+
pop_arm
29+
}
30+
31+
function postbuild_libsodium() {
32+
true
33+
}

recipes/pycparser/recipe.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
VERSION_pycparser=${VERSION_pycparser:-2.10}
4+
DEPS_pycparser=(kivy)
5+
URL_pycparser=https://pypi.python.org/packages/source/p/pycparser/pycparser-2.10.tar.gz
6+
MD5_pycparser=d87aed98c8a9f386aa56d365fe4d515f
7+
BUILD_pycparser=$BUILD_PATH/pycparser/$(get_directory $URL_pycparser)
8+
RECIPE_pycparser=$RECIPES_PATH/pycparser
9+
10+
# function called for preparing source code if needed
11+
# (you can apply patch etc here.)
12+
function prebuild_pycparser() {
13+
true
14+
}
15+
16+
# function called to build the source code
17+
function build_pycparser() {
18+
cd $BUILD_pycparser
19+
push_arm
20+
try $HOSTPYTHON setup.py install -O2
21+
pop_arm
22+
}
23+
24+
# function called after all the compile have been done
25+
function postbuild_pycparser() {
26+
true
27+
}

recipes/pynacl/recipe.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
VERSION_pynacl=${VERSION_pynacl:-0.2.3}
4+
DEPS_pynacl=(libsodium)
5+
URL_pynacl=https://pypi.python.org/packages/source/P/PyNaCl/PyNaCl-0.2.3.tar.gz
6+
MD5_pynacl=eb78a000454e878ee77f574d3c90e344
7+
BUILD_pynacl=$BUILD_PATH/pynacl/$(get_directory $URL_pynacl)
8+
RECIPE_pynacl=$RECIPES_PATH/pynacl
9+
10+
function prebuild_pynacl() {
11+
true
12+
}
13+
14+
function shouldbuild_pynacl() {
15+
# if [ -d "$SITEPACKAGES_PATH/libsodium" ]; then
16+
# DO_BUILD=0
17+
# fi
18+
true
19+
}
20+
21+
function build_pynacl() {
22+
23+
24+
cd $BUILD_pynacl
25+
26+
# export CC="$CC -I$BUILD_pynacl/_lib"
27+
# export LDFLAGS="$LDFLAGS -L$LIBS_PATH -L$BUILD_pynacl"
28+
#
29+
# export EXTRA_CFLAGS="--host linux-armv"
30+
# try $HOSTPYTHON setup.py install -O2
31+
32+
push_arm
33+
export SODIUM_INSTALL="system"
34+
35+
export LDFLAGS="$LDFLAGS -L$LIBS_PATH -L$BUILD_hostpython/Modules/_ctypes/libffi/src"
36+
export CFLAGS="$CFLAGS -I$BUILD_cffi/c -I$BUILD_hostpython/Modules/_ctypes/libffi_arm_wince"
37+
export CFLAGS="$CFLAGS -I$BUILD_libsodium/build/include"
38+
export LDFLAGS="$LDFLAGS -L$BUILD_libsodium/build/lib"
39+
40+
try $HOSTPYTHON setup.py build -f -v
41+
try $HOSTPYTHON setup.py install -O2 -f -v
42+
43+
pop_arm
44+
return
45+
46+
export CC="$CC -I$BUILD_libsodium/include -I/home/cryptoloft/Downloads/kivy-remote-shell/.buildozer/android/platform/python-for-android/build/hostpython/Python-2.7.2/Modules/_ctypes/libffi/build/lib/libffi-3.0.10rc0/include"
47+
export LDFLAGS="$LDFLAGS -L$LIBS_PATH -L$BUILD_libsodium/lib -L/home/cryptoloft/Downloads/kivy-remote-shell/.buildozer/android/platform/python-for-android/build/hostpython/Python-2.7.2/Modules/_ctypes/libffi/build/lib"
48+
49+
read -p "try to build, Press enter to continue (smurfy)..."
50+
51+
export PYTHONPATH=$BUILD_PATH/hostpython/Python-2.7.2/Lib/site-packages
52+
try $BUILD_PATH/hostpython/Python-2.7.2/hostpython setup.py install -O2 --root=$BUILD_PATH/python-install --install-lib=lib/python2.7/site-packages
53+
54+
#try $HOSTPYTHON setup.py build_ext -v
55+
# try find build/lib.* -name "*.o" -exec $STRIP {} \;
56+
#try $HOSTPYTHON setup.py install -O2
57+
58+
# try rm -rf $SITEPACKAGES/libsodium/test
59+
60+
pop_arm
61+
}
62+
63+
# function called after all the compile have been done
64+
function postbuild_pynacl() {
65+
true
66+
}

recipes/six/recipe.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
VERSION_six=${VERSION_six:-1.7.2}
4+
DEPS_six=()
5+
URL_six=https://pypi.python.org/packages/source/s/six/six-1.7.2.tar.gz
6+
MD5_six=4c26276583b01dfc73474cb32327af91
7+
BUILD_six=$BUILD_PATH/six/$(get_directory $URL_six)
8+
RECIPE_six=$RECIPES_PATH/six
9+
10+
# function called for preparing source code if needed
11+
# (you can apply patch etc here.)
12+
function prebuild_six() {
13+
true
14+
}
15+
16+
# function called to build the source code
17+
function build_six() {
18+
cd $BUILD_six
19+
push_arm
20+
try $HOSTPYTHON setup.py install -O2
21+
pop_arm
22+
}
23+
24+
# function called after all the compile have been done
25+
function postbuild_six() {
26+
true
27+
}

0 commit comments

Comments
 (0)