Files
MINGW-packages/mingw-w64-python3/0565-mingw-add-ModuleFileName-dir-to-PATH.patch
2016-07-12 14:49:26 +03:00

37 lines
1.4 KiB
Diff

diff -Naur Python-3.5.2-orig/Modules/getpath.c Python-3.5.2/Modules/getpath.c
--- Python-3.5.2-orig/Modules/getpath.c 2016-07-12 14:22:01.929300700 +0300
+++ Python-3.5.2/Modules/getpath.c 2016-07-12 14:22:02.242800700 +0300
@@ -848,6 +848,32 @@
else
wcsncpy(exec_prefix, _exec_prefix, MAXPATHLEN);
+#ifdef MS_WINDOWS
+ if (_path) {
+ wchar_t *module_path, *new_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_DecodeLocale(_path, NULL);
+ module_path = dllpath[0] ? dllpath : progpath;
+ new_path = (wchar_t *)alloca(sizeof(wchar_t)*(wcslen(L"PATH=")+wcslen(module_path)+1+wcslen(path_buffer)+1));
+ if (new_path) {
+ wchar_t *slashes, *end;
+ wcscpy(new_path, L"PATH=");
+ wcscat(new_path, module_path);
+ slashes = wcschr(new_path, L'/');
+ while (slashes) {
+ *slashes = L'\\';
+ slashes = wcschr( slashes+1, L'/' );
+ }
+ 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_RawFree(path_buffer);
+ }
+ }
+#endif
PyMem_RawFree(_pythonpath);
PyMem_RawFree(_prefix);
PyMem_RawFree(_exec_prefix);