|
41 | 41 | #include "capi.h"
|
42 | 42 | #include <stdio.h>
|
43 | 43 | #include <time.h>
|
44 |
| -#ifdef MS_WINDOWS |
45 |
| -#include "libloaderapi.h" |
46 |
| -#include "pathcch.h" |
47 |
| -#pragma comment(lib, "Pathcch.lib") |
48 |
| -#endif |
49 | 44 |
|
50 | 45 | #define ASSERTIONS
|
51 | 46 |
|
@@ -1453,63 +1448,6 @@ PyAPI_FUNC(void) initialize_graal_capi(ptr_cache_t _pythonToNative, void_ptr_cac
|
1453 | 1448 | initialize_hashes();
|
1454 | 1449 | initialize_bufferprocs();
|
1455 | 1450 |
|
1456 |
| -#ifdef MS_WINDOWS |
1457 |
| - // when initializing the C API, the appropriate libraries (like |
1458 |
| - // python-native.dll or graalvm-llvm.dll) are loaded with their full paths. |
1459 |
| - // However, they are not automatically on the search path when any |
1460 |
| - // extension modules are loaded later, and Windows wants to resolve them |
1461 |
| - // again. So we get their runtime paths here and add those to the dll |
1462 |
| - // search path. |
1463 |
| - LPSTR lpMsgBuf; |
1464 |
| - wchar_t path[MAX_PATH]; |
1465 |
| - char pathA[MAX_PATH]; |
1466 |
| - HMODULE hm = NULL; |
1467 |
| - if (GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | |
1468 |
| - GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, |
1469 |
| - (LPCWSTR) &initialize_graal_capi, &hm) == 0) { |
1470 |
| - int ret = GetLastError(); |
1471 |
| - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
1472 |
| - NULL, ret, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &lpMsgBuf, 0, NULL); |
1473 |
| - PyTruffle_Log(PY_TRUFFLE_LOG_FINE, "finding python-native.dll handle failed, error = %s\n", lpMsgBuf); |
1474 |
| - LocalFree(lpMsgBuf); |
1475 |
| - } else { |
1476 |
| - if (GetModuleFileNameW(hm, (LPWSTR)path, sizeof(path)) == 0) { |
1477 |
| - int ret = GetLastError(); |
1478 |
| - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
1479 |
| - NULL, ret, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &lpMsgBuf, 0, NULL); |
1480 |
| - PyTruffle_Log(PY_TRUFFLE_LOG_FINE, "finding python-native.dll path failed, error = %s\n", lpMsgBuf); |
1481 |
| - LocalFree(lpMsgBuf); |
1482 |
| - } else { |
1483 |
| - wcstombs(pathA, path, sizeof(pathA)); |
1484 |
| - PyTruffle_Log(PY_TRUFFLE_LOG_FINE, "Adding python-native.dll path '%s' to search path.\n", pathA); |
1485 |
| - PathCchRemoveFileSpec((PWSTR)path, sizeof(path)); |
1486 |
| - AddDllDirectory((LPWSTR)path); |
1487 |
| - } |
1488 |
| - } |
1489 |
| - if (GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | |
1490 |
| - GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, |
1491 |
| - (LPCWSTR) &polyglot_from_string, &hm) == 0) { |
1492 |
| - int ret = GetLastError(); |
1493 |
| - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
1494 |
| - NULL, ret, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &lpMsgBuf, 0, NULL); |
1495 |
| - PyTruffle_Log(PY_TRUFFLE_LOG_FINE, "finding graalvm-llvm.dll handle failed, error = %s\n", lpMsgBuf); |
1496 |
| - LocalFree(lpMsgBuf); |
1497 |
| - } else { |
1498 |
| - if (GetModuleFileNameW(hm, (LPWSTR)path, sizeof(path)) == 0) { |
1499 |
| - int ret = GetLastError(); |
1500 |
| - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
1501 |
| - NULL, ret, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &lpMsgBuf, 0, NULL); |
1502 |
| - PyTruffle_Log(PY_TRUFFLE_LOG_FINE, "finding graalvm-llvm.dll path failed, error = %s\n", lpMsgBuf); |
1503 |
| - LocalFree(lpMsgBuf); |
1504 |
| - } else { |
1505 |
| - wcstombs(pathA, path, sizeof(pathA)); |
1506 |
| - PyTruffle_Log(PY_TRUFFLE_LOG_FINE, "Adding graalvm-llvm.dll path '%s' to search path.\n", pathA); |
1507 |
| - PathCchRemoveFileSpec((LPWSTR)path, sizeof(path)); |
1508 |
| - AddDllDirectory((LPWSTR)path); |
1509 |
| - } |
1510 |
| - } |
1511 |
| -#endif |
1512 |
| - |
1513 | 1451 | // TODO: initialize during cext initialization doesn't work at the moment
|
1514 | 1452 | // This is hardcoded the same way in capi_native.c
|
1515 | 1453 | Py_FileSystemDefaultEncoding = "utf-8"; // strdup(PyUnicode_AsUTF8(GraalPyTruffle_FileSystemDefaultEncoding()));
|
|
0 commit comments