Skip to content

Commit 3e47f3d

Browse files
committed
enhance readme + update blacklist to remove other pygame modules
1 parent cec5df6 commit 3e47f3d

File tree

3 files changed

+85
-63
lines changed

3 files changed

+85
-63
lines changed

README.rst

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ bug report.
4141
You need the minimal environment for building python. Note that other libraries
4242
might need other tools::
4343

44-
sudo apt-get install build-essential patch
44+
sudo apt-get install build-essential patch git-core
4545

4646
You must have android SDK and NDK. You can download them at::
4747

4848
http://developer.android.com/sdk/index.html
4949
http://developer.android.com/sdk/ndk/index.html
5050

51-
If it's your very first time into android sdk, don't forget to follow
51+
If it's your very first time into android SDK, don't forget to follow
5252
documentation for recommended components at::
5353

5454
http://developer.android.com/sdk/installing.html#which
@@ -61,7 +61,7 @@ documentation for recommended components at::
6161
well, so that you can test your application on the full range of
6262
Android platform versions that your application supports.
6363

64-
After installing them, export both installation path, ndk version and api to use::
64+
After installing them, export both installation path, NDK version and API to use::
6565

6666
export ANDROIDSDK=/path/to/android-sdk
6767
export ANDROIDNDK=/path/to/android-ndk
@@ -78,37 +78,86 @@ After installing them, export both installation path, ndk version and api to use
7878
Usage
7979
-----
8080

81-
Step 1, compile the toolchain::
81+
Step 1: compile the toolchain
82+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83+
84+
If you want to compile the toolchain with only kivy module::
8285

8386
./distribute.sh -m "kivy"
8487

8588
After a long time, you'll get a "dist/default" directory containing all the compiled
8689
libraries and build.py script to package your application using thoses
8790
libraries.
8891

89-
Step 2, package your application::
90-
91-
cd dist/default
92-
./build.py --package org.test.touchtracer --name touchtracer \
93-
--version 1.0 --dir ~/code/kivy/examples/demo/touchtracer installd
92+
You can include other libraries to compile using `-m`::
9493

95-
Example of other toolchain::
94+
./distribute.sh -m "openssl kivy"
95+
./distribute.sh -m "pil ffmpeg kivy"
9696

97-
./distribute.sh -m "pil kivy"
98-
./distribute.sh -m "openssl python"
99-
100-
# create another distribution in a directory bleh
101-
./distribute.sh -m "openssl kivy" -d bleh
102-
cd dist/bleh
103-
./build.py ...
104-
105-
Available options::
97+
Available options to `distribute.sh`::
10698

10799
-d directory Name of the distribution directory
108100
-h Show this help
109101
-l Show a list of available modules
110102
-m 'mod1 mod2' Modules to include
111103

104+
Step 2: package your application
105+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106+
107+
Go fo your custom python distribution::
108+
109+
cd dist/default
110+
111+
Use the build.py for creating the APK::
112+
113+
./build.py --package org.test.touchtracer --name touchtracer \
114+
--version 1.0 --dir ~/code/kivy/examples/demo/touchtracer debug
115+
116+
Then, the android package (APK) will be generated at:
117+
118+
bin/touchtracer-1.0-debug.apk
119+
120+
Available options to `build.py`::
121+
122+
-h, --help show this help message and exit
123+
--package PACKAGE The name of the java package the project will be
124+
packaged under.
125+
--name NAME The human-readable name of the project.
126+
--version VERSION The version number of the project. This should consist
127+
of numbers and dots, and should have the same number
128+
of groups of numbers as previous versions.
129+
--numeric-version NUMERIC_VERSION
130+
The numeric version number of the project. If not
131+
given, this is automatically computed from the
132+
version.
133+
--dir DIR The directory containing public files for the project.
134+
--private PRIVATE The directory containing additional private files for
135+
the project.
136+
--launcher Provide this argument to build a multi-app launcher,
137+
rather than a single app.
138+
--icon-name ICON_NAME
139+
The name of the project's launcher icon.
140+
--orientation ORIENTATION
141+
The orientation that the game will display in. Usually
142+
one of "landscape" or "portrait".
143+
--permission PERMISSIONS
144+
The permissions to give this app.
145+
--ignore-path IGNORE_PATH
146+
Ignore path when building the app
147+
--icon ICON A png file to use as the icon for the application.
148+
--presplash PRESPLASH
149+
A jpeg file to use as a screen while the application
150+
is loading.
151+
--install-location INSTALL_LOCATION
152+
The default install location. Should be "auto",
153+
"preferExternal" or "internalOnly".
154+
--compile-pyo Compile all .py files to .pyo, and only distribute the
155+
compiled bytecode.
156+
--blacklist BLACKLIST
157+
Use a blacklist file to match unwanted file in the
158+
final APK
159+
160+
112161
How does it work ?
113162
------------------
114163

src/blacklist.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ config/makesetup
99

1010
# unused pygame files
1111
pygame/_camera_*
12+
pygame/camera.pyo
1213
pygame/*.html
1314
pygame/*.bmp
1415
pygame/*.svg
@@ -17,6 +18,11 @@ pygame/pygame_icon.icns
1718
pygame/LGPL
1819
pygame/threads/Py25Queue.pyo
1920
pygame/*.ttf
21+
pygame/mac*
22+
pygame/_numpy*
23+
pygame/sndarray.pyo
24+
pygame/surfarray.pyo
25+
pygame/_arraysurfarray.pyo
2026

2127
# unused kivy files (platform specific)
2228
kivy/input/providers/wm_*
@@ -34,7 +40,6 @@ encodings/cp*.pyo
3440
encodings/tis*
3541
encodings/shift*
3642
encodings/bz2*
37-
encodings/zlib*
3843
encodings/iso*
3944
encodings/undefined*
4045
encodings/johab*

src/build.py

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -194,30 +194,11 @@ def make_package(args):
194194
# Build.
195195
map(lambda arg: subprocess.call([ANT, arg]), args.command)
196196

197-
'''
198-
def shelve_lib(lfn):
199-
for root,dirs,files in os.walk('libs'):
200-
for fn in files:
201-
if fn == lfn:
202-
shelf_dir = os.path.join('.shelf', root)
203-
if not os.path.exists(shelf_dir):
204-
os.makedirs(shelf_dir)
205-
shutil.move(os.path.join(root,fn), shelf_dir)
206-
207-
def unshelve_libs():
208-
if os.path.exists('.shelf'):
209-
for root,dirs,files in os.walk('.shelf'):
210-
for fn in files:
211-
lib_dir = root[len('.shelf/'):]
212-
shutil.move(os.path.join(root,fn), lib_dir)
213-
shutil.rmtree('.shelf')
214-
'''
215-
216197
if __name__ == '__main__':
217198
import argparse
218199

219200
ap = argparse.ArgumentParser(description='''\
220-
Package a Pygame for Android or Ren'Py for Android project.
201+
Package a Python application for Android.
221202
222203
For this to work, Java and Ant need to be in your path, as does the
223204
tools directory of the Android SDK.
@@ -229,7 +210,8 @@ def unshelve_libs():
229210
ap.add_argument('--numeric-version', dest='numeric_version', help='The numeric version number of the project. If not given, this is automatically computed from the version.')
230211
ap.add_argument('--dir', dest='dir', help='The directory containing public files for the project.')
231212
ap.add_argument('--private', dest='private', help='The directory containing additional private files for the project.')
232-
ap.add_argument('--launcher', dest='launcher', action='store_true', help='Provide this argument to build a multi-game lanucher, rather than a single game.')
213+
ap.add_argument('--launcher', dest='launcher', action='store_true',
214+
help='Provide this argument to build a multi-app launcher, rather than a single app.')
233215
ap.add_argument('--icon-name', dest='icon_name', help='The name of the project\'s launcher icon.')
234216
ap.add_argument('--orientation', dest='orientation', default='landscape', help='The orientation that the game will display in. Usually one of "landscape" or "portrait".')
235217
ap.add_argument('--permission', dest='permissions', action='append', help='The permissions to give this app.')
@@ -238,11 +220,10 @@ def unshelve_libs():
238220
ap.add_argument('--presplash', dest='presplash', help='A jpeg file to use as a screen while the application is loading.')
239221
ap.add_argument('--install-location', dest='install_location', default='auto', help='The default install location. Should be "auto", "preferExternal" or "internalOnly".')
240222
ap.add_argument('--compile-pyo', dest='compile_pyo', action='store_true', help='Compile all .py files to .pyo, and only distribute the compiled bytecode.')
241-
#ap.add_argument('--with-sqlite3', dest='with_sqlite3', action='store_true', help='Include sqlite3 module.')
242-
#ap.add_argument('--with-PIL', dest='with_PIL', action='store_true', help='Include the Python Imaging Library (PIL).')
243-
#ap.add_argument('--with-ffmpeg', dest='with_ffmpeg', action='store_true', help='Include the FFMPEG android libraries (PIL).')
244-
245-
ap.add_argument('command', nargs='*', help='The command to pass to ant.')
223+
ap.add_argument('--blacklist', dest='blacklist',
224+
default=join(curdir, 'blacklist.txt'),
225+
help='Use a blacklist file to match unwanted file in the final APK')
226+
ap.add_argument('command', nargs='*', help='The command to pass to ant (debug, release, installd, installr)')
246227

247228
args = ap.parse_args()
248229

@@ -260,24 +241,11 @@ def unshelve_libs():
260241
ap.error('To use --compile-pyo, you need Python 2.7.1 installed and in your PATH.')
261242
BLACKLIST_PATTERNS += ['*.py', '*.pyc']
262243

263-
'''
264-
if not args.with_sqlite3:
265-
BLACKLIST_PATTERNS += ['sqlite3', '_sqlite3.so']
266-
shelve_lib('libsqlite3.so')
267-
268-
if not args.with_PIL:
269-
BLACKLIST_PATTERNS += ['PIL', '_imaging.so', '_imagingft.so', '_imagingmath.so']
270-
271-
if not args.with_ffmpeg:
272-
BLACKLIST_PATTERNS += ['ffmpeg']
273-
'''
274-
275-
with open(join(curdir, 'blacklist.txt')) as fd:
276-
patterns = [x.strip() for x in fd.read().splitlines() if x.strip() or
277-
x.startswith('#')]
244+
if args.blacklist:
245+
with open(args.blacklist) as fd:
246+
patterns = [x.strip() for x in fd.read().splitlines() if x.strip() or
247+
x.startswith('#')]
278248
BLACKLIST_PATTERNS += patterns
279249

280250
make_package(args)
281-
#unshelve_libs()
282-
283251

0 commit comments

Comments
 (0)