Author FFY00
Recipients FFY00, gaborjbernat, hroncok, jaraco
Date 2021-10-08.17:50:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Python 3.10 introduced sysconfig._get_preferred_schemes[1], a mechanism to allow downstream distributors to overwrite the default install scheme.
This is done to support downstream modifications where distributors change the installation layout (eg. different site-packages directory). So, distributors will change the default scheme to one that correctly represents their layout.

This presents an issue for projects/people that need to bootstrap virtual environments, like virtualenv (see [2]). As distributors might now be customizing the default install scheme, there is no guarantee that the information returned by sysconfig.get_default_scheme/get_paths is correct for the virtual environment, the only guarantee we have is that it correct for the *current* environment. When bootstrapping a virtual environment, we need to know its layout, so that we can place the files in the correct locations.

The usual solution in situations like this would be to invoke the interpreter we are targeting to get the correct information (eg. path/to/python -m sysconfig), but that is not possible here as the environment does not exist yet -- we are the ones trying to create it.

To solve this issue, I propose the addition of a "virtual" or "venv" install scheme, for virtual environments. The idea is that virtual environments (defined by the presence of pyvenv.cfg, see [3][4]) will always use this scheme, they will use the paths specified by this scheme and sysconfig.get_default_scheme will always return it (_get_preferred_schemes would have no effect here!).
This makes it possible to know the virtual environment layout for another interpreter, via sysconfig.get_paths(scheme='virtual').

I am not cure if this should be adopted in 3.10 or 3.11, as it effectively makes it impossible to reliably construct virtual environments, and requires workarounds such as [5], that pretty much implements this proposal with non-standardized downstream patches.

Date User Action Args
2021-10-08 17:50:02FFY00setrecipients: + FFY00, jaraco, hroncok, gaborjbernat
2021-10-08 17:50:02FFY00setmessageid: <>
2021-10-08 17:50:02FFY00linkissue45413 messages
2021-10-08 17:50:02FFY00create