Skip to content

Commit 12b60a5

Browse files
committed
update readme to rely on the latest docs
1 parent 3ef81e5 commit 12b60a5

File tree

1 file changed

+2
-252
lines changed

1 file changed

+2
-252
lines changed

README.rst

Lines changed: 2 additions & 252 deletions
Original file line numberDiff line numberDiff line change
@@ -5,257 +5,7 @@ Python for android is a project to create your own Python distribution
55
including the modules you want, and create an apk including python, libs, and
66
your application.
77

8-
In terms of comparaison, you can check how Python for android can be useful
9-
compared to other projects.
8+
Explaination and documentation are available here:
109

11-
+--------------------+---------------+---------------+----------------+--------------+
12-
| Project | Native Python | GUI libraries | APK generation | Custom build |
13-
+====================+===============+===============+================+==============+
14-
| Python for android | Yes | Yes | Yes | Yes |
15-
+--------------------+---------------+---------------+----------------+--------------+
16-
| PGS4A | Yes | Yes | Yes | No |
17-
+--------------------+---------------+---------------+----------------+--------------+
18-
| Android scripting | No | No | No | No |
19-
+--------------------+---------------+---------------+----------------+--------------+
20-
| Python on a chip | No | No | No | No |
21-
+--------------------+---------------+---------------+----------------+--------------+
10+
http://python-for-android.rtfd.org/
2211

23-
.. note::
24-
25-
For the moment, we are shipping only one "java bootstrap" needed for
26-
decompressing all the files of your project, create an OpenGL ES 2.0
27-
surface, handle touch input and manage an audio thread.
28-
29-
If you want to use it without kivy module (an opengl es 2.0 ui toolkit),
30-
then you might want a lighter java bootstrap, that we don't have right now.
31-
Help is welcome :)
32-
33-
34-
Prerequisites
35-
-------------
36-
37-
WARNING: the current version is tested only on Ubuntu oneiric (11.10). If it doesn't work on another platform, send us patch, not bug report.
38-
39-
You need the minimal environment for building python. Note that other libraries
40-
might need other tools (cython is used by some recipes, and ccache to speedup the build)::
41-
42-
sudo apt-get install build-essential patch git-core ccache cython
43-
44-
You must have android SDK and NDK. You can download them at::
45-
46-
http://developer.android.com/sdk/index.html
47-
http://developer.android.com/sdk/ndk/index.html
48-
49-
If it's your very first time into android SDK, don't forget to follow
50-
documentation for recommended components at::
51-
52-
http://developer.android.com/sdk/installing.html#which
53-
54-
You need to download at least one platform into your environment, so
55-
that you will be able to compile your application and set up an Android
56-
Virtual Device (AVD) to run it on (in the emulator). To start with,
57-
just download the latest version of the platform. Later, if you plan to
58-
publish your application, you will want to download other platforms as
59-
well, so that you can test your application on the full range of
60-
Android platform versions that your application supports.
61-
62-
After installing them, export both installation path, NDK version and API to use::
63-
64-
export ANDROIDSDK=/path/to/android-sdk
65-
export ANDROIDNDK=/path/to/android-ndk
66-
export ANDROIDNDKVER=rX
67-
export ANDROIDAPI=X
68-
69-
# example
70-
export ANDROIDSDK="/home/tito/code/android/android-sdk-linux_86"
71-
export ANDROIDNDK="/home/tito/code/android/android-ndk-r7"
72-
export ANDROIDNDKVER=r7
73-
export ANDROIDAPI=14
74-
75-
76-
Usage
77-
-----
78-
79-
Step 1: compile the toolchain
80-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81-
82-
If you want to compile the toolchain with only kivy module::
83-
84-
./distribute.sh -m "kivy"
85-
86-
After a long time, you'll get a "dist/default" directory containing all the compiled
87-
libraries and build.py script to package your application using thoses
88-
libraries.
89-
90-
You can include other libraries to compile using `-m`::
91-
92-
./distribute.sh -m "openssl kivy"
93-
./distribute.sh -m "pil ffmpeg kivy"
94-
95-
Available options to `distribute.sh`::
96-
97-
-d directory Name of the distribution directory
98-
-h Show this help
99-
-l Show a list of available modules
100-
-m 'mod1 mod2' Modules to include
101-
-f Restart from scratch (remove the current build)
102-
103-
Step 2: package your application
104-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105-
106-
Go fo your custom python distribution::
107-
108-
cd dist/default
109-
110-
Use the build.py for creating the APK::
111-
112-
./build.py --package org.test.touchtracer --name touchtracer \
113-
--version 1.0 --dir ~/code/kivy/examples/demo/touchtracer debug
114-
115-
Then, the android package (APK) will be generated at:
116-
117-
bin/touchtracer-1.0-debug.apk
118-
119-
Available options to `build.py`::
120-
121-
-h, --help show this help message and exit
122-
--package PACKAGE The name of the java package the project will be
123-
packaged under.
124-
--name NAME The human-readable name of the project.
125-
--version VERSION The version number of the project. This should consist
126-
of numbers and dots, and should have the same number
127-
of groups of numbers as previous versions.
128-
--numeric-version NUMERIC_VERSION
129-
The numeric version number of the project. If not
130-
given, this is automatically computed from the
131-
version.
132-
--dir DIR The directory containing public files for the project.
133-
--private PRIVATE The directory containing additional private files for
134-
the project.
135-
--launcher Provide this argument to build a multi-app launcher,
136-
rather than a single app.
137-
--icon-name ICON_NAME
138-
The name of the project's launcher icon.
139-
--orientation ORIENTATION
140-
The orientation that the game will display in. Usually
141-
one of "landscape" or "portrait".
142-
--permission PERMISSIONS
143-
The permissions to give this app.
144-
--ignore-path IGNORE_PATH
145-
Ignore path when building the app
146-
--icon ICON A png file to use as the icon for the application.
147-
--presplash PRESPLASH
148-
A jpeg file to use as a screen while the application
149-
is loading.
150-
--install-location INSTALL_LOCATION
151-
The default install location. Should be "auto",
152-
"preferExternal" or "internalOnly".
153-
--compile-pyo Compile all .py files to .pyo, and only distribute the
154-
compiled bytecode.
155-
--blacklist BLACKLIST
156-
Use a blacklist file to match unwanted file in the
157-
final APK
158-
159-
160-
How does it work ?
161-
------------------
162-
163-
To be able to run Python on android, you need to compile it for android. And
164-
you need to compile all the libraries you want for android too.
165-
Since Python is a language, not a toolkit, you cannot draw any user interface
166-
with it: you need to use a toolkit for it. Kivy can be one of them.
167-
168-
So for a simple ui project, the first step is to compile Python + Kivy + all
169-
others libraries. Then you'll have what we call a "distribution".
170-
A distribution is composed of:
171-
172-
- Python libraries
173-
- All selected libraries (kivy, pygame, pil...)
174-
- A java bootstrap
175-
- A build script
176-
177-
You'll use the build script for create an "apk": an android package.
178-
179-
180-
Customize your distribution
181-
---------------------------
182-
183-
The basic layout of a distribution is::
184-
185-
AndroidManifest.xml - (*) android manifest (generated from templates)
186-
assets/
187-
private.mp3 - (*) fake package that will contain all the python installation
188-
public.mp3 - (*) fake package that will contain your application
189-
bin/ - contain all the apk generated from build.py
190-
blacklist.txt - list of file patterns to not include in the APK
191-
buildlib/ - internals libraries for build.py
192-
build.py - build script to use for packaging your application
193-
build.xml - (*) build settings (generated from templates)
194-
default.properties - settings generated from your distribute.sh
195-
libs/ - contain all the compiled libraries
196-
local.properties - settings generated from your distribute.sh
197-
private/ - private directory containing all the python files
198-
lib/ this is where you can remove or add python libs.
199-
python2.7/ by default, some modules are already removed (tests, idlelib, ...)
200-
project.properties - settings generated from your distribute.sh
201-
python-install/ - the whole python installation, generated from distribute.sh
202-
not included in the final package.
203-
res/ - (*) android resource (generated from build.py)
204-
src/ - Java bootstrap
205-
templates/ - Templates used by build.py
206-
207-
(*): Theses files are automatically generated from build.py, don't change them directly !
208-
209-
210-
Available modules
211-
-----------------
212-
213-
List of available modules: jpeg pil png sdl sqlite3 pygame kivy android
214-
libxml2 libxslt lxml ffmpeg openssl chipmunk
215-
216-
The up-to-date list is available at:
217-
https://github.com/kivy/python-for-android/tree/master/recipes
218-
219-
Only hostpython and python are 2 mandatory recipes, used for building
220-
hostpython / target python libraries.
221-
222-
223-
Create your own recipes
224-
-----------------------
225-
226-
A recipe is a script that contain the "definition" of a module to compile.
227-
The directory layout of a recipe for a <modulename> is something like::
228-
229-
python-for-android/recipes/<modulename>/recipe.sh
230-
python-for-android/recipes/<modulename>/patches/
231-
python-for-android/recipes/<modulename>/patches/fix-path.patch
232-
233-
When building, all the recipe build must go to::
234-
235-
python-for-android/build/<modulename>/<archiveroot>
236-
237-
For example, if you want to create a recipe for sdl, do::
238-
239-
cd python-for-android/recipes
240-
mkdir sdl
241-
cp recipe.sh.tmpl sdl/recipe.sh
242-
sed -i 's#XXX#sdl#' sdl/recipe.sh
243-
244-
Then, edit the sdl/recipe.sh to adjust other information (version, url) and
245-
complete build function.
246-
247-
248-
Related project
249-
---------------
250-
251-
- PGS4A: http://pygame.renpy.org/
252-
- Android scripting: http://code.google.com/p/android-scripting/
253-
- Python on a chip: http://code.google.com/p/python-on-a-chip/
254-
255-
256-
TODO
257-
----
258-
259-
- jni/Android.mk must not include ttf/image/mixer if not asked by the user
260-
- Python try always to import name.so, namemodule.so, name.py, name.pyo ?
261-
- restore libpymodules.so loading to reduce the number of dlopen.

0 commit comments

Comments
 (0)