PEP 345, 566, 508 version specifiers and OR clauses
I'm about to release a new version of importlib_resources, so I want to get my flit.ini's require-python clause right. We support Python 2.7, and 3.4 and beyond. This makes me sad: requires-python = '>=2.7,!=3.0,!=3.1,!=3.2,!=3.3' Of course, I'd like to write this like: requires-python = '(>=2.7 and <3) or >= 3.4' I understand that OR clauses aren't supported under any syntax currently, but as PEPs 566 and 508 are still open/active, wouldn't it be reasonable to support something like this explicitly? It seems like wanting to support 2.7 and some versions of Python 3 (but not all) is a fairly common need. Cheers, -Barry
It seems like a small amount of convenience in exchange for a
significant increase in complexity to me.
FYI, some previous discussion on the topic can be found here:
https://mail.python.org/pipermail/distutils-sig/2016-September/029651.html
And also here:
https://github.com/pypa/setuptools/issues/1158
D.
On Wed, Dec 13, 2017 at 6:17 PM, Barry Warsaw
I'm about to release a new version of importlib_resources, so I want to get my flit.ini's require-python clause right. We support Python 2.7, and 3.4 and beyond. This makes me sad:
requires-python = '>=2.7,!=3.0,!=3.1,!=3.2,!=3.3'
Of course, I'd like to write this like:
requires-python = '(>=2.7 and <3) or >= 3.4'
I understand that OR clauses aren't supported under any syntax currently, but as PEPs 566 and 508 are still open/active, wouldn't it be reasonable to support something like this explicitly?
It seems like wanting to support 2.7 and some versions of Python 3 (but not all) is a fairly common need.
Cheers, -Barry
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org https://mail.python.org/mailman/listinfo/distutils-sig
On Dec 13, 2017, at 19:39, Dustin Ingram
It seems like a small amount of convenience in exchange for a significant increase in complexity to me.
I can’t speak to the complexity, but it’s very definitely an important use case. Imagine when Python 3.10 is out; do you really want to have to write: requires-python = '>=2.7,!=3.0,!=3.1,!=3.2,!=3.3,!=3.4,!=3.5,!=3.6,!=3.7’ and so on? Plus, I don’t think it’s uncommon to have disjointed version support like this (well, maybe until 2020 when Python 2 is dead and gone <wink>). And you have to get requires-python right, otherwise tools like tox can’t do the right thing when they install your library into its virtual environments.
FYI, some previous discussion on the topic can be found here:
Thanks for the links. And thanks Donald for your vote of support. Cheers, -Barry
On Dec 13, 2017, at 7:17 PM, Barry Warsaw
wrote: I understand that OR clauses aren't supported under any syntax currently, but as PEPs 566 and 508 are still open/active, wouldn't it be reasonable to support something like this explicitly?
I personally think this is a good idea, and ideally it would come with support “and”, “or”, and parenthetical for grouping and deprecate (but not remove) support for comma as and and. We actually already support this inside of environment markers just not in the version specifiers. So you can do something like ``python_version == “2.7” or python_version >= “3.4”`` in environment markers and that works but it doesn’t work in other scenarios where it’s useful (such as in requires_python). Overall I’m +1, not sure if it would be a new PEP or an amendment to the current PEPs but I think it’s a good idea.
On 14.12.2017 3:17, Barry Warsaw wrote:
I'm about to release a new version of importlib_resources, so I want to get my flit.ini's require-python clause right. We support Python 2.7, and 3.4 and beyond. This makes me sad:
requires-python = '>=2.7,!=3.0,!=3.1,!=3.2,!=3.3'
Of course, I'd like to write this like:
requires-python = '(>=2.7 and <3) or >= 3.4'
I understand that OR clauses aren't supported under any syntax currently, but as PEPs 566 and 508 are still open/active, wouldn't it be reasonable to support something like this explicitly?
It seems like wanting to support 2.7 and some versions of Python 3 (but not all) is a fairly common need. What you're actually asking for is for the >= operator to be limited to a specified major version.
With semantic versioning (which is Python's recommended best practice), this is actually a very reasonable thing to do: specify supported major versions, and for each one (it's more likely to be the edge ones), optionally limit minor versions. If only we could think of a good syntax... Folks, how problematic would it be to make this the default/enabled with a switch? With only two major versions, I don't expect much breakage, except packages like setuptools that don't use semantic versioning. -- Regards, Ivan
On Wed, Dec 13, 2017 at 6:11 PM, Ivan Pozdeev via Distutils-SIG
On 14.12.2017 3:17, Barry Warsaw wrote:
I'm about to release a new version of importlib_resources, so I want to get my flit.ini's require-python clause right. We support Python 2.7, and 3.4 and beyond. This makes me sad:
requires-python = '>=2.7,!=3.0,!=3.1,!=3.2,!=3.3'
Of course, I'd like to write this like:
requires-python = '(>=2.7 and <3) or >= 3.4'
I understand that OR clauses aren't supported under any syntax currently, but as PEPs 566 and 508 are still open/active, wouldn't it be reasonable to support something like this explicitly?
It seems like wanting to support 2.7 and some versions of Python 3 (but not all) is a fairly common need.
What you're actually asking for is for the >= operator to be limited to a specified major version.
We actually have the ~= operator that's basically that-- not sure if it's allowed in requires-python. But that's not sufficient. You also need an "or" primitive if you want to express "~= 2.7 or ~= 3.4". Right now all you could write is "~= 2.7 and ~= 3.4", which is the null set :-). -n -- Nathaniel J. Smith -- https://vorpus.org
On 14.12.2017 5:25, Nathaniel Smith wrote:
On Wed, Dec 13, 2017 at 6:11 PM, Ivan Pozdeev via Distutils-SIG
wrote: On 14.12.2017 3:17, Barry Warsaw wrote:
I'm about to release a new version of importlib_resources, so I want to get my flit.ini's require-python clause right. We support Python 2.7, and 3.4 and beyond. This makes me sad:
requires-python = '>=2.7,!=3.0,!=3.1,!=3.2,!=3.3'
Of course, I'd like to write this like:
requires-python = '(>=2.7 and <3) or >= 3.4'
I understand that OR clauses aren't supported under any syntax currently, but as PEPs 566 and 508 are still open/active, wouldn't it be reasonable to support something like this explicitly?
It seems like wanting to support 2.7 and some versions of Python 3 (but not all) is a fairly common need. What you're actually asking for is for the >= operator to be limited to a specified major version.
We actually have the ~= operator that's basically that-- not sure if it's allowed in requires-python. But that's not sufficient. You also need an "or" primitive if you want to express "~= 2.7 or ~= 3.4". Right now all you could write is "~= 2.7 and ~= 3.4", which is the null set :-). If my logic algebra memory serves me right, `or' can be changed to `and' and vice versa by lowering or raising a negation line:
~= 2.7 or ~= 3.4 <=> !!(~= 2.7 or ~= 3.4) <=> !(!~=2.7 and !~=3.4) But you need superposition (the brackets) for that. -- Regards, Ivan
On 14.12.2017 5:25, Nathaniel Smith wrote:
On Wed, Dec 13, 2017 at 6:11 PM, Ivan Pozdeev via Distutils-SIG
wrote: On 14.12.2017 3:17, Barry Warsaw wrote:
I'm about to release a new version of importlib_resources, so I want to get my flit.ini's require-python clause right. We support Python 2.7, and 3.4 and beyond. This makes me sad:
requires-python = '>=2.7,!=3.0,!=3.1,!=3.2,!=3.3'
Of course, I'd like to write this like:
requires-python = '(>=2.7 and <3) or >= 3.4'
I understand that OR clauses aren't supported under any syntax currently, but as PEPs 566 and 508 are still open/active, wouldn't it be reasonable to support something like this explicitly?
It seems like wanting to support 2.7 and some versions of Python 3 (but not all) is a fairly common need. What you're actually asking for is for the >= operator to be limited to a specified major version.
We actually have the ~= operator that's basically that-- not sure if it's allowed in requires-python. But that's not sufficient. You also need an "or" primitive if you want to express "~= 2.7 or ~= 3.4". Right now all you could write is "~= 2.7 and ~= 3.4", which is the null set :-). With the aforementioned semantic versioning, a "natural" version specifier would be:
* a disjuction of major versions (probably a range), * with each one of them possibly accompanied by a conjuction of minor versions. So, yes, for this, an `or' and superposition (arbitrary or otherwise) are absolute requirements. -- Regards, Ivan
participants (5)
-
Barry Warsaw
-
Donald Stufft
-
Dustin Ingram
-
Ivan Pozdeev
-
Nathaniel Smith