Skip to content

Commit 6b31b13

Browse files
committed
Changed python3crystax to work with python3.6
1 parent ec98886 commit 6b31b13

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

pythonforandroid/bootstraps/sdl2/build/src/org/kivy/android/PythonUtil.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,30 @@ protected static String[] getLibraries() {
1616
"SDL2_ttf",
1717
"python2.7",
1818
"python3.5m",
19+
"python3.6m",
1920
"main"
2021
};
2122
}
2223

2324
public static void loadLibraries(File filesDir) {
2425

2526
String filesDirPath = filesDir.getAbsolutePath();
26-
boolean skippedPython = false;
27+
boolean foundPython = false;
2728

2829
for (String lib : getLibraries()) {
2930
try {
3031
System.loadLibrary(lib);
32+
if (lib.startsWith("python")) {
33+
foundPython = true;
34+
}
3135
} catch(UnsatisfiedLinkError e) {
32-
if (lib.startsWith("python") && !skippedPython) {
33-
skippedPython = true;
34-
continue;
36+
// If this is the last possible libpython
37+
// load, and it has failed, give a more
38+
// general error
39+
if (lib.startsWith("python3.6") && !foundPython) {
40+
throw new java.lang.RuntimeException("Could not load any libpythonXXX.so");
3541
}
36-
throw e;
42+
continue;
3743
}
3844
}
3945

@@ -52,5 +58,5 @@ public static void loadLibraries(File filesDir) {
5258
}
5359

5460
Log.v(TAG, "Loaded everything!");
55-
}
61+
}
5662
}

pythonforandroid/recipe.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,6 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
818818

819819
with current_directory(self.get_build_dir(arch.arch)):
820820
hostpython = sh.Command(self.hostpython_location)
821-
# hostpython = sh.Command('python3.5')
822821

823822

824823
if self.ctx.python_recipe.from_crystax:
@@ -986,15 +985,13 @@ def build_cython_components(self, arch):
986985
site_packages_dirs = command(
987986
'-c', 'import site; print("\\n".join(site.getsitepackages()))')
988987
site_packages_dirs = site_packages_dirs.stdout.decode('utf-8').split('\n')
989-
# env['PYTHONPATH'] = '/usr/lib/python3.5/site-packages/:/usr/lib/python3.5'
990988
if 'PYTHONPATH' in env:
991989
env['PYTHONPATH'] = env + ':{}'.format(':'.join(site_packages_dirs))
992990
else:
993991
env['PYTHONPATH'] = ':'.join(site_packages_dirs)
994992

995993
with current_directory(self.get_build_dir(arch.arch)):
996994
hostpython = sh.Command(self.ctx.hostpython)
997-
# hostpython = sh.Command('python3.5')
998995
shprint(hostpython, '-c', 'import sys; print(sys.path)', _env=env)
999996
print('cwd is', realpath(curdir))
1000997
info('Trying first build of {} to get cython files: this is '
@@ -1089,12 +1086,14 @@ def get_recipe_env(self, arch, with_flags_in_cc=True):
10891086
self.ctx.python_recipe.version, 'include',
10901087
'python')) + env['CFLAGS']
10911088

1092-
# Temporarily hardcode the -lpython3.5 as this does not
1089+
# Temporarily hardcode the -lpython3.x as this does not
10931090
# get applied automatically in some environments. This
10941091
# will need generalising, along with the other hardcoded
10951092
# py3.5 references, to support other python3 or crystax
10961093
# python versions.
1097-
env['LDFLAGS'] = env['LDFLAGS'] + ' -lpython3.5m'
1094+
python3_version = self.ctx.python_recipe.version
1095+
python3_version = '.'.join(python3_version.split('.')[:2])
1096+
env['LDFLAGS'] = env['LDFLAGS'] + ' -lpython{}m'.format(python3_version)
10981097

10991098
return env
11001099

0 commit comments

Comments
 (0)