11
2- from pythonforandroid .toolchain import Recipe , shprint , get_directory , current_directory , ArchARM , info
2+ from pythonforandroid .toolchain import Recipe , shprint , current_directory , info
3+ from pythonforandroid .patching import is_linux , is_darwin , is_api_gt
34from os .path import exists , join , realpath
4- from os import uname
5- import glob
65import sh
76
87
@@ -14,39 +13,25 @@ class Python2Recipe(Recipe):
1413 depends = ['hostpython2' ]
1514 conflicts = ['python3' ]
1615 opt_depends = ['openssl' ]
17-
18- def prebuild_arch (self , arch ):
19- build_dir = self .get_build_container_dir (arch .arch )
20- if exists (join (build_dir , '.patched' )):
21- info ('Python2 already patched, skipping.' )
22- return
23- self .apply_patch (join ('patches' , 'Python-{}-xcompile.patch' .format (self .version )),
24- arch .arch )
25- self .apply_patch (join ('patches' , 'Python-{}-ctypes-disable-wchar.patch' .format (self .version )),
26- arch .arch )
27- self .apply_patch (join ('patches' , 'disable-modules.patch' ), arch .arch )
28- self .apply_patch (join ('patches' , 'fix-locale.patch' ), arch .arch )
29- self .apply_patch (join ('patches' , 'fix-gethostbyaddr.patch' ), arch .arch )
30- self .apply_patch (join ('patches' , 'fix-setup-flags.patch' ), arch .arch )
31- self .apply_patch (join ('patches' , 'fix-filesystemdefaultencoding.patch' ), arch .arch )
32- self .apply_patch (join ('patches' , 'fix-termios.patch' ), arch .arch )
33- self .apply_patch (join ('patches' , 'custom-loader.patch' ), arch .arch )
34- self .apply_patch (join ('patches' , 'verbose-compilation.patch' ), arch .arch )
35- self .apply_patch (join ('patches' , 'fix-remove-corefoundation.patch' ), arch .arch )
36- self .apply_patch (join ('patches' , 'fix-dynamic-lookup.patch' ), arch .arch )
37- self .apply_patch (join ('patches' , 'fix-dlfcn.patch' ), arch .arch )
38- self .apply_patch (join ('patches' , 'parsetuple.patch' ), arch .arch )
39- # self.apply_patch(join('patches', 'ctypes-find-library.patch'), arch.arch)
40- self .apply_patch (join ('patches' , 'ctypes-find-library-updated.patch' ), arch .arch )
41-
42- if uname ()[0 ] == 'Linux' :
43- self .apply_patch (join ('patches' , 'fix-configure-darwin.patch' ), arch .arch )
44- self .apply_patch (join ('patches' , 'fix-distutils-darwin.patch' ), arch .arch )
45-
46- if self .ctx .android_api > 19 :
47- self .apply_patch (join ('patches' , 'fix-ftime-removal.patch' ), arch .arch )
48-
49- shprint (sh .touch , join (build_dir , '.patched' ))
16+
17+ patches = ['patches/Python-{version}-xcompile.patch' ,
18+ 'patches/Python-{version}-ctypes-disable-wchar.patch' ,
19+ 'patches/disable-modules.patch' ,
20+ 'patches/fix-locale.patch' ,
21+ 'patches/fix-gethostbyaddr.patch' ,
22+ 'patches/fix-setup-flags.patch' ,
23+ 'patches/fix-filesystemdefaultencoding.patch' ,
24+ 'patches/fix-termios.patch' ,
25+ 'patches/custom-loader.patch' ,
26+ 'patches/verbose-compilation.patch' ,
27+ 'patches/fix-remove-corefoundation.patch' ,
28+ 'patches/fix-dynamic-lookup.patch' ,
29+ 'patches/fix-dlfcn.patch' ,
30+ 'patches/parsetuple.patch' ,
31+ 'patches/ctypes-find-library-updated.patch' ,
32+ ('patches/fix-configure-darwin.patch' , is_linux ),
33+ ('patches/fix-distutils-darwin.patch' , is_linux ),
34+ ('patches/fix-ftime-removal.patch' , is_api_gt (19 ))]
5035
5136 def build_arch (self , arch ):
5237
@@ -151,7 +136,7 @@ def do_python_build(self, arch):
151136 'INSTSONAME=libpython2.7.so' ,
152137 _env = env )
153138
154- if uname ()[ 0 ] == 'Darwin' :
139+ if is_darwin () :
155140 shprint (sh .cp , join (self .get_recipe_dir (), 'patches' , '_scproxy.py' ),
156141 join ('python-install' , 'Lib' ))
157142 shprint (sh .cp , join (self .get_recipe_dir (), 'patches' , '_scproxy.py' ),
0 commit comments