Skip to content

Commit a614b14

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents e3f0f2e + 90df704 commit a614b14

File tree

13 files changed

+617
-4
lines changed

13 files changed

+617
-4
lines changed

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Python for Android
22

3-
Python for android is a project to create your own Python distribution
3+
Python for Android is a project to create your own Python distribution
44
including the modules you want, and create an apk including python,
55
libs, and your application.
66

@@ -98,3 +98,42 @@ Original reference commit of p4a master was
9898
this need adding to the new toolchain. Some of the major later
9999
additons, including ctypes in the python build, have already been
100100
merged here.
101+
102+
Support
103+
-------
104+
105+
If you need assistance, you can ask for help on our mailing list:
106+
107+
* User Group : https://groups.google.com/group/kivy-users
108+
* Email : kivy-users@googlegroups.com
109+
110+
We also have an IRC channel:
111+
112+
* Server : irc.freenode.net
113+
* Port : 6667, 6697 (SSL only)
114+
* Channel : #kivy
115+
116+
Contributing
117+
------------
118+
119+
We love pull requests and discussing novel ideas. Check out our
120+
[contribution guide](http://kivy.org/docs/contribute.html) and
121+
feel free to improve Python for Android.
122+
123+
The following mailing list and IRC channel are used exclusively for
124+
discussions about developing the Kivy framework and its sister projects:
125+
126+
* Dev Group : https://groups.google.com/group/kivy-dev
127+
* Email : kivy-dev@googlegroups.com
128+
129+
IRC channel:
130+
131+
* Server : irc.freenode.net
132+
* Port : 6667, 6697 (SSL only)
133+
* Channel : #kivy-dev
134+
135+
License
136+
-------
137+
138+
Python for Android is released under the terms of the MIT License. Please refer to the
139+
LICENSE file.

doc/source/quickstart.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,17 @@ via your package manager or otherwise. These include:
4343
- git
4444
- ant
4545
- python2
46+
- cython (can be installed via pip)
4647
- the Android `SDK <https://developer.android.com/sdk/index.html#Other>`_ and `NDK <https://developer.android.com/ndk/downloads/index.html>`_ (see below)
4748
- a Java JDK (e.g. openjdk-7)
4849
- zlib (including 32 bit)
4950
- libncurses (including 32 bit)
5051
- unzip
52+
- virtualenv (can be installed via pip)
5153
- ccache (optional)
5254

5355
On recent versions of Ubuntu and its derivatives you may be able to
54-
install all many of these with::
56+
install most of these with::
5557

5658
sudo dpkg --add-architecture i386
5759
sudo apt-get update
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
from pythonforandroid.toolchain import PythonRecipe
3+
4+
5+
class Enum34Recipe(PythonRecipe):
6+
version = '1.0.4'
7+
url = 'https://pypi.python.org/packages/source/e/enum34/enum34-{version}.tar.gz'
8+
depends = ['python2']
9+
10+
recipe = Enum34Recipe()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
from pythonforandroid.toolchain import Recipe, shprint, current_directory
3+
from os.path import exists, join
4+
import sh
5+
6+
7+
class OpenSSLRecipe(Recipe):
8+
version = '1.0.2d'
9+
url = 'https://www.openssl.org/source/openssl-{version}.tar.gz'
10+
11+
def should_build(self):
12+
return not exists(join(self.get_build_dir('armeabi'), 'libssl.a'))
13+
14+
def build_arch(self, arch):
15+
env = self.get_recipe_env(arch)
16+
with current_directory(self.get_build_dir(arch.arch)):
17+
# sh fails with code 255 trying to execute ./Configure
18+
# so instead we manually run perl passing in Configure
19+
perl = sh.Command('perl')
20+
shprint(perl, 'Configure', 'no-dso', 'no-krb5', 'linux-armv4', _env=env)
21+
shprint(sh.make, 'build_libs', _env=env)
22+
23+
recipe = OpenSSLRecipe()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
from pythonforandroid.toolchain import PythonRecipe
3+
4+
5+
class PyASN1Recipe(PythonRecipe):
6+
version = '0.1.8'
7+
url = 'https://pypi.python.org/packages/source/p/pyasn1/pyasn1-{version}.tar.gz'
8+
depends = ['python2']
9+
10+
recipe = PyASN1Recipe()
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
from pythonforandroid.toolchain import (
3+
CompiledComponentsPythonRecipe,
4+
Recipe,
5+
current_directory,
6+
info,
7+
shprint,
8+
)
9+
from os.path import exists, join, realpath
10+
import sh
11+
import glob
12+
13+
14+
class PyCryptoRecipe(CompiledComponentsPythonRecipe):
15+
version = '2.6.1'
16+
url = 'https://pypi.python.org/packages/source/p/pycrypto/pycrypto-{version}.tar.gz'
17+
depends = ['openssl', 'python2']
18+
19+
def prebuild_arch(self, arch):
20+
super(PyCryptoRecipe, self).prebuild_arch(arch)
21+
build_dir = self.get_build_dir(arch.arch)
22+
if exists(join(build_dir, '.patched')):
23+
print('pycrypto already patched, skipping')
24+
return
25+
self.apply_patch('add_length.patch')
26+
shprint(sh.touch, join(build_dir, '.patched'))
27+
28+
def get_recipe_env(self, arch):
29+
env = super(PyCryptoRecipe, self).get_recipe_env(arch)
30+
openssl_build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
31+
env['CC'] = '%s -I%s' % (env['CC'], join(openssl_build_dir, 'include'))
32+
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format(
33+
self.ctx.get_libs_dir(arch.arch) +
34+
'-L{}'.format(self.ctx.libs_dir)) + ' -L{}'.format(
35+
openssl_build_dir)
36+
env['EXTRA_CFLAGS'] = '--host linux-armv'
37+
env['ac_cv_func_malloc_0_nonnull'] = 'yes'
38+
return env
39+
40+
def build_compiled_components(self, arch):
41+
info('Configuring compiled components in {}'.format(self.name))
42+
43+
env = self.get_recipe_env(arch)
44+
with current_directory(self.get_build_dir(arch.arch)):
45+
configure = sh.Command('./configure')
46+
shprint(configure, '--host=arm-eabi',
47+
'--prefix={}'.format(self.ctx.get_python_install_dir()),
48+
'--enable-shared', _env=env)
49+
super(PyCryptoRecipe, self).build_compiled_components(arch)
50+
51+
recipe = PyCryptoRecipe()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- pycrypto-2.6.1/src/hash_SHA2_template.c.orig 2013-10-14 14:38:10.000000000 -0700
2+
+++ pycrypto-2.6.1/src/hash_SHA2_template.c 2014-05-19 10:15:51.000000000 -0700
3+
@@ -87,7 +87,7 @@
4+
* return 1 on success
5+
* return 0 if the length overflows
6+
*/
7+
-int add_length(hash_state *hs, sha2_word_t inc) {
8+
+static int add_length(hash_state *hs, sha2_word_t inc) {
9+
sha2_word_t overflow_detector;
10+
overflow_detector = hs->length_lower;
11+
hs->length_lower += inc;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
from pythonforandroid.toolchain import (
3+
CompiledComponentsPythonRecipe,
4+
Recipe,
5+
current_directory,
6+
info,
7+
shprint,
8+
)
9+
from os.path import exists, join
10+
import sh
11+
import glob
12+
13+
14+
class PyOpenSSLRecipe(CompiledComponentsPythonRecipe):
15+
version = '0.13'
16+
url = 'https://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-{version}.tar.gz'
17+
depends = ['openssl', 'python2']
18+
19+
def prebuild_arch(self, arch):
20+
super(PyOpenSSLRecipe, self).prebuild_arch(arch)
21+
build_dir = self.get_build_dir(arch.arch)
22+
if exists(join(build_dir, '.patched')):
23+
print('pyOpenSSL already patched, skipping')
24+
return
25+
self.apply_patch('fix-dlfcn.patch')
26+
shprint(sh.touch, join(build_dir, '.patched'))
27+
28+
def get_recipe_env(self, arch):
29+
env = super(PyOpenSSLRecipe, self).get_recipe_env(arch)
30+
openssl_build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
31+
env['CC'] = '%s -I%s' % (env['CC'], join(openssl_build_dir, 'include'))
32+
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format(
33+
self.ctx.get_libs_dir(arch.arch) +
34+
'-L{}'.format(self.ctx.libs_dir)) + ' -L{}'.format(
35+
openssl_build_dir)
36+
return env
37+
38+
recipe = PyOpenSSLRecipe()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--- pyOpenSSL-0.13.orig/OpenSSL/__init__.py 2011-09-02 17:46:13.000000000 +0200
2+
+++ pyOpenSSL-0.13/OpenSSL/__init__.py 2013-07-29 17:20:15.750079894 +0200
3+
@@ -12,6 +12,11 @@
4+
except AttributeError:
5+
from OpenSSL import crypto
6+
else:
7+
+ # XXX android fix
8+
+ # linux: RTLD_NOW (0x2) | RTLD_GLOBAL (0x100 / 256)
9+
+ # android: RTLD_NOW (0x0) | RTLD_GLOBAL (0x2)
10+
+ flags = 0x2
11+
+ '''
12+
try:
13+
import DLFCN
14+
except ImportError:
15+
@@ -31,6 +36,7 @@
16+
else:
17+
flags = DLFCN.RTLD_NOW | DLFCN.RTLD_GLOBAL
18+
del DLFCN
19+
+ '''
20+
21+
sys.setdlopenflags(flags)
22+
from OpenSSL import crypto

pythonforandroid/recipes/python2/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Python2Recipe(Recipe):
1313

1414
depends = ['hostpython2']
1515
conflicts = ['python3']
16+
opt_depends = ['openssl']
1617

1718
def prebuild_armeabi(self):
1819
build_dir = self.get_build_container_dir('armeabi')
@@ -74,8 +75,8 @@ def build_armeabi(self):
7475
# return
7576

7677
def do_python_build(self):
77-
if 'sqlite' in self.ctx.recipe_build_order or 'openssl' in self.ctx.recipe_build_order:
78-
print('sqlite or openssl support not yet enabled in python recipe')
78+
if 'sqlite' in self.ctx.recipe_build_order:
79+
print('sqlite support not yet enabled in python recipe')
7980
exit(1)
8081

8182
hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx)
@@ -99,6 +100,15 @@ def do_python_build(self):
99100
env['BUILDARCH'] = shprint(sh.gcc, '-dumpmachine').stdout.split('\n')[0]
100101
env['CFLAGS'] = ' '.join([env['CFLAGS'], '-DNO_MALLINFO'])
101102

103+
# TODO need to add a should_build that checks if optional
104+
# dependencies have changed (possibly in a generic way)
105+
if 'openssl' in self.ctx.recipe_build_order:
106+
openssl_build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir('armeabi')
107+
env['CFLAGS'] = ' '.join([env['CFLAGS'],
108+
'-I{}'.format(join(openssl_build_dir, 'include'))])
109+
env['LDFLAGS'] = ' '.join([env['LDFLAGS'],
110+
'-L{}'.format(openssl_build_dir)])
111+
102112
configure = sh.Command('./configure')
103113
# AND: OFLAG isn't actually set, should it be?
104114
shprint(configure,

pythonforandroid/recipes/python3/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def prebuild_armeabi(self):
3838
self.apply_patch(join('patches', 'python-{version}-python-misc.patch'.format(version=self.version)))
3939

4040
self.apply_patch(join('patches', 'python-{version}-libpymodules_loader.patch'.format(version=self.version)))
41+
self.apply_patch('log_failures.patch')
4142

4243

4344
shprint(sh.touch, join(build_dir, '.patched'))
@@ -67,6 +68,7 @@ def build_armeabi(self):
6768
# shprint(sh.cp, join(hostpython_recipe.get_recipe_dir(), 'Setup'), 'Modules')
6869

6970
env = ArchAndroid(self.ctx).get_env()
71+
env["LDFLAGS"] = env["LDFLAGS"] + ' -llog'
7072

7173
# AND: Should probably move these to get_recipe_env for
7274
# neatness, but the whole recipe needs tidying along these

0 commit comments

Comments
 (0)