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

22.0: The new requirement parser doesn't handle unnormalized specifiers #629

Closed
frostming opened this issue Dec 8, 2022 · 4 comments · Fixed by #634
Closed

22.0: The new requirement parser doesn't handle unnormalized specifiers #629

frostming opened this issue Dec 8, 2022 · 4 comments · Fixed by #634

Comments

@frostming
Copy link

from packaging.specifiers import SpecifierSet
from packaging.requirements import Requirement

s = SpecifierSet('>=1.0-alpha')  # success
"1.0a0" in s  # True

r = Requirement('foo>=1.0-alpha')  # Error

Ideally, we should make them consistent.

@hroncok
Copy link
Contributor

hroncok commented Dec 8, 2022

For the record, Requirement('foo>=1.0-alpha') worked with packaging 21 (I've double-checked since it wasn't mentioned in the issue explicitly).

@pradyunsg
Copy link
Member

Did it parse as a LegacySpecifier?

If not, this might be a discrepancy between the logic in the new parser vs Specifier. Thinking a bit more, it might make sense to tweak the parser to try and directly match using the Specifier regex itself.

@pradyunsg
Copy link
Member

pradyunsg commented Dec 8, 2022

packaging.requirements.InvalidRequirement: Expected end or semicolon (after version specifier)
     foo >= 1.0-alpha 
         ~~~~~~~~^

The error message gives a hint of what's happening: 1.0-a is getting parsed as the version here. Having this mentioned in OP would've saved me 3 hours. 🤦🏽

@pradyunsg pradyunsg changed the title The new requirement parser doesn't handle unnormalized specifiers 22.0: The new requirement parser doesn't handle unnormalized specifiers Dec 8, 2022
This was referenced Dec 8, 2022
@henryiii
Copy link
Contributor

henryiii commented Dec 9, 2022

I expect this is what is breaking build’s test suite with 22.0. Probably should verify the dev version fixes build’s tests. I’m on vacation through tomorrow so can’t check till the weekend. Anyone else from @pypa/build?

https://github.com/pypa/build/actions/runs/3649979305

Or it might be #545, actually, and we just need to update our tests.

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

Successfully merging a pull request may close this issue.

4 participants