-
-
Notifications
You must be signed in to change notification settings - Fork 588
fix(pypi): finish PEP508/PEP440 impl for version matching #2856
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I factored a check_evaluation helper out.
Also added a test to just loop over (expr, want, env) cases. I figure we can copy/paste some real expressions. Also makes it easy to add some arbitrary expression to test.
I tried fixing a bug with prefix matching exposed by the extra tests. I'm not entirely sure my revision is entirely correct. For fun, I ran the question through Gemini, it took like minutes (:astonished:) of thinking, and ultimately came back with something resembling:
Which satisfies my confirmation bias, but I didn't look closely or think it through, so yeah, grain of salt. Also, for version equality, the local part should be ignored, so I commented out that part of https://packaging.python.org/en/latest/specifications/version-specifiers/#id5
I couldn't find an "except where noted" later, so I'm pretty sure the '+blabla` is supposed to be ignored. |
Oh nice, thank you, I will check it my tomorrow. I knew that the prefix matching is not fully done yet, but ran out of time yesterday. |
I realized that the prefix matching could be a simple string prefix match so I went that way, the code became easier to reason about and I think it needs to be optimized a little, because I am normalizing the version twice, but I think this direction is promising. Ran out of time today, so I'll leave it for the next time. |
It seems that this is still not done. I am not sure I can fully grok the spec about what we should do with the version ordering. The exclusive ordered comparison is talking about Maybe the ordering is answered in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put a suffix/prefix on this file name. We have like 4 files named "version.bzl" or "versions.bzl" and I find it confusing. parser_version? version_parser? pypa_version_parser?
While I don't like the "version.bzl" file name, I odn't think it needs to block merging; enqueing. |
This reuses the previous work by @vonschultz who implemented
a PEP440 version normalizer. We extend it and use it in the
PEP508 marker evaluation.
Summary:
of the versions to the parsing context.
parsed version.
.*
usage in the environment markersif one of the sides is not a version.
version.bzl
becauseas far as Python is concerned this is the only version that
there can be. We could in theory probably reuse this in other
code where we are parsing the Python interpreter version many
times, but this is left for the future.
Fixes #2826
Work towards #2821