pypa / pipfile

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[requires] python_version to use marker syntax (ability to describe package compatible python version by range)

gsemet opened this issue · comments

Hello

I don't know if this is a limitation of pipenv of pipfile, but I would like to recommend that

[requires]
python_version = ...

Support range syntax, for example:

[requires]
python_version = '>=3.5;<3.7'

Duplicate of #87, ticket opened in pipenv#1050

I also first tried '>= 3.5', which would be the best, but more dissapointingly, my next try was:

[requires]
python_version = "3.5,3.6,3.7,3.8"

And I've got:

Specifier python_version does not match 3.5,3.6,3.7,3.8 (3.7).
Failed!

If a package uses a concrete list like python_version = "3.5,3.6,3.7,3.8", it will be a problem for consumers as existing code most probably works in next python version e.g. 3.9 but will not be allowed. So once a new python version comes out people will have to wait for such packages to release new versions that declare compatibility, and all already released old versions will remain incompatible :-(

Hmm, similar problem exists for packages pinning a specific python version now, doesn't it? I guess the existing functionality was intended for locking app deployment, not for packages...

Anyway, a comma-separated list of specific versions will match nothing, because comma means intesection, not union:

The comma (",") is equivalent to a logical and operator: a candidate version must match all given version clauses in order to match the specifier as a whole.
-- https://www.python.org/dev/peps/pep-0440/#version-specifiers

Interestingly, markers qualifying whether a dependency is required already support complex python_version conditions, e.g. example now in README:

unittest2 = {version = ">=1.0,<3.0", markers="python_version < '2.7.9' or (python_version >= '3.0' and python_version < '3.4')"}