Skip to content

Commit ca2fd1a

Browse files
committed
_bootstrap_python: Fix execution on windows disabling site import
This works around the lack of `sys.winver` attribute addressing the following error: ``` Generating C:/path/to/Python-3.12.10/Python/deepfreeze/deepfreeze.c CUSTOMBUILD : Fatal Python error : init_import_site: Failed to import the site module [C:\path o\pycbs-3.12-build\CMakeBuild\libpython\libpython-shared.vcxproj] Python runtime state: initialized Traceback (most recent call last): File "C:\path o\pycbs-3.12-build\Lib\site.py", line 636, in <module> main() File "C:\path o\pycbs-3.12-build\Lib\site.py", line 622, in main known_paths = addusersitepackages(known_paths) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\path o\pycbs-3.12-build\Lib\site.py", line 361, in addusersitepackages user_site = getusersitepackages() ^^^^^^^^^^^^^^^^^^^^^ File "C:\path o\pycbs-3.12-build\Lib\site.py", line 348, in getusersitepackages USER_SITE = _get_path(userbase) ^^^^^^^^^^^^^^^^^^^ File "C:\path o\pycbs-3.12-build\Lib\site.py", line 313, in _get_path ver_nodot = sys.winver.replace('.', '') ^^^^^^^^^^ AttributeError: module 'sys' has no attribute 'winver' ```
1 parent 0fb18b0 commit ca2fd1a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Programs/_bootstrap_python.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ main(int argc, char **argv)
7676
// add current script dir to sys.path
7777
config.isolated = 0;
7878
config.safe_path = 0;
79+
#ifdef MS_WINDOWS
80+
config.site_import = 0;
81+
#endif
7982

8083
#ifdef MS_WINDOWS
8184
status = PyConfig_SetArgv(&config, argc, argv);

0 commit comments

Comments
 (0)