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

Alternative PR to #92288.
A build path overrides f'{PYTHONHOME}/DLLs' in sys.path, when pybuilddir.txt is found. And a new test runs in a temp directory where pybuilddir.txt doesn't exist.

Here is an output of C code in the description of #91985:

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
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
C:\cpython-main
C:\cpython-main\Lib\site-packages