@@ -1927,6 +1927,10 @@ class PythonRecipe(Recipe):
19271927 call_hostpython_via_targetpython is False.
19281928 '''
19291929
1930+ install_in_targetpython = True
1931+ '''If True (default), install the module in the target python build.
1932+ '''
1933+
19301934 @property
19311935 def hostpython_location (self ):
19321936 if not self .call_hostpython_via_targetpython :
@@ -1974,13 +1978,14 @@ def install_python_package(self, name=None, env=None, is_dir=True):
19741978 # hostpython = sh.Command(self.ctx.hostpython)
19751979 hostpython = sh .Command (self .hostpython_location )
19761980
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
19841989
19851990 # If asked, also install in the hostpython build dir
19861991 if self .install_in_hostpython :
@@ -2935,6 +2940,36 @@ def build_status(self, args):
29352940 recipe_str += '{Style.RESET_ALL}' .format (Style = Style )
29362941 print (recipe_str )
29372942
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 )
29382973
29392974def main ():
29402975 ToolchainCL ()
0 commit comments