New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

==0.1.* doesn't match 0.1+upstream.2 #41

Closed
habnabit opened this Issue Sep 14, 2015 · 6 comments

Comments

Projects
None yet
3 participants
@habnabit

habnabit commented Sep 14, 2015

As in the title, ==0.1.* doesn't match the version 0.1+upstream.2. I discovered this as a result of specifying a requirement ~=0.1.0, and getting 0.1 instead of 0.1+upstream.2. I can produce a reproducing example if necessary.

@dstufft

This comment has been minimized.

Member

dstufft commented Sep 14, 2015

Some notes from when I was testing this:

>> import packaging.specifiers
>>> packaging.specifiers.SpecifierSet("~=0.1.0").contains("0.1+upstream.2")
False
>>> packaging.specifiers.SpecifierSet(">=0.1.0,==0.1.*").contains("0.1+upstream.2")
False
>>> packaging.specifiers.SpecifierSet(">=0.1.0").contains("0.1+upstream.2")
True
>>> packaging.specifiers.SpecifierSet("==0.1.*").contains("0.1+upstream.2")
False
>>> packaging.specifiers.SpecifierSet("==0.*").contains("0.1+upstream.2")
True
>>> packaging.specifiers.SpecifierSet("==0.1.*").contains("0.1+upstream.2")
False
>>> packaging.specifiers.SpecifierSet("==0.1.0.*").contains("0.1+upstream.2")
False

It appears as if we do this correctly when ==0.* is the version specifier, but not when ==0.1.* is the version specifier.

We might also want to double check PEP 440 to make sure that this particular use case is clearly defined.

@dstufft

This comment has been minimized.

Member

dstufft commented Sep 14, 2015

Oh, and for completeness sake:

>>> packaging.specifiers.SpecifierSet("==0.1.*").contains("0.1")
True
@habnabit

This comment has been minimized.

habnabit commented Sep 14, 2015

While I'm thinking about this, it would also be nice to be able to have requirements be able to match against upstream versions. >=0.1.0+upstream.2 ignores the bit after the +, and effectively works the same as >=0.1.0.

@dstufft

This comment has been minimized.

Member

dstufft commented Sep 14, 2015

Double checking PEP 440, I see why that doesn't work:

PEP 440 says:
Local version identifiers are NOT permitted in this version specifier.

I don't recall exactly why we did that, I think it was likely to prevent (or discourage) people from uploading things to PyPI that had a dependency on a particular local version. In fact, the PEP disallows local versions like that in all specifiers except for == (without the .*) and ===. The "ignoring" behavior you're seeing is because we fall back onto a legacy implementation if something isn't a valid PEP 440 specifier which I think probably has that behavior.

@dstufft

This comment has been minimized.

Member

dstufft commented Sep 14, 2015

Oh, to be clear, changing the behavior of >= will require at a minimum, discussion on distutils-sig, but the behavior of ~= is a bug.

xavfernandez added a commit to xavfernandez/packaging that referenced this issue Nov 19, 2015

@xavfernandez

This comment has been minimized.

Contributor

xavfernandez commented Nov 20, 2015

The ~= behavior should be fixed by #47

@dstufft dstufft closed this in #47 Jan 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment