1
1
2
- from pythonforandroid .toolchain import Recipe , shprint , get_directory , current_directory , ArchAndroid
3
- from os .path import exists , join
2
+ from pythonforandroid .toolchain import Recipe , shprint , get_directory , current_directory , ArchAndroid , info
3
+ from os .path import exists , join , realpath
4
4
from os import uname
5
5
import glob
6
6
import sh
7
7
8
+
8
9
class Python2Recipe (Recipe ):
9
10
version = "2.7.2"
10
11
url = 'http://python.org/ftp/python/{version}/Python-{version}.tar.bz2'
@@ -40,6 +41,35 @@ def prebuild_armeabi(self):
40
41
shprint (sh .touch , join (build_dir , '.patched' ))
41
42
42
43
def build_armeabi (self ):
44
+
45
+ if not exists (join (self .get_build_dir ('armeabi' ), 'libpython2.7.so' )):
46
+ self .do_python_build ()
47
+
48
+ if not exists (self .ctx .get_python_install_dir ()):
49
+ shprint (sh .cp , '-a' , join (self .get_build_dir ('armeabi' ), 'python-install' ),
50
+ self .ctx .get_python_install_dir ())
51
+
52
+ # This should be safe to run every time
53
+ info ('Copying hostpython binary to targetpython folder' )
54
+ shprint (sh .cp , self .ctx .hostpython ,
55
+ join (self .ctx .get_python_install_dir (), 'bin' , 'python.host' ))
56
+ self .ctx .hostpython = join (self .ctx .get_python_install_dir (), 'bin' , 'python.host' )
57
+
58
+ if not exists (join (self .ctx .get_libs_dir ('armeabi' ), 'libpython2.7.so' )):
59
+ shprint (sh .cp , join (self .get_build_dir ('armeabi' ), 'libpython2.7.so' ), self .ctx .get_libs_dir ('armeabi' ))
60
+
61
+
62
+ # # if exists(join(self.get_build_dir('armeabi'), 'libpython2.7.so')):
63
+ # if exists(join(self.ctx.libs_dir, 'libpython2.7.so')):
64
+ # info('libpython2.7.so already exists, skipping python build.')
65
+ # if not exists(join(self.ctx.get_python_install_dir(), 'libpython2.7.so')):
66
+ # info('Copying python-install to dist-dependent location')
67
+ # shprint(sh.cp, '-a', 'python-install', self.ctx.get_python_install_dir())
68
+ # self.ctx.hostpython = join(self.ctx.get_python_install_dir(), 'bin', 'python.host')
69
+
70
+ # return
71
+
72
+ def do_python_build (self ):
43
73
if 'sqlite' in self .ctx .recipe_build_order or 'openssl' in self .ctx .recipe_build_order :
44
74
print ('sqlite or openssl support not yet enabled in python recipe' )
45
75
exit (1 )
@@ -50,15 +80,6 @@ def build_armeabi(self):
50
80
hostpython = join (self .get_build_dir ('armeabi' ), 'hostpython' )
51
81
hostpgen = join (self .get_build_dir ('armeabi' ), 'hostpython' )
52
82
53
- # ctypes: Need to set buildarch?
54
-
55
- if exists (join (self .get_build_dir ('armeabi' ), 'libpython2.7.so' )):
56
- print ('libpython2.7.so already exists, skipping python build.' )
57
- self .ctx .hostpython = join (self .ctx .build_dir , 'python-install' ,
58
- 'bin' , 'python.host' )
59
-
60
- return
61
-
62
83
with current_directory (self .get_build_dir ('armeabi' )):
63
84
64
85
@@ -80,10 +101,10 @@ def build_armeabi(self):
80
101
'--host={}' .format (env ['HOSTARCH' ]),
81
102
'--build={}' .format (env ['BUILDARCH' ]),
82
103
# 'OPT={}'.format(env['OFLAG']),
83
- '--prefix={}' .format (join ( self . ctx . build_dir , ' python-install' )),
104
+ '--prefix={}' .format (realpath ( './ python-install' )),
84
105
'--enable-shared' ,
85
106
'--disable-toolbox-glue' ,
86
- '--disable-framefork ' ,
107
+ '--disable-framework ' ,
87
108
_env = env )
88
109
89
110
# AND: tito left this comment in the original source. It's still true!
@@ -115,32 +136,30 @@ def build_armeabi(self):
115
136
116
137
if uname ()[0 ] == 'Darwin' :
117
138
shprint (sh .cp , join (self .get_recipe_dir (), 'patches' , '_scproxy.py' ),
118
- join (self . get_build_dir () , 'Lib' ))
139
+ join ('python-install' , 'Lib' ))
119
140
shprint (sh .cp , join (self .get_recipe_dir (), 'patches' , '_scproxy.py' ),
120
- join (self .ctx .build_dir , 'python-install' , 'lib' , 'python2.7' ))
121
-
122
- print ('Ready to copy .so for python arm' )
123
- shprint (sh .cp , 'libpython2.7.so' , self .ctx .libs_dir )
124
- # for filen in glob.glob('build/lib.*-2.7/_ctypes*.so'):
125
- # shprint(sh.cp, '-a', filen, self.ctx.libs_dir)
126
-
127
- print ('Copying hostpython binary to targetpython folder' )
128
- shprint (sh .cp , self .ctx .hostpython ,
129
- join (self .ctx .build_dir , 'python-install' , 'bin' ,
130
- 'python.host' ))
131
- self .ctx .hostpython = join (self .ctx .build_dir , 'python-install' ,
132
- 'bin' , 'python.host' )
133
-
141
+ join ('python-install' , 'lib' , 'python2.7' ))
134
142
135
- # reduce python?
143
+ # reduce python
136
144
for dir_name in ('test' , join ('json' , 'tests' ), 'lib-tk' ,
137
145
join ('sqlite3' , 'test' ), join ('unittest, test' ),
138
146
join ('lib2to3' , 'tests' ), join ('bsddb' , 'tests' ),
139
147
join ('distutils' , 'tests' ), join ('email' , 'test' ),
140
148
'curses' ):
141
- shprint (sh .rm , '-rf' , join (self . ctx . build_dir , 'python-install' ,
149
+ shprint (sh .rm , '-rf' , join ('python-install' ,
142
150
'lib' , 'python2.7' , dir_name ))
143
151
152
+
153
+ # info('Copying python-install to dist-dependent location')
154
+ # shprint(sh.cp, '-a', 'python-install', self.ctx.get_python_install_dir())
155
+
156
+ # print('Copying hostpython binary to targetpython folder')
157
+ # shprint(sh.cp, self.ctx.hostpython,
158
+ # join(self.ctx.get_python_install_dir(), 'bin', 'python.host'))
159
+ # self.ctx.hostpython = join(self.ctx.get_python_install_dir(), 'bin', 'python.host')
160
+
161
+
162
+
144
163
# print('python2 build done, exiting for debug')
145
164
# exit(1)
146
165
0 commit comments