Skip to content

Commit 8e2cd27

Browse files
committed
Merge branch 'fix_python2sdl2' of https://github.com/KeyWeeUsr/python-for-android into KeyWeeUsr-fix_unpack_dir
2 parents 3e5e576 + a7a878b commit 8e2cd27

File tree

6 files changed

+10
-4
lines changed

6 files changed

+10
-4
lines changed

pythonforandroid/bootstraps/pygame/build/src/org/renpy/android/SDLSurfaceView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ public void run() {
706706
nativeResize(mWidth, mHeight);
707707
nativeInitJavaCallbacks();
708708
nativeSetEnv("ANDROID_PRIVATE", mFilesDirectory);
709+
nativeSetEnv("ANDROID_UNPACK", mFilesDirectory);
709710
nativeSetEnv("ANDROID_ARGUMENT", mArgument);
710711
nativeSetEnv("ANDROID_APP_PATH", mArgument);
711712
nativeSetEnv("PYTHONOPTIMIZE", "2");

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ protected void onPostExecute(String result) {
172172
String mFilesDirectory = mActivity.getFilesDir().getAbsolutePath();
173173
Log.v(TAG, "Setting env vars for start.c and Python to use");
174174
SDLActivity.nativeSetEnv("ANDROID_PRIVATE", mFilesDirectory);
175+
SDLActivity.nativeSetEnv("ANDROID_UNPACK", mFilesDirectory + "/app");
175176
SDLActivity.nativeSetEnv("PYTHONHOME", app_root_dir);
176177
SDLActivity.nativeSetEnv("PYTHONPATH", app_root_dir + ":" + app_root_dir + "/lib");
177178
SDLActivity.nativeSetEnv("PYTHONOPTIMIZE", "2");

pythonforandroid/bootstraps/service_only/build/src/org/kivy/android/PythonService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public abstract class PythonService extends Service implements Runnable {
2626
private String pythonName;
2727
private String pythonHome;
2828
private String pythonPath;
29+
private String androidUnpack;
2930
private String serviceEntrypoint;
3031
private String pythonServiceArgument;
3132

@@ -70,6 +71,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
7071
pythonName = extras.getString("pythonName");
7172
pythonHome = extras.getString("pythonHome");
7273
pythonPath = extras.getString("pythonPath");
74+
androidUnpack = extras.getString("androidUnpack");
7375
pythonServiceArgument = extras.getString("pythonServiceArgument");
7476

7577
Log.v(TAG, "Starting Python thread");
@@ -127,7 +129,7 @@ public void onDestroy() {
127129
public void run() {
128130
PythonUtil.loadLibraries(getFilesDir());
129131
nativeStart(androidPrivate, androidArgument, serviceEntrypoint, pythonName, pythonHome,
130-
pythonPath, pythonServiceArgument);
132+
pythonPath, pythonServiceArgument, androidUnpack);
131133
stopSelf();
132134
}
133135

@@ -143,5 +145,5 @@ public void run() {
143145
public static native void nativeStart(String androidPrivate, String androidArgument,
144146
String serviceEntrypoint, String pythonName,
145147
String pythonHome, String pythonPath,
146-
String pythonServiceArgument);
148+
String pythonServiceArgument, String androidUnpack);
147149
}

pythonforandroid/bootstraps/service_only/build/templates/Service.tmpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public static void start(Context ctx, String pythonServiceArgument) {
4040
intent.putExtra("serviceDescription", "");
4141
intent.putExtra("pythonName", "{{ name }}");
4242
intent.putExtra("pythonHome", argument);
43+
intent.putExtra("androidUnpack", argument);
4344
intent.putExtra("pythonPath", argument + ":" + argument + "/lib");
4445
intent.putExtra("pythonServiceArgument", pythonServiceArgument);
4546
ctx.startService(intent);

pythonforandroid/bootstraps/webview/build/src/org/kivy/android/PythonActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
158158
PythonActivity.nativeSetEnv("ANDROID_PRIVATE", mFilesDirectory);
159159
PythonActivity.nativeSetEnv("ANDROID_ARGUMENT", mFilesDirectory);
160160
PythonActivity.nativeSetEnv("ANDROID_APP_PATH", mFilesDirectory);
161+
PythonActivity.nativeSetEnv("ANDROID_UNPACK", mFilesDirectory);
161162
PythonActivity.nativeSetEnv("ANDROID_ENTRYPOINT", "main.pyo");
162163
PythonActivity.nativeSetEnv("PYTHONHOME", mFilesDirectory);
163164
PythonActivity.nativeSetEnv("PYTHONPATH", mFilesDirectory + ":" + mFilesDirectory + "/lib");

pythonforandroid/recipes/python2/patches/custom-loader.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
+
1818
+ /* Ensure we have access to libpymodules. */
1919
+ if (libpymodules == -1) {
20-
+ printf("ANDROID_APP_PATH = %s\n", getenv("ANDROID_APP_PATH"));
21-
+ PyOS_snprintf(pathbuf, sizeof(pathbuf), "%s/libpymodules.so", getenv("ANDROID_APP_PATH"));
20+
+ printf("ANDROID_UNPACK = %s\n", getenv("ANDROID_UNPACK"));
21+
+ PyOS_snprintf(pathbuf, sizeof(pathbuf), "%s/libpymodules.so", getenv("ANDROID_UNPACK"));
2222
+ libpymodules = dlopen(pathbuf, RTLD_NOW);
2323
+
2424
+ if (libpymodules == NULL) {

0 commit comments

Comments
 (0)