Skip to content

Commit 110cf69

Browse files
committed
Python3 additions (but still don't work)
1 parent 82ac137 commit 110cf69

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

pythonforandroid/recipes/python3/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,27 @@ def prebuild_armeabi(self):
1919
print('Python3 already patched, skipping.')
2020
return
2121

22+
# # self.apply_patch(join('patches_inclement',
23+
# # 'python-{version}-define_macro.patch'.format(version=self.version)))
24+
# # self.apply_patch(join('patches_inclement',
25+
# # 'python-{version}-android-locale.patch'.format(version=self.version)))
26+
# # self.apply_patch(join('patches_inclement',
27+
# # 'python-{version}-android-misc.patch'.format(version=self.version)))
28+
29+
# self.apply_patch(join('patches_inclement',
30+
# 'python-{version}-locale_and_android_misc.patch'.format(version=self.version)))
31+
32+
2233
self.apply_patch(join('patches', 'python-{version}-android-libmpdec.patch'.format(version=self.version)))
2334
self.apply_patch(join('patches', 'python-{version}-android-locale.patch'.format(version=self.version)))
2435
self.apply_patch(join('patches', 'python-{version}-android-misc.patch'.format(version=self.version)))
2536
# self.apply_patch(join('patches', 'python-{version}-android-missing-getdents64-definition.patch'.format(version=self.version)))
2637
self.apply_patch(join('patches', 'python-{version}-cross-compile.patch'.format(version=self.version)))
2738
self.apply_patch(join('patches', 'python-{version}-python-misc.patch'.format(version=self.version)))
2839

40+
self.apply_patch(join('patches', 'python-{version}-libpymodules_loader.patch'.format(version=self.version)))
41+
42+
2943
shprint(sh.touch, join(build_dir, '.patched'))
3044

3145
def build_armeabi(self):

pythonforandroid/recipes/python3/patches/python-3.4.2-android-misc.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ diff -ru Python-3.3.5/Lib/platform.py Python-3.3.5-android/Lib/platform.py
66
full_distribution_name=0)
77

88
+_android_environment_vars = (
9-
+ 'ANDROID_ROOT', 'ANDROID_ASSETS', 'ANDROID_STORAGE', 'ANDROID_DATA',
9+
+ 'ANDROID_PRIVATE', 'ANDROID_ARGUMENT', 'ANDROID_APP_PATH', 'ANDROID_DATA',
1010
+ 'ANDROID_PROPERTY_WORKSPACE', 'ANDROID_BOOTLOGO')
1111
+_android_version_property = 'ro.build.version.release'
1212
+_android_buildstr_property = 'ro.build.version.full'
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c
2+
index 7f8f134..bba560f 100644
3+
--- a/Python/dynload_shlib.c
4+
+++ b/Python/dynload_shlib.c
5+
@@ -62,6 +62,20 @@ _PyImport_FindSharedFuncptr(const char *prefix,
6+
char pathbuf[260];
7+
int dlopenflags=0;
8+
9+
+ static void *libpymodules = NULL;
10+
+ void *rv = NULL;
11+
+
12+
+ /* Ensure we have access to libpymodules. */
13+
+ if (libpymodules == NULL) {
14+
+ printf("ANDROID_PRIVATE = %s\n", getenv("ANDROID_PRIVATE"));
15+
+ PyOS_snprintf(pathbuf, sizeof(pathbuf), "%s/libpymodules.so", getenv("ANDROID_PRIVATE"));
16+
+ libpymodules = dlopen(pathbuf, RTLD_NOW);
17+
+
18+
+ if (libpymodules == NULL) {
19+
+ //abort();
20+
+ }
21+
+ }
22+
+
23+
if (strchr(pathname, '/') == NULL) {
24+
/* Prefix bare filename with "./" */
25+
PyOS_snprintf(pathbuf, sizeof(pathbuf), "./%-.255s", pathname);
26+
@@ -71,6 +85,16 @@ _PyImport_FindSharedFuncptr(const char *prefix,
27+
PyOS_snprintf(funcname, sizeof(funcname),
28+
LEAD_UNDERSCORE "%.20s_%.200s", prefix, shortname);
29+
30+
+
31+
+ /* Read symbols that have been linked into the main binary. */
32+
+
33+
+ if (libpymodules) {
34+
+ rv = dlsym(libpymodules, funcname);
35+
+ if (rv != NULL) {
36+
+ return rv;
37+
+ }
38+
+ }
39+
+
40+
if (fp != NULL) {
41+
int i;
42+
struct _Py_stat_struct status;

0 commit comments

Comments
 (0)