Skip to content
This repository was archived by the owner on Jan 18, 2024. It is now read-only.

Commit b68f8b9

Browse files
committed
Add build script for QPy36
1 parent c97c1ef commit b68f8b9

File tree

9 files changed

+140
-0
lines changed

9 files changed

+140
-0
lines changed

mk/qpyc3/bin/end.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/system/bin/sh
2+
echo ""
3+
echo "#[QPython] The terminal will be closed in 3 seconds ..."
4+
echo ""
5+
6+
sleep 4
7+
exit
8+
9+
#while read inputline
10+
#do
11+
#exit
12+
#done

mk/qpyc3/bin/pip3

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==1.0','console_scripts','pip'
2+
__requires__ = 'pip==1.2.1'
3+
import sys
4+
from pkg_resources import load_entry_point
5+
6+
if __name__ == '__main__':
7+
sys.exit(
8+
load_entry_point('pip==1.2.1', 'console_scripts', 'pip')()
9+
)

mk/qpyc3/bin/pip4console3.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#qpy:console
2+
import os,os.path,sys
3+
#sys.dont_write_bytecode = True
4+
5+
def modcmd(arg):
6+
os.system(sys.executable+" "+sys.prefix+"/bin/"+arg)
7+
8+
if not(os.path.exists(sys.prefix+"/bin/pip3")):
9+
print("You need to install pip3 first.")
10+
print("Input pip commands, ie: pip3 install {module}")
11+
while(True):
12+
cmd=input("-->")
13+
if (cmd==""): break;
14+
modcmd(cmd)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/system/bin/sh
2+
DIR=${0%/*}
3+
test=$DIR'/init.sh && '$DIR'/python3-android5 '"$@"' && '$DIR'/end.sh'
4+
cat $DIR/init.sh > $DIR/python3-android5-root
5+
echo '\n' >> $DIR/python3-android5-root
6+
echo $test >> $DIR/python3-android5-root
7+
chmod 755 $DIR/python3-android5-root
8+
su -c $DIR/python3-android5-root

mk/qpyc3/bin/qpython3-android5.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/system/bin/sh
2+
DIR=${0%/*}
3+
. $DIR/init.sh && $DIR/python3-android5 "$@" && $DIR/end.sh

mk/qpyc3/bin/qpython3-root.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/system/bin/sh
2+
DIR=${0%/*}
3+
test=$DIR'/init.sh && '$DIR'/python3 '"$@"' && '$DIR'/end.sh'
4+
cat $DIR/init.sh > $DIR/python3-root
5+
echo '\n' >> $DIR/python3-root
6+
echo $test >> $DIR/python3-root
7+
chmod 755 $DIR/python3-root
8+
su -c $DIR/python3-root

mk/qpyc3/bin/qpython3.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/system/bin/sh
2+
DIR=${0%/*}
3+
. $DIR/init.sh && $DIR/python3 "$@" && $DIR/end.sh
4+

mk/qpyc3/bin/share3.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#qpy:qpyapp
2+
"""
3+
Share script
4+
"""
5+
import glob
6+
import os
7+
import sys
8+
import androidhelper
9+
droid = androidhelper.Android()
10+
11+
_scripts = glob.glob("/sdcard/qpython/scripts3/*.py")
12+
scripts = []
13+
for x in _scripts:
14+
scripts.append(os.path.basename(x))
15+
16+
droid.dialogCreateAlert("Run QPython3 script...")
17+
droid.dialogSetItems(scripts)
18+
droid.dialogShow()
19+
20+
response = droid.dialogGetResponse().result
21+
22+
if 'item' in response:
23+
script = _scripts[response['item']]
24+
argv1 = len(sys.argv)>1 and sys.argv[1] or ''
25+
os.execle(sys.executable, os.path.basename(sys.executable), script, argv1, os.environ)
26+
else:
27+
droid.makeToast("You cancel the share")

qpyc36.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
#
3+
# This script could export the QPython3's asset file like private(x).mp3
4+
# @Author: River
5+
#
6+
7+
# Please set the correct STRIP for your platform
8+
STRIP=${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip
9+
10+
ROOT=`pwd`
11+
DST=${ROOT}/build/qpyc36
12+
PYSRC=${ROOT}/build/target/python
13+
ASSRC=${ROOT}/mk/qpyc3
14+
mkdir -p $DST
15+
16+
# clean old resources
17+
cd $DST && rm -fr *
18+
19+
echo Python3.6.4 > PY3VER
20+
21+
22+
# Init dir structures
23+
24+
DIRS="
25+
bin
26+
include
27+
include/python3.6m
28+
lib
29+
lib/python3.6
30+
lib/python3.6/config-3.6m
31+
lib/python3.6/lib-dynload
32+
lib/python3.6/site-packages
33+
"
34+
35+
for item in $DIRS
36+
do echo $item;
37+
mkdir -p $item
38+
done
39+
40+
find ${PYSRC} -name __pycache__ -exec rm -fr {} \;
41+
42+
# Copy resources
43+
cp ${PYSRC}/usr/bin/python3.6m $DST/bin/python3-android5
44+
cp $ASSRC/bin/* $DST/bin
45+
cp ${PYSRC}/usr/lib/python3.6/config-3.6m/Makefile $DST/lib/python3.6/config-3.6m
46+
cp ${PYSRC}/usr/lib/python3.6/lib-dynload/* $DST/lib/python3.6/lib-dynload
47+
cd ${PYSRC}/usr/lib/python3.6 && zip -r $DST/lib/python36.zip * --exclude lib-dynload
48+
49+
# Strip
50+
$STRIP $DST/bin/python3-android5
51+
find $DST/lib/python3.6/lib-dynload -name "*.so" -exec $STRIP {} \;
52+
53+
# Package
54+
cd $DST && tar -czvf ../qpyc3.mp3 *
55+

0 commit comments

Comments
 (0)