@@ -1896,9 +1896,25 @@ def get_jni_dir(self):
18961896
18971897
18981898class PythonRecipe (Recipe ):
1899- site_packages_name = None # The name of the module in
1900- # site_packages (i.e. as a python
1901- # module)
1899+ site_packages_name = None
1900+ '''The name of the module's folder when installed in the Python
1901+ site-packages (e.g. for pyjnius it is 'jnius')'''
1902+
1903+ call_hostpython_via_targetpython = True
1904+ '''If True, tries to install the module using the hostpython binary
1905+ copied to the target (normally arm) python build dir. However, this
1906+ will fail if the module tries to import e.g. _io.so. Set this to False
1907+ to call hostpython from its own build dir, installing the module in
1908+ the right place via arguments to setup.py. However, this may not set
1909+ the environment correctly and so False is not the default.'''
1910+
1911+ @property
1912+ def hostpython_location (self ):
1913+ if not self .call_hostpython_via_targetpython :
1914+ return join (
1915+ Recipe .get_recipe ('hostpython2' , self .ctx ).get_build_dir (
1916+ 'armeabi' ), 'hostpython' )
1917+ return self .ctx .hostpython
19021918
19031919 def should_build (self ):
19041920 # AND: This should be different for each arch and use some
@@ -1914,8 +1930,6 @@ def should_build(self):
19141930 info ('{} apparently isn\' t already in site-packages' .format (name ))
19151931 return True
19161932
1917-
1918-
19191933 def build_arch (self , arch ):
19201934 '''Install the Python module by calling setup.py install with
19211935 the target Python dir.'''
@@ -1938,9 +1952,16 @@ def install_python_package(self, name=None, env=None, is_dir=True):
19381952 info ('Installing {} into site-packages' .format (self .name ))
19391953
19401954 with current_directory (self .get_build_dir (arch .arch )):
1941- hostpython = sh .Command (self .ctx .hostpython )
1955+ # hostpython = sh.Command(self.ctx.hostpython)
1956+ hostpython = sh .Command (self .hostpython_location )
19421957
1943- shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env )
1958+ if self .call_hostpython_via_targetpython :
1959+ shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env )
1960+ else :
1961+ shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
1962+ '--root={}' .format (self .ctx .get_python_install_dir ()),
1963+ '--install-lib=lib/python2.7/site-packages' ,
1964+ _env = env ) # AND: Hardcoded python2.7 needs fixing
19441965
19451966
19461967class CompiledComponentsPythonRecipe (PythonRecipe ):
0 commit comments