@@ -815,37 +815,54 @@ def build_arch(self, arch):
815815
816816 def build_cython_components (self , arch ):
817817 info ('Cythonizing anything necessary in {}' .format (self .name ))
818+
818819 env = self .get_recipe_env (arch )
819- # env['PYTHONHOME'] = self.ctx.get_python_install_dir()
820- env ['PYTHONPATH' ] = '/usr/lib/python3.5/site-packages/:/usr/lib/python3.5'
820+
821+ if self .ctx .ndk_is_crystax :
822+ site_packages_dirs = sh .Command ('python3.5' )('-c' , 'import site; print("\\ n".join(site.getsitepackages()))' ).stdout .split ('\n ' )
823+ # env['PYTHONPATH'] = '/usr/lib/python3.5/site-packages/:/usr/lib/python3.5'
824+ if 'PYTHONPATH' in env :
825+ env ['PYTHONPATH' ] = env + ':{}' .format (':' .join (site_packages_dirs ))
826+ else :
827+ env ['PYTHONPATH' ] = ':' .join (site_packages_dirs )
828+
821829 with current_directory (self .get_build_dir (arch .arch )):
822830 # hostpython = sh.Command(self.ctx.hostpython)
823831 hostpython = sh .Command ('python3.5' )
824832 shprint (hostpython , '-c' , 'import sys; print(sys.path)' , _env = env )
825833 print ('cwd is' , realpath (curdir ))
826834 info ('Trying first build of {} to get cython files: this is '
827835 'expected to fail' .format (self .name ))
836+
837+ manually_cythonise = False
828838 try :
829- shprint (hostpython , 'setup.py' , 'build_ext' , _env = env ,
839+ shprint (hostpython , 'setup.py' , 'build_ext' , '-v' , _env = env ,
830840 * self .setup_extra_args )
831841 except sh .ErrorReturnCode_1 :
832842 print ()
833843 info ('{} first build failed (as expected)' .format (self .name ))
844+ manually_cythonise = True
834845
835- info ('Running cython where appropriate' )
836- # shprint(sh.find, self.get_build_dir(arch.arch), '-iname', '*.pyx',
837- # '-exec', self.ctx.cython, '{}', ';', _env=env)
838- shprint (sh .find , self .get_build_dir (arch .arch ), '-iname' , '*.pyx' ,
839- '-exec' , self .ctx .cython , '{}' , ';' )
840- info ('ran cython' )
846+ if manually_cythonise :
847+ info ('Running cython where appropriate' )
848+ if self .ctx .ndk_is_crystax :
849+ shprint (sh .find , self .get_build_dir (arch .arch ), '-iname' , '*.pyx' ,
850+ '-exec' , self .ctx .cython , '{}' , ';' )
851+ else :
852+ shprint (sh .find , self .get_build_dir (arch .arch ), '-iname' , '*.pyx' ,
853+ '-exec' , self .ctx .cython , '{}' , ';' , _env = env )
854+ info ('ran cython' )
841855
842- shprint (hostpython , 'setup.py' , 'build_ext' , '-v' , _env = env ,
843- _tail = 20 , _critical = True , * self .setup_extra_args )
856+ shprint (hostpython , 'setup.py' , 'build_ext' , '-v' , _env = env ,
857+ _tail = 20 , _critical = True , * self .setup_extra_args )
858+ else :
859+ info ('First build appeared to complete correctly, skipping manual'
860+ 'cythonising.' )
844861
845- # print('stripping')
846- # build_lib = glob.glob('./build/lib*')
847- # shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
848- # env['STRIP'], '{}', ';', _env=env)
862+ print ('stripping' )
863+ build_lib = glob .glob ('./build/lib*' )
864+ shprint (sh .find , build_lib [0 ], '-name' , '*.o' , '-exec' ,
865+ env ['STRIP' ], '{}' , ';' , _env = env )
849866 print ('stripped!?' )
850867 # exit(1)
851868
0 commit comments