@@ -771,37 +771,54 @@ def build_arch(self, arch):
771
771
772
772
def build_cython_components (self , arch ):
773
773
info ('Cythonizing anything necessary in {}' .format (self .name ))
774
+
774
775
env = self .get_recipe_env (arch )
775
- # env['PYTHONHOME'] = self.ctx.get_python_install_dir()
776
- env ['PYTHONPATH' ] = '/usr/lib/python3.5/site-packages/:/usr/lib/python3.5'
776
+
777
+ if self .ctx .ndk_is_crystax :
778
+ site_packages_dirs = sh .Command ('python3.5' )('-c' , 'import site; print("\\ n".join(site.getsitepackages()))' ).stdout .split ('\n ' )
779
+ # env['PYTHONPATH'] = '/usr/lib/python3.5/site-packages/:/usr/lib/python3.5'
780
+ if 'PYTHONPATH' in env :
781
+ env ['PYTHONPATH' ] = env + ':{}' .format (':' .join (site_packages_dirs ))
782
+ else :
783
+ env ['PYTHONPATH' ] = ':' .join (site_packages_dirs )
784
+
777
785
with current_directory (self .get_build_dir (arch .arch )):
778
786
# hostpython = sh.Command(self.ctx.hostpython)
779
787
hostpython = sh .Command ('python3.5' )
780
788
shprint (hostpython , '-c' , 'import sys; print(sys.path)' , _env = env )
781
789
print ('cwd is' , realpath (curdir ))
782
790
info ('Trying first build of {} to get cython files: this is '
783
791
'expected to fail' .format (self .name ))
792
+
793
+ manually_cythonise = False
784
794
try :
785
- shprint (hostpython , 'setup.py' , 'build_ext' , _env = env ,
795
+ shprint (hostpython , 'setup.py' , 'build_ext' , '-v' , _env = env ,
786
796
* self .setup_extra_args )
787
797
except sh .ErrorReturnCode_1 :
788
798
print ()
789
799
info ('{} first build failed (as expected)' .format (self .name ))
800
+ manually_cythonise = True
790
801
791
- info ('Running cython where appropriate' )
792
- # shprint(sh.find, self.get_build_dir(arch.arch), '-iname', '*.pyx',
793
- # '-exec', self.ctx.cython, '{}', ';', _env=env)
794
- shprint (sh .find , self .get_build_dir (arch .arch ), '-iname' , '*.pyx' ,
795
- '-exec' , self .ctx .cython , '{}' , ';' )
796
- info ('ran cython' )
802
+ if manually_cythonise :
803
+ info ('Running cython where appropriate' )
804
+ if self .ctx .ndk_is_crystax :
805
+ shprint (sh .find , self .get_build_dir (arch .arch ), '-iname' , '*.pyx' ,
806
+ '-exec' , self .ctx .cython , '{}' , ';' )
807
+ else :
808
+ shprint (sh .find , self .get_build_dir (arch .arch ), '-iname' , '*.pyx' ,
809
+ '-exec' , self .ctx .cython , '{}' , ';' , _env = env )
810
+ info ('ran cython' )
797
811
798
- shprint (hostpython , 'setup.py' , 'build_ext' , '-v' , _env = env ,
799
- _tail = 20 , _critical = True , * self .setup_extra_args )
812
+ shprint (hostpython , 'setup.py' , 'build_ext' , '-v' , _env = env ,
813
+ _tail = 20 , _critical = True , * self .setup_extra_args )
814
+ else :
815
+ info ('First build appeared to complete correctly, skipping manual'
816
+ 'cythonising.' )
800
817
801
- # print('stripping')
802
- # build_lib = glob.glob('./build/lib*')
803
- # shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
804
- # env['STRIP'], '{}', ';', _env=env)
818
+ print ('stripping' )
819
+ build_lib = glob .glob ('./build/lib*' )
820
+ shprint (sh .find , build_lib [0 ], '-name' , '*.o' , '-exec' ,
821
+ env ['STRIP' ], '{}' , ';' , _env = env )
805
822
print ('stripped!?' )
806
823
# exit(1)
807
824
0 commit comments