@@ -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 .ctx .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' ] += ' -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' ))
@@ -844,17 +872,6 @@ class CompiledComponentsPythonRecipe(PythonRecipe):
844
872
845
873
build_cmd = 'build_ext'
846
874
847
- def get_recipe_env (self , arch = None , with_flags_in_cc = True ):
848
- env = super (CompiledComponentsPythonRecipe ,
849
- self ).get_recipe_env (arch , with_flags_in_cc )
850
- if not self .call_hostpython_via_targetpython :
851
- if 'python2' in self .ctx .recipe_build_order :
852
- env ['PYTHON_ROOT' ] = self .ctx .get_python_install_dir ()
853
- env ['CFLAGS' ] += ' -I' + env ['PYTHON_ROOT' ] + '/include/python2.7'
854
- env ['LDFLAGS' ] += ' -L' + env ['PYTHON_ROOT' ] + '/lib' + \
855
- ' -lpython2.7'
856
- return env
857
-
858
875
def build_arch (self , arch ):
859
876
'''Build any cython components, then install the Python module by
860
877
calling setup.py install with the target Python dir.
@@ -900,17 +917,14 @@ def get_recipe_env(self, arch):
900
917
keys = dict (
901
918
ctx = self .ctx ,
902
919
arch = arch ,
903
- arch_noeabi = arch .arch .replace ('eabi' , '' ),
904
- pyroot = self .ctx .get_python_install_dir ()
920
+ arch_noeabi = arch .arch .replace ('eabi' , '' )
905
921
)
906
922
env ['LDSHARED' ] = env ['CC' ] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
907
- env ['CFLAGS' ] += " -I{pyroot}/include/python2.7 " \
908
- " -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" \
909
924
" -I{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/include" \
910
925
" -I{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/include" .format (** keys )
911
926
env ['CXXFLAGS' ] = env ['CFLAGS' ] + ' -frtti -fexceptions'
912
927
env ['LDFLAGS' ] += " -L{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}" \
913
- " -lpython2.7" \
914
928
" -lgnustl_shared" .format (** keys )
915
929
916
930
return env
@@ -1053,21 +1067,6 @@ def get_recipe_env(self, arch, with_flags_in_cc=True):
1053
1067
env ['LIBLINK_PATH' ] = liblink_path
1054
1068
ensure_dir (liblink_path )
1055
1069
1056
- if self .ctx .python_recipe .from_crystax :
1057
- env ['CFLAGS' ] = '-I{} ' .format (
1058
- join (self .ctx .ndk_dir , 'sources' , 'python' ,
1059
- self .ctx .python_recipe .version , 'include' ,
1060
- 'python' )) + env ['CFLAGS' ]
1061
-
1062
- # Temporarily hardcode the -lpython3.x as this does not
1063
- # get applied automatically in some environments. This
1064
- # will need generalising, along with the other hardcoded
1065
- # py3.5 references, to support other python3 or crystax
1066
- # python versions.
1067
- python3_version = self .ctx .python_recipe .version
1068
- python3_version = '.' .join (python3_version .split ('.' )[:2 ])
1069
- env ['LDFLAGS' ] = env ['LDFLAGS' ] + ' -lpython{}m' .format (python3_version )
1070
-
1071
1070
return env
1072
1071
1073
1072
0 commit comments