Conversation
|
Since it might not be obvious, here is the reason sysconfig returns "venv" in case "prefix" is passed: https://github.com/python/cpython/blob/23b93770f6e6c6db2eef9d9b9e6ca7741489ae99/Lib/sysconfig/__init__.py#L300-L301 |
distutils by default passes os.name, so "nt", to _resolve_scheme() which results in the layout key being "", which results in get_preferred_scheme() raising, and "nt" being returned as as a fallback. This is not correct in case sysconfig has a different scheme configuration, or in case we are installing into a venv, where the "venv" scheme should be selected and not "nt". Fix by defaulting to the "prefix" layout in case no layout is given. This gives us "nt" from sysconfig, and "venv" in case we are in a venv. With CPython the change from "nt" to "venv" doesn't change anything for distutils since that only means "headers" are missing, which distutils injects later, resulting in the same scheme paths. For MINGW Python which defaults to the "posix" scheme this fixes the default install location (up until now MINGW Python patched the "nt" scheme to work around this but we want to fix the real issue now)
47a6744 to
b263b17
Compare
|
The premise holds, and the mechanism is narrower than the description suggests. Worth stating in the PR: this narrows the silent fallback rather than removing it. Test suite on Windows: 4 failed, 234 passed, identical failing set with and without the patch. MeasurementsPython 3.14.7, per scheme name, Inside a venv (3.13.13): Suite, unpatched and patched, identical set: |
distutils by default passes os.name, so "nt", to _resolve_scheme() which results in the layout key being "", which results in get_preferred_scheme() raising, and "nt" being returned as as a fallback.
This is not correct in case sysconfig has a different scheme configuration, or in case we are installing into a venv, where the "venv" scheme should be selected and not "nt".
Fix by defaulting to the "prefix" layout in case no layout is given. This gives us "nt" from sysconfig, and "venv" in case we are in a venv. With CPython the change from "nt" to "venv" doesn't change anything for distutils since that only means "headers" are missing, which distutils injects later, resulting in the same scheme paths.
For MINGW Python which defaults to the "posix" scheme this fixes the default
install location (up until now MINGW Python patched the "nt" scheme to work
around this but we want to fix the real issue now)