Skip to content

Commit bca97c0

Browse files
committed
Merge branch 'master' into prebuild
2 parents 488ea4b + 244e28b commit bca97c0

File tree

10 files changed

+320
-92
lines changed

10 files changed

+320
-92
lines changed

distribute.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,30 @@ if [ "X$PYTHON" == "X" ]; then
1818
PYTHON="$(which python)"
1919
fi
2020

21+
# Resolve pip path
22+
PIP_NAME="$(which pip-2.7)"
23+
if [ "X$PIP_NAME" == "X" ]; then
24+
PIP_NAME="$(which pip2.7)"
25+
fi
26+
if [ "X$PIP_NAME" == "X" ]; then
27+
PIP_NAME="$(which pip2)"
28+
fi
29+
if [ "X$PIP_NAME" == "X" ]; then
30+
PIP_NAME="$(which pip)"
31+
fi
32+
33+
# Resolve virtualenv path
34+
VIRTUALENV_NAME="$(which virtualenv-2.7)"
35+
if [ "X$VIRTUALENV_NAME" == "X" ]; then
36+
VIRTUALENV_NAME="$(which virtualenv2.7)"
37+
fi
38+
if [ "X$VIRTUALENV_NAME" == "X" ]; then
39+
VIRTUALENV_NAME="$(which virtualenv2)"
40+
fi
41+
if [ "X$VIRTUALENV_NAME" == "X" ]; then
42+
VIRTUALENV_NAME="$(which virtualenv)"
43+
fi
44+
2145
# Paths
2246
ROOT_PATH="$(dirname $($PYTHON -c 'from __future__ import print_function; import os,sys;print(os.path.realpath(sys.argv[1]))' $0))"
2347
RECIPES_PATH="$ROOT_PATH/recipes"
@@ -35,7 +59,8 @@ HOSTPYTHON="$BUILD_PATH/python-install/bin/python.host"
3559
export LIBLINK_PATH="$BUILD_PATH/objects"
3660
export LIBLINK="$ROOT_PATH/src/tools/liblink"
3761
export BIGLINK="$ROOT_PATH/src/tools/biglink"
38-
export PIP="pip-2.7"
62+
export PIP=$PIP_NAME
63+
export VIRTUALENV=$VIRTUALENV_NAME
3964

4065
MD5SUM=$(which md5sum)
4166
if [ "X$MD5SUM" == "X" ]; then

docs/source/android.rst

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
Python API
22
==========
33

4-
Python for android project include a "android" python module. The module is
5-
composed of multiple part, mostly done for a easier usage of Java API. The
6-
module is not designed to wrap anything you want.
4+
The Python for android project includes a Python module called "android". It
5+
consists of multiple parts which are mostly there to facilitate the use of the Java API.
76

8-
Most of the Java API is accessible with PyJNIus, and then. prefer to see if you
9-
can use Java API directly first.
7+
This module is not designed to be comprehensive. Most of the Java API is also accessible with PyJNIus,
8+
so if you can't find what you need here you can try using the Java API directly instead.
109

1110

1211
Android (``android``)
@@ -17,18 +16,18 @@ Android (``android``)
1716
.. function:: check_pause()
1817

1918
This should be called on a regular basis to check to see if Android
20-
expects the game to pause. If it return true, the game should call
21-
:func:`android.wait_for_resume()`, after persisting its state as necessary.
19+
expects the application to pause. If it returns true, the app should call
20+
:func:`android.wait_for_resume()`, after storing its state as necessary.
2221

2322
.. function:: wait_for_resume()
2423

25-
This function should be called after :func:`android.check_pause()` returns
24+
This function should be called after :func:`android.check_pause()` and returns
2625
true. It does not return until Android has resumed from the pause. While in
27-
this function, Android may kill a game without further notice.
26+
this function, Android may kill the app without further notice.
2827

2928
.. function:: map_key(keycode, keysym)
3029

31-
This maps between an android keycode and a python keysym. The android
30+
This maps an android keycode to a python keysym. The android
3231
keycodes are available as constants in the android module.
3332

3433

@@ -37,7 +36,7 @@ Activity (``android.activity``)
3736

3837
.. module:: android.activity
3938

40-
The default PythonActivity have a observer pattern for `onActivityResult <http://developer.android.com/reference/android/app/Activity.html#onActivityResult(int, int, android.content.Intent)>`_ and `onNewIntent <http://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)>`_.
39+
The default PythonActivity has a observer pattern for `onActivityResult <http://developer.android.com/reference/android/app/Activity.html#onActivityResult(int, int, android.content.Intent)>`_ and `onNewIntent <http://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)>`_.
4140

4241
.. function:: bind(eventname=callback, ...)
4342

@@ -51,8 +50,7 @@ The default PythonActivity have a observer pattern for `onActivityResult <http:/
5150

5251
Example::
5352

54-
# this example is a snippet from an NFC p2p app, and are located into a
55-
# kivy App class implementation
53+
# This example is a snippet from an NFC p2p app implemented with Kivy.
5654

5755
from android import activity
5856

@@ -81,9 +79,9 @@ Billing (``android.billing``)
8179

8280
.. module:: android.billing
8381

84-
This billing module give an access to the `In-App Billing <http://developer.android.com/guide/google/play/billing/billing_overview.html>`_:
82+
This billing module gives an access to the `In-App Billing <http://developer.android.com/guide/google/play/billing/billing_overview.html>`_:
8583

86-
#. `Setup a test accounts <http://developer.android.com/guide/google/play/billing/billing_admin.html#billing-testing-setup>`_, and get your Public Key
84+
#. `Setup a test account <http://developer.android.com/guide/google/play/billing/billing_admin.html#billing-testing-setup>`_, and get your Public Key
8785
#. Export your public key::
8886

8987
export BILLING_PUBKEY="Your public key here"
@@ -104,18 +102,18 @@ This billing module give an access to the `In-App Billing <http://developer.andr
104102
# Start the billing service, and attach our callback
105103
self.service = BillingService(billing_callback)
106104

107-
# Start a clock to check billing service message every seconds
105+
# Start a clock to check billing service message every second
108106
Clock.schedule_interval(self.service.check, 1)
109107

110108
def billing_callback(self, action, *largs):
111-
'''Callback that will receive all the event from the Billing service
109+
'''Callback that will receive all the events from the Billing service
112110
'''
113111
if action == BillingService.BILLING_ACTION_ITEMSCHANGED:
114112
items = largs[0]
115113
if 'org.kivy.gopremium' in items:
116-
print 'Congratulation, you have a premium acess'
114+
print "Congratulations, you have a premium acess"
117115
else:
118-
print 'Unfortunately, you dont have premium access'
116+
print "Unfortunately, you don't have premium access"
119117

120118
def buy(self, sku):
121119
# Method to buy something.
@@ -125,7 +123,7 @@ This billing module give an access to the `In-App Billing <http://developer.andr
125123
# Return all the items purchased
126124
return self.service.get_purchased_items()
127125

128-
#. To initiate a in-app purchase, just call the buy method::
126+
#. To initiate an in-app purchase, just call the buy() method::
129127

130128
# Note: start the service at the start, and never twice!
131129
bs = MyBillingService()
@@ -136,7 +134,7 @@ This billing module give an access to the `In-App Billing <http://developer.andr
136134
print bs.get_purchased_items()
137135
{'org.kivy.gopremium': {'qt: 1}}
138136

139-
#. You'll receive all the notification about the billing process in the callback.
137+
#. You'll receive all the notifications about the billing process in the callback.
140138

141139
#. Last step, create your application with `--with-billing $BILLING_PUBKEY`::
142140

@@ -157,8 +155,8 @@ or categories filters.
157155

158156
.. warning::
159157

160-
The callback will be called in another thread than the main thread. Be
161-
careful to not access to OpenGL or something like that.
158+
The callback will be called in another thread than the main thread. In
159+
that thread, be careful not to access OpenGL or something like that.
162160

163161
.. method:: __init__(callback, actions=None, categories=None)
164162

@@ -200,7 +198,7 @@ Example::
200198
else:
201199
print 'The headset is unplugged'
202200

203-
# don't forget to stop and restart the receiver when the app is going
201+
# Don't forget to stop and restart the receiver when the app is going
204202
# to pause / resume mode
205203

206204
def on_pause(self):
@@ -225,26 +223,26 @@ intended to be imported as an alternative to pygame.mixer, using code like: ::
225223
except ImportError:
226224
import android.mixer as mixer
227225

228-
Note that if you're using `kivy.core.audio
226+
Note that if you're using the `kivy.core.audio
229227
<http://kivy.org/docs/api-kivy.core.audio.html>`_ module, you don't have to do
230-
anything, all is automatic.
228+
anything, it is all automatic.
231229

232230
The `android.mixer` module is a wrapper around the Android MediaPlayer
233231
class. This allows it to take advantage of any hardware acceleration
234232
present, and also eliminates the need to ship codecs as part of an
235233
application.
236234

237-
It has several differences from the pygame mixer:
235+
It has several differences with the pygame mixer:
238236

239-
* The init and pre_init methods work, but are ignored - Android chooses
240-
appropriate setting automatically.
237+
* The init() and pre_init() methods work, but are ignored - Android chooses
238+
appropriate settings automatically.
241239

242240
* Only filenames and true file objects can be used - file-like objects
243241
will probably not work.
244242

245243
* Fadeout does not work - it causes a stop to occur.
246244

247-
* Looping is all or nothing, there's no way to choose the number of
245+
* Looping is all or nothing, there is no way to choose the number of
248246
loops that occur. For looping to work, the
249247
:func:`android.mixer.periodic` function should be called on a
250248
regular basis.
@@ -304,13 +302,13 @@ This can be used to prevent errors like:
304302
Service (``android.service``)
305303
-----------------------------
306304

307-
Service part of the application is controlled through the class :class:`AndroidService`.
305+
Services of an application are controlled through the class :class:`AndroidService`.
308306

309307
.. module:: android.service
310308

311309
.. class:: AndroidService(title, description)
312310

313-
Run ``service/main.py`` from application directory as a service.
311+
Run ``service/main.py`` from the application directory as a service.
314312

315313
:param title: Notification title, default to 'Python service'
316314
:param description: Notification text, default to 'Kivy Python service started'
@@ -321,8 +319,8 @@ Service part of the application is controlled through the class :class:`AndroidS
321319

322320
Start the service.
323321

324-
:param arg: Argument to pass to a service, through environment variable
325-
``PYTHON_SERVICE_ARGUMENT``, default to ''
322+
:param arg: Argument to pass to a service, through the environment variable
323+
``PYTHON_SERVICE_ARGUMENT``. Defaults to ''
326324
:type arg: str
327325

328326
.. method:: stop()
@@ -359,7 +357,7 @@ Application service part example, ``service/main.py``:
359357
arg = os.getenv('PYTHON_SERVICE_ARGUMENT')
360358
361359
while True:
362-
# this will print 'Hello From Service' continually, even when application is switched
360+
# this will print 'Hello From Service' continually, even when the application is switched
363361
print arg
364362
time.sleep(1)
365363

docs/source/prerequisites.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ might need other tools (cython is used by some recipes, and ccache to speedup th
1818

1919
If you are on a 64 bit distro, you should install these packages too ::
2020

21-
sudo apt-get install ia32-libs and libc6-dev-i386
21+
sudo apt-get install ia32-libs libc6-dev-i386
2222

2323
On debian Squeeze amd64, those packages were found to be necessary ::
2424

recipes/android/src/android/broadcast.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,19 @@ def __init__(self, callback, actions=None, categories=None):
2424
if not actions and not categories:
2525
raise Exception('You need to define at least actions or categories')
2626

27-
# resolve actions/categories first
28-
Intent = autoclass('android.content.Intent')
29-
resolved_actions = []
30-
if actions:
31-
for x in actions:
32-
name = 'ACTION_{}'.format(x.upper())
27+
def _expand_partial_name(partial_name):
28+
if '.' in partial_name:
29+
return partial_name # Its actually a full dotted name
30+
else:
31+
name = 'ACTION_{}'.format(partial_name.upper())
3332
if not hasattr(Intent, name):
3433
raise Exception('The intent {} doesnt exist'.format(name))
35-
resolved_actions += [getattr(Intent, name)]
34+
return getattr(Intent, name)
3635

37-
resolved_categories = []
38-
if categories:
39-
for x in categories:
40-
name = 'CATEGORY_{}'.format(x.upper())
41-
if not hasattr(Intent, name):
42-
raise Exception('The intent {} doesnt exist'.format(name))
43-
resolved_categories += [getattr(Intent, name)]
36+
# resolve actions/categories first
37+
Intent = autoclass('android.content.Intent')
38+
resolved_actions = [_expand_partial_name(x) for x in actions or []]
39+
resolved_categories = [_expand_partial_name(x) for x in categories or []]
4440

4541
# resolve android API
4642
PythonActivity = autoclass('org.renpy.android.PythonActivity')

recipes/c_igraph/recipe.sh

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ BUILD_c_igraph=$BUILD_PATH/c_igraph/$(get_directory $URL_c_igraph)
1919
RECIPE_c_igraph=$RECIPES_PATH/c_igraph
2020

2121
function prebuild_c_igraph() {
22-
true
22+
if [ ! -e $BUILD_c_igraph/.patched ]; then {
23+
try patch $BUILD_c_igraph/src/Makefile.am $RECIPE_c_igraph/Makefile.am.patch;
24+
try cp -f $RECIPE_c_igraph/arith.h $BUILD_c_igraph/src/f2c/arith.h;
25+
try patch $BUILD_c_igraph/src/f2c/sysdep1.h $RECIPE_c_igraph/sysdep1.h.patch;
26+
try patch $BUILD_c_igraph/src/f2c/uninit.c $RECIPE_c_igraph/uninit.c.patch;
27+
touch $BUILD_c_igraph/.patched;
28+
}
29+
fi
2330
}
2431

2532
function shouldbuild_c_igraph() {
@@ -32,15 +39,14 @@ function build_c_igraph() {
3239
cd $BUILD_c_igraph
3340

3441
push_arm
35-
patch -Nr - $BUILD_c_igraph/src/Makefile.am $RECIPE_c_igraph/Makefile.am.patch
36-
export OLD_CPPFLAGS="$CPPFLAGS"
37-
export CPPFLAGS="$CPPFLAGS -I$ANDROIDNDK/sources/cxx-stl/gnu-libstdc++/4.4.3/include -I$ANDROIDNDK/sources/cxx-stl/gnu-libstdc++/4.4.3/libs/armeabi/include -L$ANDROIDNDK/platforms/android-$ANDROIDAPI/arch-arm/usr/lib"
38-
try ./configure --prefix="$BUILD_PATH/python-install" --build=i686-pc-linux-gnu --host=arm-linux-eabi
39-
export CPPFLAGS="$OLD_CPPFLAGS"
40-
cp -f $RECIPE_c_igraph/arith.h $BUILD_c_igraph/src/f2c/arith.h
41-
patch -Nr - $BUILD_c_igraph/src/f2c/sysdep1.h $RECIPE_c_igraph/sysdep1.h.patch
42-
patch -Nr - $BUILD_c_igraph/src/f2c/uninit.c $RECIPE_c_igraph/uninit.c.patch
43-
patch -N $BUILD_c_igraph/config.h $RECIPE_c_igraph/config.h.patch
42+
if [ ! -e $BUILD_c_igraph/config.h ]; then {
43+
export OLD_CPPFLAGS="$CPPFLAGS";
44+
export CPPFLAGS="$CPPFLAGS -I$ANDROIDNDK/sources/cxx-stl/gnu-libstdc++/4.4.3/include -I$ANDROIDNDK/sources/cxx-stl/gnu-libstdc++/4.4.3/libs/armeabi/include -L$ANDROIDNDK/platforms/android-$ANDROIDAPI/arch-arm/usr/lib";
45+
try ./configure --prefix="$BUILD_PATH/python-install" --build=i686-pc-linux-gnu --host=arm-linux-eabi;
46+
try patch $BUILD_c_igraph/config.h $RECIPE_c_igraph/config.h.patch;
47+
export CPPFLAGS="$OLD_CPPFLAGS";
48+
}
49+
fi
4450
try $MAKE
4551
try $MAKE install
4652

recipes/django/recipe.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
VERSION_django=${VERSION_django:-1.6.1}
4+
DEPS_django=(sqlite3)
5+
URL_django=https://pypi.python.org/packages/source/D/Django/Django-$VERSION_django.tar.gz
6+
MD5_django=3ea7a00ea9e7a014e8a4067dd6466a1b
7+
BUILD_django=$BUILD_PATH/django/$(get_directory $URL_django)
8+
RECIPE_django=$RECIPES_PATH/django
9+
10+
function prebuild_django() {
11+
true
12+
}
13+
14+
function shouldbuild_django() {
15+
if [ -d "$SITEPACKAGES_PATH/django" ]; then
16+
DO_BUILD=0
17+
fi
18+
}
19+
20+
function build_django() {
21+
cd $BUILD_django
22+
push_arm
23+
try $HOSTPYTHON setup.py install
24+
pop_arm
25+
}
26+
27+
function postbuild_django() {
28+
# ensure the blacklist doesn't contain wsgiref or unittest
29+
$SED '/unittest/d' $BUILD_PATH/blacklist.txt
30+
$SED '/wsgiref/d' $BUILD_PATH/blacklist.txt
31+
}

recipes/igraph/recipe.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
b#!/bin/bash
1+
#!/bin/bash
22

33
# Recipe for the Python interface to igraph, a high-performance graph library in C: http://igraph.org/
44
#
@@ -18,8 +18,12 @@ RECIPE_igraph=$RECIPES_PATH/igraph
1818

1919

2020
function prebuild_igraph() {
21-
patch -Nr - $BUILD_igraph/setup.py $RECIPE_igraph/setup.py.patch
22-
patch -Nr - $BUILD_igraph/setup.cfg $RECIPE_igraph/setup.cfg.patch
21+
if [ ! -f "$BUILD_igraph/.patched" ]; then {
22+
try patch $BUILD_igraph/setup.py $RECIPE_igraph/setup.py.patch
23+
try patch $BUILD_igraph/setup.cfg $RECIPE_igraph/setup.cfg.patch
24+
touch $BUILD_igraph/.patched
25+
};
26+
fi
2327
}
2428

2529
function shouldbuild_igraph() {

src/build.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ def make_package(args):
206206

207207
args.numeric_version = str(version_code)
208208

209+
args.name = args.name.decode('utf-8')
210+
if args.icon_name:
211+
args.icon_name = args.icon_name.decode('utf-8')
212+
209213
versioned_name = args.name.replace(' ', '').replace('\'', '') + '-' + args.version
210214

211215
# Android SDK rev14 needs two ant execs (ex: debug installd) and new build.xml

0 commit comments

Comments
 (0)