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
55import sh
66import shutil
7- from os import listdir , unlink , environ , mkdir
7+ from os import listdir , unlink , environ , mkdir , curdir
88from sys import stdout
99try :
1010 from urlparse import urlparse
@@ -671,8 +671,30 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
671671 with current_directory (self .get_build_dir (arch .arch )):
672672 # hostpython = sh.Command(self.ctx.hostpython)
673673 hostpython = sh .Command (self .hostpython_location )
674+ hostpython = sh .Command ('python3.5' )
674675
675- if self .call_hostpython_via_targetpython :
676+
677+ if self .ctx .ndk_is_crystax :
678+ hppath = join (dirname (self .hostpython_location ), 'Lib' ,
679+ 'site-packages' )
680+ hpenv = env .copy ()
681+ if 'PYTHONPATH' in hpenv :
682+ hpenv ['PYTHONPATH' ] = ':' .join ([hppath ] +
683+ hpenv ['PYTHONPATH' ].split (':' ))
684+ else :
685+ hpenv ['PYTHONPATH' ] = hppath
686+ # hpenv['PYTHONHOME'] = self.ctx.get_python_install_dir()
687+ # shprint(hostpython, 'setup.py', 'build',
688+ # _env=hpenv, *self.setup_extra_args)
689+ shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
690+ '--root={}' .format (self .ctx .get_python_install_dir ()),
691+ '--install-lib=lib/python3.5/site-packages' ,
692+ _env = hpenv , * self .setup_extra_args )
693+ site_packages_dir = self .ctx .get_site_packages_dir ()
694+ built_files = glob .glob (join ('build' , 'lib*' , '*' ))
695+ for filen in built_files :
696+ shprint (sh .cp , '-r' , filen , join (site_packages_dir , split (filen )[- 1 ]))
697+ elif self .call_hostpython_via_targetpython :
676698 shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env ,
677699 * self .setup_extra_args )
678700 else :
@@ -749,8 +771,13 @@ def build_arch(self, arch):
749771 def build_cython_components (self , arch ):
750772 info ('Cythonizing anything necessary in {}' .format (self .name ))
751773 env = self .get_recipe_env (arch )
774+ # env['PYTHONHOME'] = self.ctx.get_python_install_dir()
775+ env ['PYTHONPATH' ] = '/usr/lib/python3.5/site-packages/:/usr/lib/python3.5'
752776 with current_directory (self .get_build_dir (arch .arch )):
753- hostpython = sh .Command (self .ctx .hostpython )
777+ # hostpython = sh.Command(self.ctx.hostpython)
778+ hostpython = sh .Command ('python3.5' )
779+ shprint (hostpython , '-c' , 'import sys; print(sys.path)' , _env = env )
780+ print ('cwd is' , realpath (curdir ))
754781 info ('Trying first build of {} to get cython files: this is '
755782 'expected to fail' .format (self .name ))
756783 try :
@@ -761,17 +788,19 @@ def build_cython_components(self, arch):
761788 info ('{} first build failed (as expected)' .format (self .name ))
762789
763790 info ('Running cython where appropriate' )
791+ # shprint(sh.find, self.get_build_dir(arch.arch), '-iname', '*.pyx',
792+ # '-exec', self.ctx.cython, '{}', ';', _env=env)
764793 shprint (sh .find , self .get_build_dir (arch .arch ), '-iname' , '*.pyx' ,
765- '-exec' , self .ctx .cython , '{}' , ';' , _env = env )
794+ '-exec' , self .ctx .cython , '{}' , ';' )
766795 info ('ran cython' )
767796
768797 shprint (hostpython , 'setup.py' , 'build_ext' , '-v' , _env = env ,
769798 _tail = 20 , _critical = True , * self .setup_extra_args )
770799
771- print ('stripping' )
772- build_lib = glob .glob ('./build/lib*' )
773- shprint (sh .find , build_lib [0 ], '-name' , '*.o' , '-exec' ,
774- env ['STRIP' ], '{}' , ';' , _env = env )
800+ # print('stripping')
801+ # build_lib = glob.glob('./build/lib*')
802+ # shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
803+ # env['STRIP'], '{}', ';', _env=env)
775804 print ('stripped!?' )
776805 # exit(1)
777806
@@ -792,10 +821,12 @@ def build_cython_components(self, arch):
792821
793822 def get_recipe_env (self , arch ):
794823 env = super (CythonRecipe , self ).get_recipe_env (arch )
795- env ['LDFLAGS' ] = env ['LDFLAGS' ] + ' -L{}' .format (
824+ env ['LDFLAGS' ] = env ['LDFLAGS' ] + ' -L{} ' .format (
796825 self .ctx .get_libs_dir (arch .arch ) +
797- '-L{}' .format (self .ctx .libs_dir ))
798- env ['LDSHARED' ] = join (self .ctx .root_dir , 'tools' , 'liblink' )
826+ ' -L{} ' .format (self .ctx .libs_dir )) + ' -L/home/asandy/.local/share/python-for-android/build/bootstrap_builds/sdl2python3crystax/libs/armeabi '
827+ # env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink-jb')
828+ env ['LDSHARED' ] = env ['CC' ] + ' -shared'
829+ shprint (sh .whereis , env ['LDSHARED' ], _env = env )
799830 env ['LIBLINK' ] = 'NOTNONE'
800831 env ['NDKPLATFORM' ] = self .ctx .ndk_platform
801832
@@ -805,4 +836,7 @@ def get_recipe_env(self, arch):
805836 'objects_{}' .format (self .name ))
806837 env ['LIBLINK_PATH' ] = liblink_path
807838 ensure_dir (liblink_path )
839+
840+ env ['CFLAGS' ] = '-I/home/asandy/android/crystax-ndk-10.3.0/sources/python/3.5/include/python ' + env ['CFLAGS' ]
841+
808842 return env
0 commit comments