@@ -1927,6 +1927,10 @@ class PythonRecipe(Recipe):
1927
1927
call_hostpython_via_targetpython is False.
1928
1928
'''
1929
1929
1930
+ install_in_targetpython = True
1931
+ '''If True (default), install the module in the target python build.
1932
+ '''
1933
+
1930
1934
@property
1931
1935
def hostpython_location (self ):
1932
1936
if not self .call_hostpython_via_targetpython :
@@ -1974,13 +1978,14 @@ def install_python_package(self, name=None, env=None, is_dir=True):
1974
1978
# hostpython = sh.Command(self.ctx.hostpython)
1975
1979
hostpython = sh .Command (self .hostpython_location )
1976
1980
1977
- if self .call_hostpython_via_targetpython :
1978
- shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env )
1979
- else :
1980
- shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
1981
- '--root={}' .format (self .ctx .get_python_install_dir ()),
1982
- '--install-lib=lib/python2.7/site-packages' ,
1983
- _env = env ) # AND: Hardcoded python2.7 needs fixing
1981
+ if self .install_in_targetpython :
1982
+ if self .call_hostpython_via_targetpython :
1983
+ shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env )
1984
+ else :
1985
+ shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
1986
+ '--root={}' .format (self .ctx .get_python_install_dir ()),
1987
+ '--install-lib=lib/python2.7/site-packages' ,
1988
+ _env = env ) # AND: Hardcoded python2.7 needs fixing
1984
1989
1985
1990
# If asked, also install in the hostpython build dir
1986
1991
if self .install_in_hostpython :
@@ -2935,6 +2940,36 @@ def build_status(self, args):
2935
2940
recipe_str += '{Style.RESET_ALL}' .format (Style = Style )
2936
2941
print (recipe_str )
2937
2942
2943
+ def hostpython (self , args ):
2944
+ '''Get an hostpython shell for the default arch
2945
+ '''
2946
+ ctx = self .ctx
2947
+ ctx .prepare_build_environment (user_sdk_dir = self .sdk_dir ,
2948
+ user_ndk_dir = self .ndk_dir ,
2949
+ user_android_api = self .android_api ,
2950
+ user_ndk_ver = self .ndk_version )
2951
+
2952
+ recipe = Recipe .get_recipe ('hostpython2' , self .ctx )
2953
+ hostpython = join (recipe .get_build_dir ('armeabi' ), 'hostpython' )
2954
+ env = recipe .get_recipe_env ()
2955
+ env ["PYTHONPATH" ] = ":" .join ([
2956
+ join (recipe .get_build_dir ('armeabi' ), 'Lib' , 'site-packages' )
2957
+ ])
2958
+ env ["CFLAGS" ] = "-I/home/tito/.local/share/python-for-android/build/other_builds/numpy/armeabi/numpy/numpy/core/include {}" .format (env ["CFLAGS" ])
2959
+ env ["CFLAGS" ] = "-I/home/tito/.local/share/python-for-android/build/other_builds/numpy/armeabi/numpy/build/src.linux-x86_64-2.7/numpy/core/include/numpy {}" .format (env ["CFLAGS" ])
2960
+ env ["CFLAGS" ] = "-I/home/tito/.local/share/python-for-android/build/other_builds/python2/armeabi/python2/Include {}" .format (env ["CFLAGS" ])
2961
+ env ["CFLAGS" ] = "-I/home/tito/.local/share/python-for-android/build/other_builds/python2/armeabi/python2 {}" .format (env ["CFLAGS" ])
2962
+ # env["LDFLAGS"] = "-lpython2.7 -lc"
2963
+ env ["LDFLAGS" ] = "-lpython2.7"
2964
+ env ["LDFLAGS" ] = "-L/home/tito/.local/share/python-for-android/build/other_builds/python2/armeabi/python2 {}" .format (env ["LDFLAGS" ])
2965
+ # env["LDSHARED"] = "{} -shared".format(env["LD"])
2966
+ env ["LDSHARED" ] = "{} -shared" .format (env ["CC" ])
2967
+ env ["CFLAGS" ] = env ["CFLAGS" ].replace ("-DANDROID" , "" )
2968
+ env ["CXXFLAGS" ] = env ["CXXFLAGS" ].replace ("-DANDROID" , "" )
2969
+ from pprint import pprint
2970
+ pprint (env )
2971
+ pprint (ctx .include_dirs )
2972
+ os .execve (hostpython , [hostpython ] + args , env )
2938
2973
2939
2974
def main ():
2940
2975
ToolchainCL ()
0 commit comments