Declare minimum Python version in metadata#2726
Conversation
We got a bug report in uv because pywin32 only has wheels for Python 3.8+ and no source distribution, but doesn't declare its minimum requires Python version (astral-sh/uv#15069). This prevents package managers from correctly rejecting it as an unsupported version when resolving for a range of Python versions. This PR adds this bound as `Requires-Python` in the wheel metadata.
Co-authored-by: Avasam <samuel.06@hotmail.com>
|
I've a similar question to mine in #2028, which is probably my misunderstanding - but what's the actual use-case here - why can't package managers running Python 3.7 already reject this because such a wheel doesn't exist? How do we ensure this doesn't go stale over time? |
|
Usually, packages provide both a source distribution and a Packages that do not provide a source distribution are rare and usually packages that have very custom platform requirements (torch, tensorflow). While it's technically possible to infer the bound from wheel tags, it's both a lot of complexity for a case that rarely exists (pywin32 is currently the only case I'm aware of). It also means that we can't resolve from core metadata alone anymore, but always need to process the list of files (the list of files is currently only required for a universal resolution when a specific platform is required, it's otherwise possible from metadata alone).
This bound usually gets bumbed together with the CI and docs changes when dropping support for a Python version, similar to #2413. |
We do too though?
It's the "usually" that worries me here - the fact no binary exists is more difficult to accidentally forget. If we fail to update this, what's the error scenario? |
I get that, but I don't see how failing earlier here is better than failing later. Python 3.7 is going to fail in either case. |
|
Whilst I personally prefer having the lower bounds (no upper though !), hence approval. I'm not gonna merge until Mark is convinced.
We don't, not on PyPI, as Konstin showed above. And I don't mind if it stays that way as building pywin32 has a certain set of requirements and I'd rather leave that to advanced users that will know to clone the project or build from source from GitHub. (sdists also have replicability issues). Have inexperienced users be told we don't support their platform/python (missing wheel) rather than getting reports of failed sdist builds from PyPI.
For sdists: In the hypothetical we started shipping it, AFAICT, the most recent pywin32 will try to install and build on unsupported Python version, then either fail at build or runtime (depending on where we introduced the breaking change). Which is solved by pinning pywin32 For bdist: I'll let @konstin answer here. But I'd assume a resolver would try the latest pywin32 version, fail to find a binary for the unsupported python version, then fallback to the slow resolution (or fail entirely, but also solved by pinning pywin32) Also note that if we eventually move static project metadata (title, author, version, links, readme, license, etc.) from |

We got a bug report in uv because pywin32 only has wheels for Python 3.8+ and no source distribution, but doesn't declare its minimum requires Python version (astral-sh/uv#15069). This prevents package managers from correctly rejecting it as an unsupported version when resolving for a range of Python versions. This PR adds this bound as
Requires-Pythonin the wheel metadata.Closes #2028
Closes #1448