28
28
29
29
# Try to find a host version of Python that matches our ARM version.
30
30
PYTHON = join (curdir , 'python-install' , 'bin' , 'python.host' )
31
+ if not exists (PYTHON ):
32
+ print ('Could not find hostpython, will not compile to .pyo (this is normal with python3)' )
33
+ PYTHON = None
31
34
32
35
BLACKLIST_PATTERNS = [
33
36
# code versionning
38
41
39
42
# pyc/py
40
43
'*.pyc' ,
41
- # '*.py', # AND: Need to fix this to add it back
42
44
43
45
# temp files
44
46
'~' ,
45
47
'*.bak' ,
46
48
'*.swp' ,
47
49
]
50
+ if PYTHON is not None :
51
+ BLACKLIST_PATTERNS .append ('*.py' )
48
52
49
53
WHITELIST_PATTERNS = []
50
54
@@ -202,9 +206,9 @@ def compile_dir(dfn):
202
206
'''
203
207
Compile *.py in directory `dfn` to *.pyo
204
208
'''
205
-
206
- return # AND: Currently leaving out the compile to pyo step because it's somehow broken
207
209
# -OO = strip docstrings
210
+ if PYTHON is None :
211
+ return
208
212
subprocess .call ([PYTHON , '-OO' , '-m' , 'compileall' , '-f' , dfn ])
209
213
210
214
@@ -370,7 +374,7 @@ def make_package(args):
370
374
371
375
372
376
def parse_args (args = None ):
373
- global BLACKLIST_PATTERNS , WHITELIST_PATTERNS
377
+ global BLACKLIST_PATTERNS , WHITELIST_PATTERNS , PYTHON
374
378
default_android_api = 12
375
379
import argparse
376
380
ap = argparse .ArgumentParser (description = '''\
@@ -455,6 +459,8 @@ def parse_args(args=None):
455
459
'NAME:PATH_TO_PY[:foreground]' )
456
460
ap .add_argument ('--add-source' , dest = 'extra_source_dirs' , action = 'append' ,
457
461
help = 'Include additional source dirs in Java build' )
462
+ ap .add_argument ('--no-compile-pyo' , dest = 'no_compile_pyo' , action = 'store_true' ,
463
+ help = 'Do not optimise .py files to .pyo.' )
458
464
459
465
if args is None :
460
466
args = sys .argv [1 :]
@@ -480,6 +486,10 @@ def parse_args(args=None):
480
486
if args .services is None :
481
487
args .services = []
482
488
489
+ if args .no_compile_pyo :
490
+ PYTHON = None
491
+ BLACKLIST_PATTERNS .remove ('*.py' )
492
+
483
493
if args .blacklist :
484
494
with open (args .blacklist ) as fd :
485
495
patterns = [x .strip () for x in fd .read ().splitlines ()
0 commit comments