Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8abe7bf

Browse files
author
Thomas Heller
committed
Set PYTHONHOME before loading Python, so that sys.path will be set correctly.
Already backported.
1 parent e4772f3 commit 8abe7bf

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

PC/bdist_wininst/install.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,13 @@ static HINSTANCE LoadPythonDll(char *fname)
613613
char fullpath[_MAX_PATH];
614614
LONG size = sizeof(fullpath);
615615
char subkey_name[80];
616-
HINSTANCE h = LoadLibrary(fname);
616+
char buffer[260 + 12];
617+
HINSTANCE h;
618+
619+
/* make sure PYTHONHOME is set, to that sys.path is initialized correctly */
620+
wsprintf(buffer, "PYTHONHOME=%s", python_dir);
621+
_putenv(buffer);
622+
h = LoadLibrary(fname);
617623
if (h)
618624
return h;
619625
wsprintf(subkey_name,

0 commit comments

Comments
 (0)