From d60e61993ef820b20fea62eee34d9f8f7a0b91f9 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 21 Nov 2009 15:45:21 +0000 Subject: [PATCH] This should fix the eggcacher/packpanda problems on Windows, I think. --- direct/src/directbase/ppython.cxx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/direct/src/directbase/ppython.cxx b/direct/src/directbase/ppython.cxx index 01a01cde05..28f0dcfd2c 100755 --- a/direct/src/directbase/ppython.cxx +++ b/direct/src/directbase/ppython.cxx @@ -21,6 +21,27 @@ int main(int argc, char **argv) { int sts = 0; Py_SetProgramName(argv[0]); + + // On windows, we need to set pythonhome correctly. We'll try to + // find ppython.exe on the path and set pythonhome to its location. +#ifdef _WIN32 + char *path = getenv("PATH"); + char *result = strtok(path, ";"); + while (result != NULL) { + struct stat st; + char *ppython = (char*) malloc(strlen(result) + 13); + strcpy(ppython, result); + strcat(ppython, "\\ppython.exe"); + if (stat(ppython, &st) == 0) { + Py_SetPythonHome(result); + free(ppython); + break; + } + result = strtok(NULL, ";"); + free(ppython); + } +#endif + Py_Initialize(); if (Py_VerboseFlag) { @@ -38,4 +59,3 @@ int main(int argc, char **argv) { Py_Finalize(); return sts; } -