Skip to content

Conversation

@lazka
Copy link
Contributor

@lazka lazka commented Jan 11, 2026

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 we patched the "nt" scheme to work around this but we want to fix the real issue now)

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 we patched the "nt" scheme to work around this
but we want to fix the real issue now)
@lazka
Copy link
Contributor Author

lazka commented Jan 11, 2026

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant