From fc71fef27d54bc4e30a5c14e8085adf35420c944 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 30 Mar 2020 15:54:50 +0200 Subject: [PATCH] deploy-stub: chdir to Resources dir in GUI macOS app bundle This prevents a common error of trying to load non-Panda3D assets without specifying $MAIN_DIR. We aren't currently making any guarantees about the cwd (which may in fact be / when launching from Finder), so I think this is safe. --- pandatool/src/deploy-stub/deploy-stub.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandatool/src/deploy-stub/deploy-stub.c b/pandatool/src/deploy-stub/deploy-stub.c index e30482654e..7255b911b8 100644 --- a/pandatool/src/deploy-stub/deploy-stub.c +++ b/pandatool/src/deploy-stub/deploy-stub.c @@ -522,6 +522,10 @@ int Py_FrozenMain(int argc, char **argv) // for ConfigPageManager to read out and assign to MAIN_DIR. sprintf(buffer, "%s/../Resources", dir); set_main_dir(buffer); + + // Finally, chdir to it, so that regular Python files are read from the + // right location. + chdir(buffer); #endif n = PyImport_ImportFrozenModule("__main__");