From 60fb95f7e3ffa763f0f72d52e06c4f530c3a961f Mon Sep 17 00:00:00 2001 From: konstin Date: Sat, 21 Nov 2026 12:22:23 +0100 Subject: [PATCH] PEP 838: Add `python-version` to `pyvenv.cfg` Stacked on top of https://github.com/pypa/packaging.python.org/pull/2201. --- source/specifications/virtual-environments.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/specifications/virtual-environments.rst b/source/specifications/virtual-environments.rst index ba35d96c6..738ed5dad 100644 --- a/source/specifications/virtual-environments.rst +++ b/source/specifications/virtual-environments.rst @@ -46,6 +46,11 @@ are defined: virtual environment site directories. If ``false``, the system site directories are not included. It is RECOMMENDED to set it to ``false`` when creating a virtual environments. The value is not case sensitive. +* ``python-version``: Contains a string value with the major and minor version + of the Python interpreter, such as ``3.16``. The value can be obtained with + ``f"{sys.version_info[0]}.{sys.version_info[1]}"``. It omits the patch + version or any other version components. Tools MUST write ``python-version`` + to ``pyvenv.cfg`` when creating the virtual environment. Declaring installation environments as Python virtual environments @@ -65,3 +70,4 @@ History - May 2012: This specification was approved through :pep:`405`. - Nov 2026: Removed PEP 405 references and clarified that ``include-system-site-packages`` defaults to ``true``. +- Nov 2026: Added ``python-version`` from :pep:`838`.