Illustrative Example: Dropping an Old Python Without Telling the Installer
A made-up case, labelled as such. "Library L" is a small parsing package on PyPI. Its maintainers started using syntax that only newer interpreters understand but left the package metadata unchanged. The code change was reasonable; the missing metadata turned it into a breaking release for a slice of users who never chose to upgrade.
Assumptions for the scenario
- Library L
2.3.0supports Python 3.8 and up, and itspyproject.tomlsays so. - For
2.4.0the team adopts thematchstatement, which requires Python 3.10. - Assume a minority of users, say one in ten, still run 3.8 or 3.9 on long-lived servers.
- The project builds a single pure-Python wheel tagged
py3-none-any, so the wheel tag says nothing about the minimum version.
What broke
The pyproject.toml for 2.4.0 still read:
[project]
name = "library-l"
version = "2.4.0"
requires-python = ">=3.8"
pip reads the Requires-Python metadata when choosing which release to install. Because 2.4.0 claimed to support 3.8, a user on 3.9 running pip install -U library-l received it, and the first import failed with a SyntaxError inside the library. Nothing in the error pointed at a version mismatch; it looked like a corrupted install. Assume each affected team spent an hour or so before someone read the changelog.
The one-line fix that should have shipped
requires-python = ">=3.10"
With the correct bound, pip on 3.9 simply skips 2.4.0 and installs the newest release whose metadata allows 3.9, which is 2.3.0. The user gets a working package and no error. This behaviour is described in the Python Packaging User Guide and is the reason the field exists. It only works if the field is accurate on every release.
Repairing the released version
Files uploaded to PyPI cannot be overwritten; a given filename can only be uploaded once. So the team cannot edit the metadata of 2.4.0 in place. The realistic options were:
- Yank 2.4.0 on PyPI (the mechanism defined in PEP 592). Installers skip a yanked release unless it is pinned exactly, so new installs on 3.9 fall back to 2.3.0.
- Publish 2.4.1 with
requires-python = ">=3.10"and otherwise identical code. - Note it in the changelog under a heading readers will see, stating the new minimum version plainly.
Is dropping a Python version a major change?
Projects disagree. Some treat interpreter support as part of the public contract and bump the major; others drop versions that have reached end of life in a minor release, on the basis that correct requires-python metadata means nobody gets a broken install. Either policy can be defensible. What is not defensible is changing the floor without changing the metadata. A CI job that runs the test suite on the lowest version requires-python claims would have failed on day one. For a wider view of version rules, see choosing the next version number.