After thinking about this some more, I made a PR that adjusts the packaging
library so that is has semantics which might be better overall than what is
if someone wants to play with it at all, but the highlights are:
* 1.7.1 matches >1.7 (previously it did not)
* 1.7.post1 does not match >1.7 (previously it did not)
* 1.7.post1 matches >1.7.post0 (previously it did)
* 3.dev0 does not match <3.0 (previously it did)
* 3.0.dev0 does not match <3.0 (previously it did not)
* 3.0.dev0 matches <3.0rc1 (previously it did)
Instead of having >V and <V impliy !=V.*, this means that:
1. A <V does not match a pre-release of V unless V is itself a pre-release.
2. A >V does not match a post-release of V unless V is itself a post-release.
3. A >V does not match a V+local.version.
Implicitly these three rules are also true, but they are true because of the
ordered nature of the versions and the mathemtical meaning of > and < rather
than any rule mentioned in the PEP:
4. A <V does not match a post-release of V unless V is itself a post-release.
5. A >V does not match a pre-release of V unless V is itself a pre-release.
6. A <V does not match a V+local.version.
If you check out my branch, you can play around with the specifier rules as
I've implemented them now by just doing:
>>> from packaging.specifiers import SpecifierSet
>>> SpecifierSet(">1.7").contains("1.7.1", prereleases=True)
True
>>> SpecifierSet(">1.7").contains("1.7.post1", prereleases=True)
False
>>> SpecifierSet(">1.7.post0").contains("1.7.post1", prereleases=True)
True
>>> SpecifierSet(">1.7").contains("1.7+thing.1", prereleases=True)
False
>>> SpecifierSet("<3.0.0").contains("3.0.dev0", prereleases=True)
False
>>> SpecifierSet("<3").contains("3.0.dev0", prereleases=True)
False
>>> SpecifierSet("<3rc1").contains("3.0.dev0", prereleases=True)
True
Does this better match your expectations? I think I might like these rules
better as they handle zero padding similarly to ==, !=, >=, and <= (sans when
== and != have a .*) which means that a rule like <3.0 won't accept 3.dev0
even though the current PEP means that it does. I think it also follows along
better with what people expect both for > and for <.