Message385662
Confirmed. The following code works as I want:
Py_Main_t get_pymain(wchar_t *base_dir) {
wchar_t *dll_path;
HRESULT hr = PathAllocCombine(
base_dir, L"python\\python3.dll",
PATHCCH_ALLOW_LONG_PATHS, &dll_path
);
if (hr != S_OK) {
error(L"Could not construct Python DLL path");
}
HMODULE py_dll = LoadLibraryExW(dll_path, 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
if (!py_dll) {
error(L"Could not load Python DLL %ls", dll_path);
}
LocalFree(dll_path);
Py_Main_t py_main = (Py_Main_t)GetProcAddress(py_dll, "Py_Main");
if (!py_main) {
error(L"Could not locate Py_Main function");
}
return py_main;
}
If people think it's worthwhile, I can put together a change to https://docs.python.org/3/extending/embedding.html#embedding-python-in-another-application (maybe a new section, "Embedding on Windows by dynamically loading the stable ABI"?) that uses a code snippet like this. |
|
Date |
User |
Action |
Args |
2021-01-25 21:02:20 | paul.moore | set | recipients:
+ paul.moore, tim.golden, jkloth, zach.ware, eryksun, steve.dower |
2021-01-25 21:02:20 | paul.moore | set | messageid: <1611608540.9.0.500872109484.issue43022@roundup.psfhosted.org> |
2021-01-25 21:02:20 | paul.moore | link | issue43022 messages |
2021-01-25 21:02:20 | paul.moore | create | |
|