lbry-fdroid/recipes/python2/patches/custom-loader.patch
Akinwale Ariwodola 744cfaebc2 Initial commit
2017-08-13 02:24:00 +01:00

67 lines
No EOL
1.9 KiB
Diff

--- Python-2.7.9.orig/Python/dynload_shlib.c 2010-05-09 16:46:46.000000000 +0200
+++ Python-2.7.9/Python/dynload_shlib.c 2011-04-20 17:52:12.000000000 +0200
@@ -6,6 +6,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <stdlib.h>
#if defined(__NetBSD__)
#include <sys/param.h>
@@ -75,6 +76,21 @@
char pathbuf[260];
int dlopenflags=0;
+ static void *libpymodules = NULL;
+ void *rv = NULL;
+
+ /* Ensure we have access to libpymodules. */
+ if (libpymodules == NULL) {
+ printf("ANDROID_APP_PATH = %s\n", getenv("ANDROID_APP_PATH"));
+ PyOS_snprintf(pathbuf, sizeof(pathbuf), "%s/libpymodules.so", getenv("ANDROID_APP_PATH"));
+ libpymodules = dlopen(pathbuf, RTLD_NOW);
+
+ if (libpymodules == NULL) {
+ //abort();
+ }
+ }
+
+
if (strchr(pathname, '/') == NULL) {
/* Prefix bare filename with "./" */
PyOS_snprintf(pathbuf, sizeof(pathbuf), "./%-.255s", pathname);
@@ -84,6 +100,17 @@
PyOS_snprintf(funcname, sizeof(funcname),
LEAD_UNDERSCORE "init%.200s", shortname);
+
+ /* Read symbols that have been linked into the main binary. */
+
+ if (libpymodules) {
+ rv = dlsym(libpymodules, funcname);
+ if (rv != NULL) {
+ return rv;
+ }
+ }
+
+
if (fp != NULL) {
int i;
struct stat statb;
--- Python-2.7.2.orig/Python/pythonrun.c 2010-10-29 05:45:34.000000000 +0200
+++ Python-2.7.2/Python/pythonrun.c 2011-04-20 17:52:12.000000000 +0200
@@ -254,9 +254,13 @@
_PyGILState_Init(interp, tstate);
#endif /* WITH_THREAD */
+ /* For PGS4A, we don't want to call initsite, as we won't have the
+ library path set up until start.pyx finishes running. */
+#if 0
if (!Py_NoSiteFlag)
initsite(); /* Module site */
-
+#endif
+
if ((p = Py_GETENV("PYTHONIOENCODING")) && *p != '\0') {
p = icodeset = codeset = strdup(p);
free_codeset = 1;