@@ -1896,9 +1896,25 @@ def get_jni_dir(self):
1896
1896
1897
1897
1898
1898
class 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
1902
1918
1903
1919
def should_build (self ):
1904
1920
# AND: This should be different for each arch and use some
@@ -1914,8 +1930,6 @@ def should_build(self):
1914
1930
info ('{} apparently isn\' t already in site-packages' .format (name ))
1915
1931
return True
1916
1932
1917
-
1918
-
1919
1933
def build_arch (self , arch ):
1920
1934
'''Install the Python module by calling setup.py install with
1921
1935
the target Python dir.'''
@@ -1938,9 +1952,16 @@ def install_python_package(self, name=None, env=None, is_dir=True):
1938
1952
info ('Installing {} into site-packages' .format (self .name ))
1939
1953
1940
1954
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 )
1942
1957
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
1944
1965
1945
1966
1946
1967
class CompiledComponentsPythonRecipe (PythonRecipe ):
0 commit comments