Skip to content

Commit ccab213

Browse files
committed
Fixes to run under python3
1 parent 94dad85 commit ccab213

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

pythonforandroid/bootstraps/sdl2/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ def run_distribute(self):
9797

9898
info('Renaming .so files to reflect cross-compile')
9999
site_packages_dir = 'crystax_python/crystax_python/site-packages'
100-
filens = shprint(sh.find, site_packages_dir, '-iname', '*.so').stdout.split('\n')[:-1]
100+
filens = shprint(sh.find, site_packages_dir, '-iname', '*.so').stdout.decode(
101+
'utf-8').split('\n')[:-1]
101102
for filen in filens:
102103
parts = filen.split('.')
103104
if len(parts) <= 2:

pythonforandroid/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
211211
self.android_api = android_api
212212

213213
android = sh.Command(join(sdk_dir, 'tools', 'android'))
214-
targets = android('list').stdout.split('\n')
214+
targets = android('list').stdout.decode('utf-8').split('\n')
215215
apis = [s for s in targets if re.match(r'^ *API level: ', s)]
216216
apis = [re.findall(r'[0-9]+', s) for s in apis]
217217
apis = [int(s[0]) for s in apis if s]

pythonforandroid/logger.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
from collections import defaultdict
99
from colorama import Style as Colo_Style, Fore as Colo_Fore
1010

11-
import codecs
12-
stdout = codecs.getwriter('utf8')(stdout)
13-
stderr = codecs.getwriter('utf8')(stderr)
11+
# This codecs change fixes a bug with log output, but crashes under python3
12+
# import codecs
13+
# stdout = codecs.getwriter('utf8')(stdout)
14+
# stderr = codecs.getwriter('utf8')(stderr)
1415

1516
# monkey patch to show full output
1617
sh.ErrorReturnCode.truncate_cap = 999999

pythonforandroid/recipe.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,10 @@ def build_cython_components(self, arch):
830830
env = self.get_recipe_env(arch)
831831

832832
if self.ctx.python_recipe.from_crystax:
833-
site_packages_dirs = sh.Command('python{}'.format(self.ctx.python_recipe.version))('-c', 'import site; print("\\n".join(site.getsitepackages()))').stdout.split('\n')
833+
command = sh.Command('python{}'.format(self.ctx.python_recipe.version))
834+
site_packages_dirs = command(
835+
'-c', 'import site; print("\\n".join(site.getsitepackages()))')
836+
site_packages_dirs = site_packages_dirs.stdout.decode('utf-8').split('\n')
834837
# env['PYTHONPATH'] = '/usr/lib/python3.5/site-packages/:/usr/lib/python3.5'
835838
if 'PYTHONPATH' in env:
836839
env['PYTHONPATH'] = env + ':{}'.format(':'.join(site_packages_dirs))

pythonforandroid/recipes/python2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def do_python_build(self, arch):
8888
# neatness, but the whole recipe needs tidying along these
8989
# lines
9090
env['HOSTARCH'] = 'arm-eabi'
91-
env['BUILDARCH'] = shprint(sh.gcc, '-dumpmachine').stdout.split('\n')[0]
91+
env['BUILDARCH'] = shprint(sh.gcc, '-dumpmachine').stdout.decode('utf-8').split('\n')[0]
9292
env['CFLAGS'] = ' '.join([env['CFLAGS'], '-DNO_MALLINFO'])
9393

9494
# TODO need to add a should_build that checks if optional

0 commit comments

Comments
 (0)