From 488fe5198b8cb2e28cc99b382a3e80dddbe1e41e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 3 Dec 2019 10:22:41 +0530 Subject: [PATCH] Add proper paths in windows frozen build --- bypy/run-python.h | 2 ++ bypy/windows/site.py | 4 ++++ bypy/windows/util.c | 8 +++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bypy/run-python.h b/bypy/run-python.h index 304dc07cfb..67d511c200 100644 --- a/bypy/run-python.h +++ b/bypy/run-python.h @@ -190,8 +190,10 @@ run_interpreter() { status = PyConfig_SetString(&config, &config.program_name, interpreter_data.exe_path); CHECK_STATUS; +#ifndef _WIN32 status = PyConfig_SetString(&config, &config.home, interpreter_data.python_home_path); CHECK_STATUS; +#endif status = PyConfig_SetString(&config, &config.run_module, L"site"); CHECK_STATUS; #ifdef _WIN32 diff --git a/bypy/windows/site.py b/bypy/windows/site.py index 26acf3a8ae..244ddfb39b 100644 --- a/bypy/windows/site.py +++ b/bypy/windows/site.py @@ -82,3 +82,7 @@ def main(): set_quit() return run_entry_point() + + +if __name__ == '__main__': + main() diff --git a/bypy/windows/util.c b/bypy/windows/util.c index 7b552391d3..65d258d34d 100644 --- a/bypy/windows/util.c +++ b/bypy/windows/util.c @@ -72,7 +72,6 @@ int show_last_error(wchar_t *preamble) { } static wchar_t qt_prefix_dir[MAX_PATH] = {0}; -static wchar_t w_program_name[MAX_PATH] = {0}; static void get_app_dirw(void) { @@ -80,11 +79,14 @@ get_app_dirw(void) { wchar_t drive[4] = L"\0\0\0"; DWORD sz; errno_t err; - sz = GetModuleFileNameW(NULL, w_program_name, MAX_PATH); + sz = GetModuleFileNameW(NULL, interpreter_data.exe_path, MAX_PATH); if (sz >= MAX_PATH-1) ExitProcess(_show_error(L"Installation directory path too long", L"", 1)); - err = _wsplitpath_s(w_program_name, drive, 4, buf, MAX_PATH, NULL, 0, NULL, 0); + err = _wsplitpath_s(interpreter_data.exe_path, drive, 4, buf, MAX_PATH, NULL, 0, NULL, 0); if (err != 0) ExitProcess(show_last_error_crt(L"Failed to find application directory")); _snwprintf_s(interpreter_data.app_dir, MAX_PATH, _TRUNCATE, L"%ls%ls", drive, buf); + _snwprintf_s(interpreter_data.resources_path, MAX_PATH, _TRUNCATE, L"%ls%lsapp\\resources", drive, buf); + _snwprintf_s(interpreter_data.extensions_path, MAX_PATH, _TRUNCATE, L"%ls%lsapp\\bin", drive, buf); + _snwprintf_s(interpreter_data.executables_path, MAX_PATH, _TRUNCATE, L"%ls%lsapp\\bin", drive, buf); } static void