Skip to content

Commit 922625c

Browse files
authored
Merge pull request #1109 from inclement/try_system_python_compile
Try system python when performing compileall
2 parents 4727b1c + 48eb6e8 commit 922625c

File tree

1 file changed

+15
-0
lines changed
  • pythonforandroid/bootstraps/sdl2/build

1 file changed

+15
-0
lines changed

pythonforandroid/bootstraps/sdl2/build/build.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ def parse_args(args=None):
491491
'NAME:PATH_TO_PY[:foreground]')
492492
ap.add_argument('--add-source', dest='extra_source_dirs', action='append',
493493
help='Include additional source dirs in Java build')
494+
ap.add_argument('--try-system-python-compile', dest='try_system_python_compile',
495+
action='store_true',
496+
help='Use the system python during compileall if possible.')
494497
ap.add_argument('--no-compile-pyo', dest='no_compile_pyo', action='store_true',
495498
help='Do not optimise .py files to .pyo.')
496499
ap.add_argument('--sign', action='store_true',
@@ -524,6 +527,18 @@ def parse_args(args=None):
524527
if args.services is None:
525528
args.services = []
526529

530+
if args.try_system_python_compile:
531+
# Hardcoding python2.7 is okay for now, as python3 skips the
532+
# compilation anyway
533+
if not exists('crystax_python'):
534+
python_executable = 'python2.7'
535+
try:
536+
subprocess.call([python_executable, '--version'])
537+
except (OSError, subprocess.CalledProcessError):
538+
pass
539+
else:
540+
PYTHON = python_executable
541+
527542
if args.no_compile_pyo:
528543
PYTHON = None
529544
BLACKLIST_PATTERNS.remove('*.py')

0 commit comments

Comments
 (0)