Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile pyo with sdl2 #944

Merged
merged 2 commits into from
Dec 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions pythonforandroid/bootstraps/sdl2/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

# Try to find a host version of Python that matches our ARM version.
PYTHON = join(curdir, 'python-install', 'bin', 'python.host')
if not exists(PYTHON):
print('Could not find hostpython, will not compile to .pyo (this is normal with python3)')
PYTHON = None

BLACKLIST_PATTERNS = [
# code versionning
Expand All @@ -38,13 +41,14 @@

# pyc/py
'*.pyc',
# '*.py', # AND: Need to fix this to add it back

# temp files
'~',
'*.bak',
'*.swp',
]
if PYTHON is not None:
BLACKLIST_PATTERNS.append('*.py')

WHITELIST_PATTERNS = []

Expand Down Expand Up @@ -202,9 +206,9 @@ def compile_dir(dfn):
'''
Compile *.py in directory `dfn` to *.pyo
'''

return # AND: Currently leaving out the compile to pyo step because it's somehow broken
# -OO = strip docstrings
if PYTHON is None:
return
subprocess.call([PYTHON, '-OO', '-m', 'compileall', '-f', dfn])


Expand Down Expand Up @@ -370,7 +374,7 @@ def make_package(args):


def parse_args(args=None):
global BLACKLIST_PATTERNS, WHITELIST_PATTERNS
global BLACKLIST_PATTERNS, WHITELIST_PATTERNS, PYTHON
default_android_api = 12
import argparse
ap = argparse.ArgumentParser(description='''\
Expand Down Expand Up @@ -455,6 +459,8 @@ def parse_args(args=None):
'NAME:PATH_TO_PY[:foreground]')
ap.add_argument('--add-source', dest='extra_source_dirs', action='append',
help='Include additional source dirs in Java build')
ap.add_argument('--no-compile-pyo', dest='no_compile_pyo', action='store_true',
help='Do not optimise .py files to .pyo.')

if args is None:
args = sys.argv[1:]
Expand All @@ -480,6 +486,10 @@ def parse_args(args=None):
if args.services is None:
args.services = []

if args.no_compile_pyo:
PYTHON = None
BLACKLIST_PATTERNS.remove('*.py')

if args.blacklist:
with open(args.blacklist) as fd:
patterns = [x.strip() for x in fd.read().splitlines()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ protected void onCreate(Bundle savedInstanceState) {
SDLActivity.nativeSetEnv("ANDROID_ENTRYPOINT", "main.pyo");
SDLActivity.nativeSetEnv("PYTHONHOME", app_root_dir);
SDLActivity.nativeSetEnv("PYTHONPATH", app_root_dir + ":" + app_root_dir + "/lib");
SDLActivity.nativeSetEnv("PYTHONOPTIMIZE", "2");

try {
Log.v(TAG, "Access to our meta-data...");
Expand Down