Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions peps/pep-0838.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ Specification
A new ``python-version`` field is added to ``pyvenv.cfg``. It 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]}"``. Tools creating virtual
environments MUST write ``python-version`` to ``pyvenv.cfg``. Reading
``version`` or ``version_info`` is discouraged.
``f"{sys.version_info[0]}.{sys.version_info[1]}"``. Tools MUST write
``python-version`` to ``pyvenv.cfg`` when creating the virtual environment.
Reading ``version`` or ``version_info`` is discouraged.

A Python interpreter MAY refuse to run from a virtual environment with a
mismatching ``python-version``.
mismatching ``python-version``. A mismatch between the value and the
observed version of the Python interpreter in virtual environment signals
a broken virtual environment.


Rationale
Expand All @@ -87,7 +89,8 @@ search <https://github.com/search?q=path%3A**%2Fpyvenv.cfg%20python-version&type
avoiding breakage in tools that read any of the existing keys. By
specifying only the major and minor version, the value remains fresh even if
the underlying Python interpreter is updated from one patch release to
another.
another. If we were to reuse an existing field, it would also be a breaking
change. On the other hand, the cost of adding a new field is minimal.

This PEP does not handle the case of ``python-version`` going stale due to
the underlying Python interpreter being updated to another minor version.
Expand Down
Loading