@@ -815,37 +815,54 @@ def build_arch(self, arch):
815
815
816
816
def build_cython_components (self , arch ):
817
817
info ('Cythonizing anything necessary in {}' .format (self .name ))
818
+
818
819
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
+
821
829
with current_directory (self .get_build_dir (arch .arch )):
822
830
# hostpython = sh.Command(self.ctx.hostpython)
823
831
hostpython = sh .Command ('python3.5' )
824
832
shprint (hostpython , '-c' , 'import sys; print(sys.path)' , _env = env )
825
833
print ('cwd is' , realpath (curdir ))
826
834
info ('Trying first build of {} to get cython files: this is '
827
835
'expected to fail' .format (self .name ))
836
+
837
+ manually_cythonise = False
828
838
try :
829
- shprint (hostpython , 'setup.py' , 'build_ext' , _env = env ,
839
+ shprint (hostpython , 'setup.py' , 'build_ext' , '-v' , _env = env ,
830
840
* self .setup_extra_args )
831
841
except sh .ErrorReturnCode_1 :
832
842
print ()
833
843
info ('{} first build failed (as expected)' .format (self .name ))
844
+ manually_cythonise = True
834
845
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' )
841
855
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.' )
844
861
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 )
849
866
print ('stripped!?' )
850
867
# exit(1)
851
868
0 commit comments