Files
MINGW-packages/mingw-w64-python3/0565-mingw-add-ModuleFileName-dir-to-PATH.patch
2014-03-17 10:49:46 +04:00

35 lines
1.3 KiB
Diff

diff -Naur a/Modules/getpath.c b/Modules/getpath.c
--- a/Modules/getpath.c 2014-03-17 10:46:20.154400000 +0400
+++ b/Modules/getpath.c 2014-03-17 10:46:20.357200000 +0400
@@ -879,6 +879,30 @@
else
wcsncpy(exec_prefix, _exec_prefix, MAXPATHLEN);
+#ifdef MS_WINDOWS
+ if (_path) {
+ /* Add path of executable/dll to system path. This
+ * is so that the correct tcl??.dll and tk??.dll get used. */
+ path_buffer = _Py_char2wchar(_path, NULL);
+ wchar_t *module_path = dllpath[0] ? dllpath : progpath;
+ wchar_t *new_path = (wchar_t *)alloca(sizeof(wchar_t)*(wcslen(L"PATH=")+wcslen(module_path)+1+wcslen(path_buffer)+1));
+ if (new_path) {
+ wcscpy( new_path, L"PATH=" );
+ wcscat( new_path, module_path );
+ wchar_t *slashes = wcschr( new_path, L'/' );
+ while (slashes) {
+ *slashes = '\\';
+ slashes = wcschr( slashes+1, L'/' );
+ }
+ wchar_t *end = wcsrchr(new_path, L'\\') ? wcsrchr(new_path, L'\\') : new_path + wcslen(new_path);
+ end[0] = L';';
+ end[1] = L'\0';
+ wcscat( new_path, path_buffer );
+ _wputenv( new_path );
+ PyMem_Free(path_buffer);
+ }
+ }
+#endif
PyMem_Free(_pythonpath);
PyMem_Free(_prefix);
PyMem_Free(_exec_prefix);