@@ -1672,7 +1672,7 @@ def unpack(self, arch):
16721672 info ('Extracting {} at {}' .format (extraction_filename , filename ))
16731673 sh .tar ('xjf' , extraction_filename )
16741674 root_directory = sh .tar ('tjf' , extraction_filename ).stdout .decode (
1675- 'utf-8' ).split ('\n ' )[0 ].strip ('/' )
1675+ 'utf-8' ).split ('\n ' )[0 ].split ('/' )[ 0 ]
16761676 if root_directory != directory_name :
16771677 shprint (sh .mv , root_directory , directory_name )
16781678 elif extraction_filename .endswith ('.zip' ):
@@ -1896,9 +1896,31 @@ 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+ install_in_hostpython = False
1912+ '''If True, additionally installs the module in the hostpython build
1913+ dir. This will make it available to other recipes if
1914+ call_hostpython_via_targetpython is False.
1915+ '''
1916+
1917+ @property
1918+ def hostpython_location (self ):
1919+ if not self .call_hostpython_via_targetpython :
1920+ return join (
1921+ Recipe .get_recipe ('hostpython2' , self .ctx ).get_build_dir (
1922+ 'armeabi' ), 'hostpython' )
1923+ return self .ctx .hostpython
19021924
19031925 def should_build (self ):
19041926 # AND: This should be different for each arch and use some
@@ -1914,8 +1936,6 @@ def should_build(self):
19141936 info ('{} apparently isn\' t already in site-packages' .format (name ))
19151937 return True
19161938
1917-
1918-
19191939 def build_arch (self , arch ):
19201940 '''Install the Python module by calling setup.py install with
19211941 the target Python dir.'''
@@ -1938,9 +1958,23 @@ def install_python_package(self, name=None, env=None, is_dir=True):
19381958 info ('Installing {} into site-packages' .format (self .name ))
19391959
19401960 with current_directory (self .get_build_dir (arch .arch )):
1941- hostpython = sh .Command (self .ctx .hostpython )
1961+ # hostpython = sh.Command(self.ctx.hostpython)
1962+ hostpython = sh .Command (self .hostpython_location )
1963+
1964+ if self .call_hostpython_via_targetpython :
1965+ shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env )
1966+ else :
1967+ shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
1968+ '--root={}' .format (self .ctx .get_python_install_dir ()),
1969+ '--install-lib=lib/python2.7/site-packages' ,
1970+ _env = env ) # AND: Hardcoded python2.7 needs fixing
19421971
1943- shprint (hostpython , 'setup.py' , 'install' , '-O2' , _env = env )
1972+ # If asked, also install in the hostpython build dir
1973+ if self .install_in_hostpython :
1974+ shprint (hostpython , 'setup.py' , 'install' , '-O2' ,
1975+ '--root={}' .format (dirname (self .hostpython_location )),
1976+ '--install-lib=Lib/site-packages' ,
1977+ _env = env )
19441978
19451979
19461980class CompiledComponentsPythonRecipe (PythonRecipe ):
@@ -2169,7 +2203,7 @@ def biglink(ctx, arch):
21692203 info ('There seem to be no libraries to biglink, skipping.' )
21702204 return
21712205 info ('Biglinking' )
2172- info ('target' , join (ctx .get_libs_dir (arch .arch ), 'libpymodules.so' ))
2206+ info ('target {}' . format ( join (ctx .get_libs_dir (arch .arch ), 'libpymodules.so' ) ))
21732207 biglink_function (
21742208 join (ctx .get_libs_dir (arch .arch ), 'libpymodules.so' ),
21752209 obj_dir .split (' ' ),
0 commit comments