Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions pythonforandroid/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,9 @@ class PythonRecipe(Recipe):
call_hostpython_via_targetpython is False.
'''

setup_extra_args = []
'''List of extra arguments to pass to setup.py.'''

@property
def hostpython_location(self):
if not self.call_hostpython_via_targetpython:
Expand Down Expand Up @@ -2208,12 +2211,20 @@ 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:
hppath = join(dirname(self.hostpython_location), 'Lib',
'site-packages')
hpenv = env.copy()
if 'PYTHONPATH' in hpenv:
hpenv['PYTHONPATH'] = ':'.join(
[hppath] + hpenv['PYTHONPATH'].split(':'))
else:
hpenv['PYTHONPATH'] = hppath
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=hpenv, *self.setup_extra_args) # AND: Hardcoded python2.7 needs fixing

# If asked, also install in the hostpython build dir
if self.install_in_hostpython:
Expand All @@ -2239,8 +2250,15 @@ 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)
Expand Down