-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy path__init__.py
69 lines (53 loc) · 2.39 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from pythonforandroid.toolchain import Recipe, shprint, current_directory, info, warning
from os.path import join, exists
import os
import sh
class Hostpython2Recipe(Recipe):
"""
Overrides upstream hostpython2 recipe from:
https://github.com/kivy/python-for-android/blob/b3d3d45
/pythonforandroid/recipes/hostpython2/__init__.py
Adds `--enable-unicode=ucs4` configure flag, refs:
https://github.com/AndreMiras/PyWallet/issues/136
"""
version = '2.7.2'
url = 'https://python.org/ftp/python/{version}/Python-{version}.tar.bz2'
name = 'hostpython2'
conflicts = ['hostpython3']
def get_build_container_dir(self, arch=None):
choices = self.check_recipe_choices()
dir_name = '-'.join([self.name] + choices)
return join(self.ctx.build_dir, 'other_builds', dir_name, 'desktop')
def get_build_dir(self, arch=None):
return join(self.get_build_container_dir(), self.name)
def prebuild_arch(self, arch):
# Override hostpython Setup?
shprint(sh.cp, join(self.get_recipe_dir(), 'Setup'),
join(self.get_build_dir(), 'Modules', 'Setup'))
def build_arch(self, arch):
with current_directory(self.get_build_dir()):
if exists('hostpython'):
info('hostpython already exists, skipping build')
self.ctx.hostpython = join(self.get_build_dir(),
'hostpython')
self.ctx.hostpgen = join(self.get_build_dir(),
'hostpgen')
return
if 'LIBS' in os.environ:
os.environ.pop('LIBS')
configure = sh.Command('./configure')
# shprint(configure)
shprint(configure, '--enable-unicode=ucs4')
shprint(sh.make, '-j5')
shprint(sh.mv, join('Parser', 'pgen'), 'hostpgen')
if exists('python.exe'):
shprint(sh.mv, 'python.exe', 'hostpython')
elif exists('python'):
shprint(sh.mv, 'python', 'hostpython')
else:
warning('Unable to find the python executable after '
'hostpython build! Exiting.')
exit(1)
self.ctx.hostpython = join(self.get_build_dir(), 'hostpython')
self.ctx.hostpgen = join(self.get_build_dir(), 'hostpgen')
recipe = Hostpython2Recipe()