Description
Checklist
- I am confident this is a bug in CPython, not a bug in a third-party project
- I have searched the CPython issue tracker,
and am confident this bug has not been reported before
CPython versions tested on:
3.11, 3.12, CPython main branch
Operating systems tested on:
Windows
Output from running 'python -VV' on the command line:
No response
A clear and concise description of the bug:
Windows builds of Python use a script called find_python.bat to locate a valid python.exe to use during the build.
It tries, in order:
- whatever's in
VIRTUAL_ENV
- whatever's already in
externals\pythonx86\tools\
- query
py.exe
from $PATH, but only a permitted version, as per this line https://github.com/python/cpython/blob/main/PCbuild/find_python.bat#L45 - downloading Python from the default configured NuGet repo (empty therefore nuget.exe defaults)
The problem is with case 3.
The permitted $PATH versions of Python to build 3.10 are 3.9 or 3.8 - if 3.10 is installed, it is ignored and 3.12RC1 from NuGet is used instead
The permitted $PATH versions of Python to build 3.11 are 3.10 or 3.9 - if 3.11 is installed, it is ignored and 3.12RC1 from NuGet is used instead
The permitted $PATH versions of Python to build 3.12 are 3.11, 3.10 or 3.9 - if 3.12 is installed, it is ignored and 3.12RC1 from NuGet is used instead
The permitted $PATH versions of Python to build main are 3.11, 3.10 or 3.9 - if main is installed, it is ignored and 3.12RC1 from NuGet is used instead
This behaviour is clearly wrong (especially since the version downloaded in the fallback case 4 is not version locked, so right now it's 3.12RC1 and doesn't account for compatibility breakages). Version X should always be in the permitted list to build version X.
3.9 did allow builds from a system install of 3.9, but this seems like an accident rather than design.