Skip to content

Add python-version to pyvenv.cfg for PEP 838 - #3193

Draft
konstin wants to merge 4 commits into
pypa:mainfrom
konstin:pep-838-python-version
Draft

konstin wants to merge 4 commits into
pypa:mainfrom
konstin:pep-838-python-version

Conversation

@konstin

@konstin konstin commented Jul 21, 2026

Copy link
Copy Markdown

Draft PR accompanying PEP 838

@konstin konstin changed the title Add python-version to pyvenv.cfg Add python-version to pyvenv.cfg for PEP 838 Jul 21, 2026
@gaborbernat
gaborbernat marked this pull request as ready for review July 24, 2026 06:33
@gaborbernat
gaborbernat marked this pull request as draft July 24, 2026 06:35
@gaborbernat
gaborbernat force-pushed the pep-838-python-version branch from a2e69f4 to 23c018b Compare August 28, 2026 19:17
konstin and others added 4 commits August 28, 2026 12:20
Bind version_info once instead of repeating self.interpreter.version_info
across the python-version, version_info, and version fields.

Assert the written python-version against sys.version_info rather than the
interpreter object the code just read, so the test fails if the field value
is wrong.
The key had no home in the docs, since virtualenv documented no
`pyvenv.cfg` key anywhere. A reference page now covers the file, and a
table sets `python-version` against `version` and `version_info`, which
carry one number at three precisions and gave callers no reason to
prefer one over another.

The tutorial reads the key out of an environment it just made, the usage
guide parses it without spawning the interpreter, and the explanation of
why environments borrow from the base install says why `pyvenv.cfg`
became the place tools look.

The version assertion compared against the running interpreter while the
code reads the target one, so it passed for the wrong reason whenever
the two agree.
@gaborbernat
gaborbernat force-pushed the pep-838-python-version branch from 23c018b to 1ebb90b Compare August 28, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants