flit icon indicating copy to clipboard operation
flit copied to clipboard

`python-requires="~3.7"` generates a universal Wheel file

Open florisla opened this issue 4 years ago • 3 comments

When this is in pyproject.toml:

[project]
# ...
requires-python = ">=3.7,<4"

The flit build produces a Python-3-only Wheel file: projectname-0.0.1.dev0-py3-none-any.whl. Good! (and thanks for Flit, it's really nice!)

When I use the shorter syntax to require Python 3.7 or higher -- which I understood to be equivalent:

requires-python = "~=3.7"

Then the produced Wheel becomes universal: projectname-0.0.1.dev0-py2.py3-none-any.
When - obviously - I don't want to support Python 2.

If this difference in behavior is intentional, it should at least be mentioned in the docs.

florisla avatar Nov 29 '21 14:11 florisla

~= doesn't look to be valid in a python version specifier: https://www.python.org/dev/peps/pep-0345/#version-specifiers

dtrodrigues avatar Nov 29 '21 21:11 dtrodrigues

Maybe you meant >= instead of ~= for "greater than or equal to Python 3.7"?

Edit: `~=' is valid as well https://www.python.org/dev/peps/pep-0440/#compatible-release

dtrodrigues avatar Nov 29 '21 21:11 dtrodrigues

Yup, as you spotted, ~= is valid now. The canonical document for the package metadata standard is now https://packaging.python.org/specifications/core-metadata/ rather than the series of PEPs defining the changes for each new version. And that points (via this page) to PEP 440 for version specifiers.

This isn't intentional, it's just that the check for 'is this Python-3 only' is a fairly simple regex:

https://github.com/takluyver/flit/blob/353f920b7a1a95c28ba1234d275324c351d6f4a3/flit_core/flit_core/common.py#L385-L391

Properly, it should be parsing the version specifier and then checking 2.7 against all the clauses there. But the regex has been 'good enough' that there's hasn't been much pressure to do that.

takluyver avatar Nov 29 '21 21:11 takluyver