This is also a problem with meson which tries to execute things in the build directory using the build directory DLLs by prepending those to PATH. Since meson uses a Python helper the PATH gets updated to include the system prefix first which makes things link against the installed libraries instead and fail because symbols are missing. One of the reasons why this was added in the first place is that Python loads C extensions in lib-dynload which then can't find the libraries in prefix (e.g. "import tkinter") if it isn't in PATH. By moving the prefix at the end of PATH we make both cases work. Starting with Python 3.8 C extensions will no longer use PATH for loading DLL dependencies, see https://github.com/python/cpython/pull/12302 so we will have to look into this again then.
40 lines
1.6 KiB
Diff
40 lines
1.6 KiB
Diff
--- Python-3.7.3/Modules/getpath.c.orig 2019-03-25 21:21:05.000000000 +0100
|
|
+++ Python-3.7.3/Modules/getpath.c 2019-04-16 21:51:06.279967700 +0200
|
|
@@ -959,6 +1091,36 @@
|
|
memset(exec_prefix, 0, sizeof(exec_prefix));
|
|
calculate_exec_prefix(core_config, calculate, exec_prefix);
|
|
|
|
+#ifdef MS_WINDOWS
|
|
+ if (calculate->path_env) {
|
|
+ wchar_t *module_path, *norm_path;
|
|
+ // Add path of executable/dll to system path. This
|
|
+ // is so that the correct tcl??.dll and tk??.dll get used.
|
|
+ module_path = config->dll_path[0] ? config->dll_path : config->program_full_path;
|
|
+ norm_path = (wchar_t *)alloca(sizeof(wchar_t) * (wcslen(module_path) + 1));
|
|
+ if (norm_path) {
|
|
+ wchar_t *slashes, *end, *new_path;
|
|
+ wcscpy(norm_path, module_path);
|
|
+ slashes = wcschr(norm_path, L'/');
|
|
+ while (slashes) {
|
|
+ *slashes = L'\\';
|
|
+ slashes = wcschr(slashes + 1, L'/');
|
|
+ }
|
|
+ end = wcsrchr(norm_path, L'\\') ? wcsrchr(norm_path, L'\\') : norm_path + wcslen(norm_path);
|
|
+ end[1] = L'\0';
|
|
+
|
|
+ new_path = (wchar_t *)alloca(sizeof(wchar_t) * (wcslen(L"PATH=") + wcslen(calculate->path_env) + 1 + wcslen(norm_path) + 1));
|
|
+ if (new_path) {
|
|
+ wcscpy(new_path, L"PATH=");
|
|
+ wcscat(new_path, calculate->path_env);
|
|
+ wcscat(new_path, L";");
|
|
+ wcscat(new_path, norm_path);
|
|
+ _wputenv(new_path);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+#endif
|
|
+
|
|
if ((!calculate->prefix_found || !calculate->exec_prefix_found) &&
|
|
!Py_FrozenFlag)
|
|
{
|