gh-91985: Fix sys.path calculation with PYTHONHOME on Windows by neonene · Pull Request #92288 · python/cpython

This workaround inserts a dll build directory into sys.path to avoid import errors.
Here is an output of C code in the description of #91985:

  • set PYTHONHOME=C:\cpython-main
0
C:\cpython-main\PCbuild\amd64\python311.zip
c:\cpython-main\Lib
C:\cpython-main\PCbuild\amd64
c:\cpython-main
c:\cpython-main\Lib\site-packages

1
C:\cpython-main\PCbuild\amd64\python311.zip
c:\cpython-main\Lib
C:\cpython-main\PCbuild\amd64     # <<<<< inserted
c:\cpython-main\DLLs
c:\cpython-main
c:\cpython-main\Lib\site-packages

2
C:\cpython-main\PCbuild\amd64\python311.zip
c:\cpython-main\Lib
C:\cpython-main\PCbuild\amd64     # <<<<< inserted
c:\cpython-main\DLLs
c:\cpython-main
c:\cpython-main\Lib\site-packages

f'{PYTHONHOME}/DLLs' is left just for test_embed.test_init_setpythonhome.