Skip to content
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
2 changes: 1 addition & 1 deletion pythonforandroid/bootstraps/sdl2/build/jni/src/start.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) {
if (dir_exists("lib")) {
/* If we built our own python, set up the paths correctly */
LOGP("Setting up python from ANDROID_PRIVATE");
PyRun_SimpleString("private = posix.environ['ANDROID_PRIVATE']\n"
PyRun_SimpleString("private = posix.environ['ANDROID_PRIVATE'] + '/app'\n"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should actually use ANDROID_APP_PATH rather than guessing /app, right? If that's right, just let me know and I'll make the change manually and merge.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"argument = posix.environ['ANDROID_ARGUMENT']\n"
"sys.path[:] = [ \n"
" private + '/lib/python27.zip', \n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,37 @@ public class PythonActivity extends SDLActivity {
private Bundle mMetaData = null;
private PowerManager.WakeLock mWakeLock = null;

public String getKivyRoot() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to use getAppRoot or something instead of Kivy, but it doesn't really matter.

String kivy_root = getFilesDir().getAbsolutePath() + "/app";
return kivy_root;
}


@Override
protected void onCreate(Bundle savedInstanceState) {
Log.v(TAG, "My oncreate running");
resourceManager = new ResourceManager(this);
this.showLoadingScreen();
File kivy_root_file = new File(getKivyRoot());

Log.v(TAG, "Ready to unpack");
unpackData("private", getFilesDir());
unpackData("private", kivy_root_file);

Log.v(TAG, "About to do super onCreate");
super.onCreate(savedInstanceState);
Log.v(TAG, "Did super onCreate");

this.mActivity = this;

String kivy_root_dir = getKivyRoot();
String mFilesDirectory = mActivity.getFilesDir().getAbsolutePath();
Log.v(TAG, "Setting env vars for start.c and Python to use");
SDLActivity.nativeSetEnv("ANDROID_PRIVATE", mFilesDirectory);
SDLActivity.nativeSetEnv("ANDROID_ARGUMENT", mFilesDirectory);
SDLActivity.nativeSetEnv("ANDROID_APP_PATH", mFilesDirectory);
SDLActivity.nativeSetEnv("ANDROID_ARGUMENT", kivy_root_dir);
SDLActivity.nativeSetEnv("ANDROID_APP_PATH", kivy_root_dir);
SDLActivity.nativeSetEnv("ANDROID_ENTRYPOINT", "main.pyo");
SDLActivity.nativeSetEnv("PYTHONHOME", mFilesDirectory);
SDLActivity.nativeSetEnv("PYTHONPATH", mFilesDirectory + ":" + mFilesDirectory + "/lib");
SDLActivity.nativeSetEnv("PYTHONHOME", kivy_root_dir);
SDLActivity.nativeSetEnv("PYTHONPATH", kivy_root_dir + ":" + kivy_root_dir + "/lib");

try {
Log.v(TAG, "Access to our meta-data...");
Expand All @@ -93,7 +101,9 @@ protected void onCreate(Bundle savedInstanceState) {
}

public void loadLibraries() {
PythonUtil.loadLibraries(getFilesDir());
String kivy_root = new String(getKivyRoot());
File kivy_root_file = new File(kivy_root);
PythonUtil.loadLibraries(kivy_root_file);
}

public void recursiveDelete(File f) {
Expand Down Expand Up @@ -267,11 +277,12 @@ public static void start_service(String serviceTitle, String serviceDescription,
Intent serviceIntent = new Intent(PythonActivity.mActivity, PythonService.class);
String argument = PythonActivity.mActivity.getFilesDir().getAbsolutePath();
String filesDirectory = argument;
String kivy_root_dir = PythonActivity.mActivity.getKivyRoot();
serviceIntent.putExtra("androidPrivate", argument);
serviceIntent.putExtra("androidArgument", argument);
serviceIntent.putExtra("androidArgument", kivy_root_dir);
serviceIntent.putExtra("serviceEntrypoint", "service/main.pyo");
serviceIntent.putExtra("pythonHome", argument);
serviceIntent.putExtra("pythonPath", argument + ":" + filesDirectory + "/lib");
serviceIntent.putExtra("pythonHome", kivy_root_dir);
serviceIntent.putExtra("pythonPath", kivy_root_dir + ":" + kivy_root_dir + "/lib");
serviceIntent.putExtra("serviceTitle", serviceTitle);
serviceIntent.putExtra("serviceDescription", serviceDescription);
serviceIntent.putExtra("pythonServiceArgument", pythonServiceArgument);
Expand Down