@@ -690,17 +690,12 @@ def clean_build(self, arch=None):
690
690
691
691
@property
692
692
def real_hostpython_location (self ):
693
- if 'hostpython2' in self .ctx .recipe_build_order :
694
- return join (
695
- Recipe .get_recipe ('hostpython2' , self .ctx ).get_build_dir (),
696
- 'hostpython' )
697
- elif 'hostpython3crystax' in self .ctx .recipe_build_order :
698
- return join (
699
- Recipe .get_recipe ('hostpython3crystax' , self .ctx ).get_build_dir (),
700
- 'hostpython' )
701
- elif 'hostpython3' in self .ctx .recipe_build_order :
702
- return join (Recipe .get_recipe ('hostpython3' , self .ctx ).get_build_dir (),
703
- 'native-build' , 'python' )
693
+ host_name = 'host{}' .format (self .ctx .python_recipe .name )
694
+ host_build = Recipe .get_recipe (host_name , self .ctx ).get_build_dir ()
695
+ if host_name in ['hostpython2' , 'hostpython3' ]:
696
+ return join (host_build , 'native-build' , 'python' )
697
+ elif host_name == 'hostpython3crystax' :
698
+ return join (host_build , 'hostpython' )
704
699
else :
705
700
python_recipe = self .ctx .python_recipe
706
701
return 'python{}' .format (python_recipe .version )
@@ -726,14 +721,17 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
726
721
727
722
if not self .call_hostpython_via_targetpython :
728
723
# sets python headers/linkages...depending on python's recipe
724
+ python_name = self .ctx .python_recipe .name
729
725
python_version = self .ctx .python_recipe .version
730
726
python_short_version = '.' .join (python_version .split ('.' )[:2 ])
731
- if 'python2' in self .ctx .recipe_build_order :
732
- env ['PYTHON_ROOT' ] = self .ctx .get_python_install_dir ()
733
- env ['CFLAGS' ] += ' -I' + env [
734
- 'PYTHON_ROOT' ] + '/include/python2.7'
735
- env ['LDFLAGS' ] += (
736
- ' -L' + env ['PYTHON_ROOT' ] + '/lib' + ' -lpython2.7' )
727
+ if python_name in ['python2' , 'python3' ]:
728
+ env ['CFLAGS' ] += ' -I{}' .format (
729
+ self .ctx .python_recipe .include_root (arch .arch ))
730
+ env ['LDFLAGS' ] += ' -L{} -lpython{}' .format (
731
+ self .ctx .python_recipe .link_root (arch .arch ),
732
+ self .ctx .python_recipe .major_minor_version_string )
733
+ if python_name == 'python3' :
734
+ env ['LDFLAGS' ] += 'm'
737
735
elif self .ctx .python_recipe .from_crystax :
738
736
ndk_dir_python = join (self .ctx .ndk_dir , 'sources' ,
739
737
'python' , python_version )
@@ -743,11 +741,6 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
743
741
env ['LDFLAGS' ] += ' -L{}' .format (
744
742
join (ndk_dir_python , 'libs' , arch .arch ))
745
743
env ['LDFLAGS' ] += ' -lpython{}m' .format (python_short_version )
746
- elif 'python3' in self .ctx .recipe_build_order :
747
- env ['CFLAGS' ] += ' -I{}' .format (self .ctx .python_recipe .include_root (arch .arch ))
748
- env ['LDFLAGS' ] += ' -L{} -lpython{}m' .format (
749
- self .ctx .python_recipe .link_root (arch .arch ),
750
- self .ctx .python_recipe .major_minor_version_string )
751
744
752
745
hppath = []
753
746
hppath .append (join (dirname (self .hostpython_location ), 'Lib' ))
@@ -790,7 +783,7 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
790
783
hostpython = sh .Command (self .hostpython_location )
791
784
792
785
if (self .ctx .python_recipe .from_crystax or
793
- self .ctx .python_recipe .name == ' python3' ):
786
+ self .ctx .python_recipe .name in [ 'python2' , ' python3'] ):
794
787
hpenv = env .copy ()
795
788
shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
796
789
'--root={}' .format (self .ctx .get_python_install_dir ()),
@@ -799,19 +792,6 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
799
792
elif self .call_hostpython_via_targetpython :
800
793
shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env ,
801
794
* self .setup_extra_args )
802
- else :
803
- hppath = join (dirname (self .hostpython_location ), 'Lib' ,
804
- 'site-packages' )
805
- hpenv = env .copy ()
806
- if 'PYTHONPATH' in hpenv :
807
- hpenv ['PYTHONPATH' ] = ':' .join ([hppath ] +
808
- hpenv ['PYTHONPATH' ].split (':' ))
809
- else :
810
- hpenv ['PYTHONPATH' ] = hppath
811
- shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
812
- '--root={}' .format (self .ctx .get_python_install_dir ()),
813
- '--install-lib=lib/python2.7/site-packages' ,
814
- _env = hpenv , * self .setup_extra_args )
815
795
816
796
# If asked, also install in the hostpython build dir
817
797
if self .install_in_hostpython :
@@ -966,20 +946,13 @@ def build_cython_components(self, arch):
966
946
info ('First build appeared to complete correctly, skipping manual'
967
947
'cythonising.' )
968
948
969
- if 'python2' in self .ctx .recipe_build_order :
970
- info ('Stripping object files' )
971
- build_lib = glob .glob ('./build/lib*' )
972
- shprint (sh .find , build_lib [0 ], '-name' , '*.o' , '-exec' ,
973
- env ['STRIP' ], '{}' , ';' , _env = env )
974
-
975
- else : # python3crystax or python3
976
- info ('Stripping object files' )
977
- shprint (sh .find , '.' , '-iname' , '*.so' , '-exec' ,
978
- '/usr/bin/echo' , '{}' , ';' , _env = env )
979
- shprint (sh .find , '.' , '-iname' , '*.so' , '-exec' ,
980
- env ['STRIP' ].split (' ' )[0 ], '--strip-unneeded' ,
981
- # '/usr/bin/strip', '--strip-unneeded',
982
- '{}' , ';' , _env = env )
949
+ info ('Stripping object files' )
950
+ shprint (sh .find , '.' , '-iname' , '*.so' , '-exec' ,
951
+ '/usr/bin/echo' , '{}' , ';' , _env = env )
952
+ shprint (sh .find , '.' , '-iname' , '*.so' , '-exec' ,
953
+ env ['STRIP' ].split (' ' )[0 ], '--strip-unneeded' ,
954
+ # '/usr/bin/strip', '--strip-unneeded',
955
+ '{}' , ';' , _env = env )
983
956
984
957
def cythonize_file (self , env , build_dir , filename ):
985
958
short_filename = filename
0 commit comments