@@ -758,6 +758,34 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
758
758
env ['PYTHONNOUSERSITE' ] = '1'
759
759
760
760
if not self .call_hostpython_via_targetpython :
761
+ # sets python headers/linkages...depending on python's recipe
762
+ python_version = self .ctx .python_recipe .version
763
+ python_short_version = '.' .join (python_version .split ('.' )[:2 ])
764
+ if 'python2' in self .ctx .recipe_build_order :
765
+ env ['PYTHON_ROOT' ] = self .c
8000
tx .get_python_install_dir ()
766
+ env ['CFLAGS' ] += ' -I' + env [
767
+ 'PYTHON_ROOT' ] + '/include/python2.7'
768
+ env ['LDFLAGS' ] += ' -L' + env ['PYTHON_ROOT' ] + '/lib' + \
769
+ ' -lpython2.7'
770
+ elif self .ctx .python_recipe .from_crystax :
771
+ ndk_dir_python = join (self .ctx .ndk_dir , 'sources' ,
772
+ 'python' , python_version )
773
+ env ['CFLAGS' ] += ' -I{} ' .format (
774
+ join (ndk_dir_python , 'include' ,
775
+ 'python' ))
776
+ env ['LDFLAGS' ] += ' -L{}' .format (
777
+ join (ndk_dir_python , 'libs' , arch .arch ))
778
+ env ['LDFLAGS' ] += ' -lpython{}m' .format (python_short_version )
779
+ elif 'python3' in self .ctx .recipe_build_order :
780
+ # This headers are unused cause python3 recipe was removed
781
+ # TODO: should be reviewed when python3 recipe added
782
+ env ['PYTHON_ROOT' ] = self .ctx .get_python_install_dir ()
783
+ env ['CFLAGS' ] += ' -I' + env [
784
+ 'PYTHON_ROOT' ] + '/include/python{}m' .format (
785
+ python_short_version )
786
+ env ['LDFLAGS' ] +=
8000
9; -L' + env ['PYTHON_ROOT' ] + '/lib' + \
787
+ ' -lpython{}m' .format (
788
+ python_short_version )
761
789
hppath = []
762
790
hppath .append (join (dirname (self .hostpython_location ), 'Lib' ))
763
791
hppath .append (join (hppath [0 ], 'site-packages' ))
@@ -889,17 +917,14 @@ def get_recipe_env(self, arch):
889
917
keys = dict (
890
918
ctx = self .ctx ,
891
919
arch = arch ,
892
- arch_noeabi = arch .arch .replace ('eabi' , '' ),
893
- pyroot = self .ctx .get_python_install_dir ()
920
+ arch_noeabi = arch .arch .replace ('eabi' , '' )
894
921
)
895
922
env ['LDSHARED' ] = env ['CC' ] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
896
- env ['CFLAGS' ] += " -I{pyroot}/include/python2.7 " \
897
- " -I{ctx.ndk_dir}/platforms/android-{ctx.android_api}/arch-{arch_noeabi}/usr/include" \
923
+ env ['CFLAGS' ] += " -I{ctx.ndk_dir}/platforms/android-{ctx.android_api}/arch-{arch_noeabi}/usr/include" \
898
924
" -I{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/include" \
899
925
" -I{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/include" .format (** keys )
900
926
env ['CXXFLAGS' ] = env ['CFLAGS' ] + ' -frtti -fexceptions'
901
927
env ['LDFLAGS' ] += " -L{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}" \
902
8000
td>
- " -lpython2.7" \
903
928
" -lgnustl_shared" .format (** keys )
904
929
905
930
return env
@@ -919,6 +944,7 @@ class CythonRecipe(PythonRecipe):
919
944
pre_build_ext = False
920
945
cythonize = True
921
946
cython_args = []
947
+ call_hostpython_via_targetpython = False
922
948
923
949
def __init__ (self , * args , ** kwargs ):
924
950
super (CythonRecipe , self ).__init__ (* args , ** kwargs )
@@ -1042,21 +1068,6 @@ def get_recipe_env(self, arch, with_flags_in_cc=True):
1042
1068
env ['LIBLINK_PATH' ] = liblink_path
1043
1069
ensure_dir (liblink_path )
1044
1070
1045
- if self .ctx .python_recipe .from_crystax :
1046
- env ['CFLAGS' ] = '-I{} ' .format (
1047
- join (self .ctx .ndk_dir , 'sources' , 'python' ,
1048
- self .ctx .python_recipe .version , 'include' ,
1049
- 'python' )) + env ['CFLAGS' ]
1050
-
1051
- # Temporarily hardcode the -lpython3.x as this does not
1052
- # get applied automatically in some environments. This
1053
- # will need generalising, along with the other hardcoded
1054
- # py3.5 references, to support other python3 or crystax
1055
- # python versions.
1056
- python3_version = self .ctx .python_recipe .version
1057
- python3_version = '.' .join (python3_version .split ('.' )[:2 ])
1058
- env ['LDFLAGS' ] = env ['LDFLAGS' ] + ' -lpython{}m' .format (python3_version )
1059
-
1060
1071
return env
1061
1072
1062
1073
0 commit comments