Skip to content
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 · Fixed by #47
Closed

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

habnabit opened this issue Sep 14, 2015 · 6 comments · Fixed by #47

Comments

@habnabit
Copy link

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
Copy link
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
Copy link
Member

dstufft commented Sep 14, 2015

Oh, and for completeness sake:

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

@habnabit
Copy link
Author

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
Copy link
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
Copy link
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
Copy link
Member

The ~= behavior should be fixed by #47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants