bpo-45413: Define "posix_venv", "nt_venv" and "venv" sysconfig installation schemes (GH-31034)

Define *posix_venv* and *nt_venv* sysconfig installation schemes
to be used for bootstrapping new virtual environments.
Add *venv* sysconfig installation scheme to get the appropriate one of the above.
The schemes are identical to the pre-existing
*posix_prefix* and *nt* install schemes.
The venv module now uses the *venv* scheme to create new virtual environments
instead of hardcoding the paths depending only on the platform. Downstream
Python distributors customizing the *posix_prefix* or *nt* install
scheme in a way that is not compatible with the install scheme used in
virtual environments are encouraged not to customize the *venv* schemes.
When Python itself runs in a virtual environment,
sysconfig.get_default_scheme and
sysconfig.get_preferred_scheme with `key="prefix"` returns
*venv*.
This commit is contained in:
Miro Hrončok 2022-03-18 10:53:29 +01:00 committed by GitHub
parent cd44afc573
commit 48d9262699
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 211 additions and 16 deletions

View file

@ -361,6 +361,24 @@ sys
(equivalent to ``sys.exc_info()[1]``).
(Contributed by Irit Katriel in :issue:`46328`.)
sysconfig
---------
* Two new :ref:`installation schemes <installation_paths>`
(*posix_venv*, *nt_venv* and *venv*) were added and are used when Python
creates new virtual environments or when it is running from a virtual
environment.
The first two schemes (*posix_venv* and *nt_venv*) are OS-specific
for non-Windows and Windows, the *venv* is essentially an alias to one of
them according to the OS Python runs on.
This is useful for downstream distributors who modify
:func:`sysconfig.get_preferred_scheme`.
Third party code that creates new virtual environments should use the new
*venv* installation scheme to determine the paths, as does :mod:`venv`.
(Contributed by Miro Hrončok in :issue:`45413`.)
threading
---------
@ -395,6 +413,20 @@ unicodedata
* The Unicode database has been updated to version 14.0.0. (:issue:`45190`).
venv
----
* When new Python virtual environments are created, the *venv*
:ref:`sysconfig installation scheme <installation_paths>` is used
to determine the paths inside the environment.
When Python runs in a virtual environment, the same installation scheme
is the default.
That means that downstream distributors can change the default sysconfig install
scheme without changing behavior of virtual environments.
Third party code that also creates new virtual environments should do the same.
(Contributed by Miro Hrončok in :issue:`45413`.)
fcntl
-----