Skip to content

Commit c5d3c8b

Browse files
committed
Add ability to get hostpython and python version when creating our distribution files
Because this will allows us to restore the ability to compile python code to .pyo/.pyc (python2/python3)
1 parent d0798b2 commit c5d3c8b

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

pythonforandroid/bootstraps/common/build/build.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,24 @@
2222
import jinja2
2323

2424

25-
def get_bootstrap_name():
25+
def get_dist_info_for(key):
2626
try:
2727
with open(join(dirname(__file__), 'dist_info.json'), 'r') as fileh:
2828
info = json.load(fileh)
29-
bootstrap = str(info["bootstrap"])
29+
value = str(info[key])
3030
except (OSError, KeyError) as e:
31-
print("BUILD FAILURE: Couldn't extract bootstrap name " +
31+
print("BUILD FAILURE: Couldn't extract the key `" + key + "` " +
3232
"from dist_info.json: " + str(e))
3333
sys.exit(1)
34-
return bootstrap
34+
return value
35+
36+
37+
def get_hostpython():
38+
return get_dist_info_for('hostpython')
39+
40+
41+
def get_bootstrap_name():
42+
return get_dist_info_for('bootstrap')
3543

3644

3745
if os.name == 'nt':
@@ -43,9 +51,8 @@ def get_bootstrap_name():
4351

4452
curdir = dirname(__file__)
4553

46-
# Try to find a host version of Python that matches our ARM version.
47-
PYTHON = join(curdir, 'python-install', 'bin', 'python.host')
48-
if not exists(PYTHON):
54+
PYTHON = get_hostpython()
55+
if PYTHON is not None and not exists(PYTHON):
4956
PYTHON = None
5057

5158
BLACKLIST_PATTERNS = [

pythonforandroid/distribution.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ def save_info(self, dirn):
216216
'bootstrap': self.ctx.bootstrap.name,
217217
'archs': [arch.arch for arch in self.ctx.archs],
218218
'ndk_api': self.ctx.ndk_api,
219-
'recipes': self.ctx.recipe_build_order + self.ctx.python_modules},
219+
'recipes': self.ctx.recipe_build_order + self.ctx.python_modules,
220+
'hostpython': self.ctx.hostpython,
221+
'python_version': self.ctx.python_recipe.major_minor_version_string},
220222
fileh)
221223

222224

0 commit comments

Comments
 (0)