Currently both pip and uv (and others?) ignore the pre-release section of requires-python
.
E.g.
[project]
name = "foo"
version = "0.1.0"
requires-python = ">=3.13"
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
Using any Python 3.13 pre-release:
$ pip install --dry-run .
Processing ...
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Would install foo-0.1.0
Yet this does not conform to the specifier spec:
>>> from packaging import specifiers
>>> specifiers.SpecifierSet(">=3.13").contains("3.13.0rc1", prereleases=True)
False
To be fair, I think most users would find this surprising behavior. And the spec actually says very little on requires-python
:
This field specifies the Python version(s) that the distribution is compatible with. Installation tools may look at this when picking which version of a project to install.
The value must be in the format specified in Version specifiers.
Perhaps it would make sense, as it is the de facto standard, to say it is normal to ignore the pre-release part of the version on comparison?