Skip to content

Commit 327dabd

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 cbab936 commit 327dabd

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
@@ -23,16 +23,24 @@
2323
import jinja2
2424

2525

26-
def get_bootstrap_name():
26+
def get_dist_info_for(key):
2727
try:
2828
with open(join(dirname(__file__), 'dist_info.json'), 'r') as fileh:
2929
info = json.load(fileh)
30-
bootstrap = str(info["bootstrap"])
30+
value = str(info[key])
3131
except (OSError, KeyError) as e:
32-
print("BUILD FAILURE: Couldn't extract bootstrap name " +
32+
print("BUILD FAILURE: Couldn't extract the key `" + key + "` " +
3333
"from dist_info.json: " + str(e))
3434
sys.exit(1)
35-
return bootstrap
35+
return value
36+
37+
38+
def get_hostpython():
39+
return get_dist_info_for('hostpython')
40+
41+
42+
def get_bootstrap_name():
43+
return get_dist_info_for('bootstrap')
3644

3745

3846
if os.name == 'nt':
@@ -44,9 +52,8 @@ def get_bootstrap_name():
4452

4553
curdir = dirname(__file__)
4654

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

5259
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)