1- from os .path import join , dirname , isdir , exists , isfile
1+ from os .path import join , dirname , isdir , exists , isfile , split , realpath
22import importlib
33import zipfile
44import glob
55from six import PY2
66
77import sh
88import shutil
9- from os import listdir , unlink , environ , mkdir
9+ from os import listdir , unlink , environ , mkdir , curdir
1010from sys import stdout
1111try :
1212 from urlparse import urlparse
@@ -715,8 +715,30 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
715715 with current_directory (self .get_build_dir (arch .arch )):
716716 # hostpython = sh.Command(self.ctx.hostpython)
717717 hostpython = sh .Command (self .hostpython_location )
718+ hostpython = sh .Command ('python3.5' )
718719
719- if self .call_hostpython_via_targetpython :
720+
721+ if self .ctx .ndk_is_crystax :
722+ hppath = join (dirname (self .hostpython_location ), 'Lib' ,
723+ 'site-packages' )
724+ hpenv = env .copy ()
725+ if 'PYTHONPATH' in hpenv :
726+ hpenv ['PYTHONPATH' ] = ':' .join ([hppath ] +
727+ hpenv ['PYTHONPATH' ].split (':' ))
728+ else :
729+ hpenv ['PYTHONPATH' ] = hppath
730+ # hpenv['PYTHONHOME'] = self.ctx.get_python_install_dir()
731+ # shprint(hostpython, 'setup.py', 'build',
732+ # _env=hpenv, *self.setup_extra_args)
733+ shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
734+ '--root={}' .format (self .ctx .get_python_install_dir ()),
735+ '--install-lib=lib/python3.5/site-packages' ,
736+ _env = hpenv , * self .setup_extra_args )
737+ site_packages_dir = self .ctx .get_site_packages_dir ()
738+ built_files = glob .glob (join ('build' , 'lib*' , '*' ))
739+ for filen in built_files :
740+ shprint (sh .cp , '-r' , filen , join (site_packages_dir , split (filen )[- 1 ]))
741+ elif self .call_hostpython_via_targetpython :
720742 shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env ,
721743 * self .setup_extra_args )
722744 else :
@@ -793,8 +815,13 @@ def build_arch(self, arch):
793815 def build_cython_components (self , arch ):
794816 info ('Cythonizing anything necessary in {}' .format (self .name ))
795817 env = self .get_recipe_env (arch )
818+ # env['PYTHONHOME'] = self.ctx.get_python_install_dir()
819+ env ['PYTHONPATH' ] = '/usr/lib/python3.5/site-packages/:/usr/lib/python3.5'
796820 with current_directory (self .get_build_dir (arch .arch )):
797- hostpython = sh .Command (self .ctx .hostpython )
821+ # hostpython = sh.Command(self.ctx.hostpython)
822+ hostpython = sh .Command ('python3.5' )
823+ shprint (hostpython , '-c' , 'import sys; print(sys.path)' , _env = env )
824+ print ('cwd is' , realpath (curdir ))
798825 info ('Trying first build of {} to get cython files: this is '
799826 'expected to fail' .format (self .name ))
800827 try :
@@ -805,17 +832,19 @@ def build_cython_components(self, arch):
805832 info ('{} first build failed (as expected)' .format (self .name ))
806833
807834 info ('Running cython where appropriate' )
835+ # shprint(sh.find, self.get_build_dir(arch.arch), '-iname', '*.pyx',
836+ # '-exec', self.ctx.cython, '{}', ';', _env=env)
808837 shprint (sh .find , self .get_build_dir (arch .arch ), '-iname' , '*.pyx' ,
809- '-exec' , self .ctx .cython , '{}' , ';' , _env = env )
838+ '-exec' , self .ctx .cython , '{}' , ';' )
810839 info ('ran cython' )
811840
812841 shprint (hostpython , 'setup.py' , 'build_ext' , '-v' , _env = env ,
813842 _tail = 20 , _critical = True , * self .setup_extra_args )
814843
815- print ('stripping' )
816- build_lib = glob .glob ('./build/lib*' )
817- shprint (sh .find , build_lib [0 ], '-name' , '*.o' , '-exec' ,
818- env ['STRIP' ], '{}' , ';' , _env = env )
844+ # print('stripping')
845+ # build_lib = glob.glob('./build/lib*')
846+ # shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
847+ # env['STRIP'], '{}', ';', _env=env)
819848 print ('stripped!?' )
820849 # exit(1)
821850
@@ -836,10 +865,12 @@ def build_cython_components(self, arch):
836865
837866 def get_recipe_env (self , arch ):
838867 env = super (CythonRecipe , self ).get_recipe_env (arch )
839- env ['LDFLAGS' ] = env ['LDFLAGS' ] + ' -L{}' .format (
868+ env ['LDFLAGS' ] = env ['LDFLAGS' ] + ' -L{} ' .format (
840869 self .ctx .get_libs_dir (arch .arch ) +
841- '-L{}' .format (self .ctx .libs_dir ))
842- env ['LDSHARED' ] = join (self .ctx .root_dir , 'tools' , 'liblink' )
870+ ' -L{} ' .format (self .ctx .libs_dir )) + ' -L/home/asandy/.local/share/python-for-android/build/bootstrap_builds/sdl2python3crystax/libs/armeabi '
871+ # env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink-jb')
872+ env ['LDSHARED' ] = env ['CC' ] + ' -shared'
873+ shprint (sh .whereis , env ['LDSHARED' ], _env = env )
843874 env ['LIBLINK' ] = 'NOTNONE'
844875 env ['NDKPLATFORM' ] = self .ctx .ndk_platform
845876
@@ -849,4 +880,7 @@ def get_recipe_env(self, arch):
849880 'objects_{}' .format (self .name ))
850881 env ['LIBLINK_PATH' ] = liblink_path
851882 ensure_dir (liblink_path )
883+
884+ env ['CFLAGS' ] = '-I/home/asandy/android/crystax-ndk-10.3.0/sources/python/3.5/include/python ' + env ['CFLAGS' ]
885+
852886 return env
0 commit comments