diff --git a/pythonforandroid/recipe.py b/pythonforandroid/recipe.py index b76507940f..3a8f0c7968 100644 --- a/pythonforandroid/recipe.py +++ b/pythonforandroid/recipe.py @@ -594,6 +594,9 @@ class PythonRecipe(Recipe): call_hostpython_via_targetpython is False. ''' + setup_extra_args = [] + '''List of extra arugments to pass to setup.py''' + @property def hostpython_location(self): if not self.call_hostpython_via_targetpython: @@ -635,19 +638,21 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True): hostpython = sh.Command(self.hostpython_location) if self.call_hostpython_via_targetpython: - shprint(hostpython, 'setup.py', 'install', '-O2', _env=env) + shprint(hostpython, 'setup.py', 'install', '-O2', _env=env, + *self.setup_extra_args) else: shprint(hostpython, 'setup.py', 'install', '-O2', '--root={}'.format(self.ctx.get_python_install_dir()), '--install-lib=lib/python2.7/site-packages', - _env=env) # AND: Hardcoded python2.7 needs fixing + _env=env, *self.setup_extra_args) + # AND: Hardcoded python2.7 needs fixing # If asked, also install in the hostpython build dir if self.install_in_hostpython: shprint(hostpython, 'setup.py', 'install', '-O2', '--root={}'.format(dirname(self.hostpython_location)), '--install-lib=Lib/site-packages', - _env=env) + _env=env, *self.setup_extra_args) class CompiledComponentsPythonRecipe(PythonRecipe): @@ -666,8 +671,16 @@ def build_compiled_components(self, arch): env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): - hostpython = sh.Command(self.ctx.hostpython) - shprint(hostpython, 'setup.py', 'build_ext', '-v') + hostpython = sh.Command(self.hostpython_location) + if self.call_hostpython_via_targetpython: + shprint(hostpython, 'setup.py', 'build_ext', '-v', + *self.setup_extra_args) + else: + hppath = join(dirname(self.hostpython_location), 'Lib', + 'site-packages') + hpenv = {'PYTHONPATH': hppath} + shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=hpenv, + *self.setup_extra_args) build_dir = glob.glob('build/lib.*')[0] shprint(sh.find, build_dir, '-name', '"*.o"', '-exec', env['STRIP'], '{}', ';', _env=env) @@ -693,7 +706,8 @@ def build_cython_components(self, arch): info('Trying first build of {} to get cython files: this is ' 'expected to fail'.format(self.name)) try: - shprint(hostpython, 'setup.py', 'build_ext', _env=env) + shprint(hostpython, 'setup.py', 'build_ext', _env=env, + *self.setup_extra_args) except sh.ErrorReturnCode_1: print() info('{} first build failed (as expected)'.format(self.name)) @@ -704,7 +718,7 @@ def build_cython_components(self, arch): info('ran cython') shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env, - _tail=20, _critical=True) + _tail=20, _critical=True, *self.setup_extra_args) print('stripping') build_lib = glob.glob('./build/lib*')