Index: Include/pythonrun.h =================================================================== --- Include/pythonrun.h (revision 84913) +++ Include/pythonrun.h (working copy) @@ -113,6 +113,7 @@ PyAPI_FUNC(wchar_t *) Py_GetPrefix(void); PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void); PyAPI_FUNC(wchar_t *) Py_GetPath(void); +PyAPI_FUNC(void) Py_SetPath(const wchar_t *); /* In their own files */ PyAPI_FUNC(const char *) Py_GetVersion(void); Index: PC/getpathp.c =================================================================== --- PC/getpathp.c (revision 84913) +++ PC/getpathp.c (working copy) @@ -79,6 +79,9 @@ * The approach is an adaptation for Windows of the strategy used in * ../Modules/getpath.c; it uses the Windows Registry as one of its * information sources. + * + * Py_SetPath() can be used to override this mechanism. Call Py_SetPath + * with a semicolon separated path prior to calling Py_Initialize. */ #ifndef LANDMARK @@ -654,6 +657,22 @@ /* External interface */ +void +Py_SetPath(const wchar_t *path) +{ + if (module_search_path != NULL) { + free(module_search_path); + module_search_path = NULL; + } + if (path != NULL) { + get_progpath(); + prefix[0] = L'\0'; + module_search_path = malloc((wcslen(path) + 1) * sizeof(wchar_t)); + if (module_search_path != NULL) + wcscpy(module_search_path, path); + } +} + wchar_t * Py_GetPath(void) {