summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMiro Hrončok <miro@hroncok.cz>2022-03-18 09:53:29 (GMT)
committerGitHub <noreply@github.com>2022-03-18 09:53:29 (GMT)
commit48d926269963cfe7a49c0a4f34af4fe9b832399b (patch)
treed3fc5c6c1e6b8db9f95eb0fa1987c2738985f654 /Doc
parentcd44afc573e2e2de8d7e5a9119c347373066cd10 (diff)
downloadcpython-48d926269963cfe7a49c0a4f34af4fe9b832399b.zip
cpython-48d926269963cfe7a49c0a4f34af4fe9b832399b.tar.gz
cpython-48d926269963cfe7a49c0a4f34af4fe9b832399b.tar.bz2
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*.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/sysconfig.rst15
-rw-r--r--Doc/library/venv.rst5
-rw-r--r--Doc/whatsnew/3.11.rst32
3 files changed, 51 insertions, 1 deletions
diff --git a/Doc/library/sysconfig.rst b/Doc/library/sysconfig.rst
index 713be1e..fa18d62 100644
--- a/Doc/library/sysconfig.rst
+++ b/Doc/library/sysconfig.rst
@@ -73,7 +73,7 @@ Every new component that is installed using :mod:`distutils` or a
Distutils-based system will follow the same scheme to copy its file in the right
places.
-Python currently supports six schemes:
+Python currently supports nine schemes:
- *posix_prefix*: scheme for POSIX platforms like Linux or macOS. This is
the default scheme used when Python or a component is installed.
@@ -83,8 +83,14 @@ Python currently supports six schemes:
- *posix_user*: scheme for POSIX platforms used when a component is installed
through Distutils and the *user* option is used. This scheme defines paths
located under the user home directory.
+- *posix_venv*: scheme for :mod:`Python virtual environments <venv>` on POSIX
+ platforms; by default it is the same as *posix_prefix* .
- *nt*: scheme for NT platforms like Windows.
- *nt_user*: scheme for NT platforms, when the *user* option is used.
+- *nt_venv*: scheme for :mod:`Python virtual environments <venv>` on NT
+ platforms; by default it is the same as *nt* .
+- *venv*: a scheme with values from ether *posix_venv* or *nt_venv* depending
+ on the platform Python runs on
- *osx_framework_user*: scheme for macOS, when the *user* option is used.
Each scheme is itself composed of a series of paths and each path has a unique
@@ -119,6 +125,9 @@ identifier. Python currently uses eight paths:
This function was previously named ``_get_default_scheme()`` and
considered an implementation detail.
+ .. versionchanged:: 3.11
+ When Python runs from a virtual environment,
+ the *venv* scheme is returned.
.. function:: get_preferred_scheme(key)
@@ -132,6 +141,10 @@ identifier. Python currently uses eight paths:
.. versionadded:: 3.10
+ .. versionchanged:: 3.11
+ When Python runs from a virtual environment and ``key="prefix"``,
+ the *venv* scheme is returned.
+
.. function:: _get_preferred_schemes()
diff --git a/Doc/library/venv.rst b/Doc/library/venv.rst
index 092781b..b40bd41 100644
--- a/Doc/library/venv.rst
+++ b/Doc/library/venv.rst
@@ -177,6 +177,11 @@ creation according to their needs, the :class:`EnvBuilder` class.
``clear=True``, contents of the environment directory will be cleared
and then all necessary subdirectories will be recreated.
+ .. versionchanged:: 3.11
+ The *venv*
+ :ref:`sysconfig installation scheme <installation_paths>`
+ is used to construct the paths of the created directories.
+
.. method:: create_configuration(context)
Creates the ``pyvenv.cfg`` configuration file in the environment.
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 3914234..2af6638 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -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
-----