Skip to content

Commit 5c0f96f

Browse files
committed
symlink system Python to hostpython3crystax build dir
Creates an empty hostpython3crystax build directory and symlinks system python3.5 to it, fixes #1154
1 parent 405934e commit 5c0f96f

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

pythonforandroid/recipe.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,10 @@ def real_hostpython_location(self):
724724
return join(
725725
Recipe.get_recipe('hostpython2', self.ctx).get_build_dir(),
726726
'hostpython')
727+
elif 'hostpython3crystax' in self.ctx.recipe_build_order:
728+
return join(
729+
Recipe.get_recipe('hostpython3crystax', self.ctx).get_build_dir(),
730+
'hostpython')
727731
else:
728732
python_recipe = self.ctx.python_recipe
729733
return 'python{}'.format(python_recipe.version)
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
2-
from pythonforandroid.toolchain import Recipe, shprint, current_directory, info, warning
3-
from os.path import join, exists
4-
from os import chdir
1+
from pythonforandroid.toolchain import Recipe, shprint
2+
from os.path import join
53
import sh
64

75

@@ -13,14 +11,32 @@ class Hostpython3Recipe(Recipe):
1311

1412
conflicts = ['hostpython2']
1513

14+
def get_build_container_dir(self, arch=None):
15+
choices = self.check_recipe_choices()
16+
dir_name = '-'.join([self.name] + choices)
17+
return join(self.ctx.build_dir, 'other_builds', dir_name, 'desktop')
18+
1619
# def prebuild_armeabi(self):
1720
# # Override hostpython Setup?
1821
# shprint(sh.cp, join(self.get_recipe_dir(), 'Setup'),
1922
# join(self.get_build_dir('armeabi'), 'Modules', 'Setup'))
2023

24+
def get_build_dir(self, arch=None):
25+
return join(self.get_build_container_dir(), self.name)
26+
2127
def build_arch(self, arch):
28+
"""
29+
Creates expected build and symlinks system Python version.
30+
"""
2231
self.ctx.hostpython = '/usr/bin/false'
2332
self.ctx.hostpgen = '/usr/bin/false'
33+
# creates the sub buildir (used by other recipes)
34+
# https://github.com/kivy/python-for-android/issues/1154
35+
sub_build_dir = join(self.get_build_dir(), 'build')
36+
shprint(sh.mkdir, '-p', sub_build_dir)
37+
system_python = sh.which("python" + self.version)
38+
link_dest = join(self.get_build_dir(), 'hostpython')
39+
shprint(sh.ln, '-sf', system_python, link_dest)
2440

2541

2642
recipe = Hostpython3Recipe()

0 commit comments

Comments
 (0)