-
Notifications
You must be signed in to change notification settings - Fork 240
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
In Markers, use PEP 440 version comparison only if both sides are valid version specifier. #101
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
d79297a
In Version, convert version to string before applying the regex.
vphilippon 34e8b5b
Markers: Use PEP 440 version comparison only when both sides are vali…
vphilippon 6c2e77c
In Version, catch TypeError from the regex, and raise InvalidVersion.
vphilippon File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we really want that ? :-/
(and same question for
"extra": "3.7.0.0
)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.
In PEP-440
3.7.0==3.7.0+anything
, and3.7.0==3.7.0.0
too.That's how PEP-440 does the comparison, and how PEP-508 defines it, as it says it respects PEP-440 comparison for valid version specifier.
So,the marker
extra == '3.7.0'
withextra=3.7.0+youaregreat
should evaluate as true.We can open another issue about the PEP-508 spec and the changes we might want, but that's the "how PEP-508 is supposed to be right now" implementation.
Personnaly, I'm ok with that, and I'm eagerly waiting for the PEP-440 comparison to be fixed in the extras for pip, as I'd like to define some things like:
Now, if I all my extras are valid version specifier, but I want
3.7.0
and3.7.0.0
to be different, I could define those using===
:One sad thing, if you have extras like
foobar
,3.7.0
and3.7.0.0
, you can't differentiate them all with PEP-508, as the===
operator is not defined in python, so you can't use it here. That means you're back with3.7.0==3.7.0.0
.Like I said, that's a whole other discussion IMO.
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 agree, this PR follows the PEP-508, specifically:
but again, I don't think the PEP-508 wanted to allow "non-version" markers (that is
os_name
,sys_platform
,platform_machine
,platform_python_implementation
,platform_system
,implementation_name
and IMHOextra
) to behave like version numbers.cc @rbtcollins
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 see what you mean. That means that the
<marker_op> operators
behaviour would not only be determined by the types of both sides of the expression, but rather the expected types of both sides of the operation. Or rather, the expected type of the "variable".That situation isn't really problematic usually, as each "variable" has an almost predifined type (
python_version
will be a version,sys_platform
will be a string). Withextra
, it can be anything, really, and that's why we end up with a "it'll be evaluated based on what it looks like", which can bring some confusion (like the one I had before reading PEP-508).The thing is, I'm not sure how we can change that behaviour, as when we're evaluationg a marker, we don't know what the "variable" was, we only have it's value. That is, unless we change the implementation quite a bit, and start associating a "type" to every "variable", and keeping that information for evaluation time.
I have a feeling that this is because
extra
might not fit so well as an environment marker, as it's a user provided value. This leads to a few odd behaviour (like this one), and some corner cases (like pypa/pip/issues/4086).(Note that while I spent quite some time lately reading (and re-reading) the PEPs and the various codebase, as well as trying to analyze and understand a lot of this, I don't have the previous and historical knowledge that most of you seem to have, so thanks for taking the time to explain. I promise I'll keep trying to make it worthwile.)
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.
After looking more into the code, I realized that having "Variable Types" wouldn't be as hard as I thought. I have a general idea of how I could implement that.
Here's my suggestion:
Merge this PR, as it fixes a bug that is live, which is that if a package provides extras that are valid version specifiers, the package is uninstalable (pointing back at DistInfoDistribution._compute_dependencies fails if the package has extras_require that are PEP440 versions. pip#4356).
This PR does not actually bring the change that introduced the questionable extra behaviour: If someone, right now with the previous code, creates a
Marker
object likeextra == 3.7.0+youaregreat
and evaluates it with an environment like{'extra': '3.7.0'}
, it would have the behaviour I simply explicited in the tests. This simply never really occured "in the wild" before as the principal (if not only?) use of that is through setuptools/pip, which crashed before that by passing aNone
, which is now fixed.Open an issue and re-launch the discussion on "Is that really the behaviour we intended with PEP 508?", as this PR pointed out there was an edge case with the extras possible values. We can then make the required changes/clarifications to PEP 508 and make the appropriate change to the code to respect the newly defined and written behaviour, if needed. I'll gladly join that discussion, and I'll most likely be ready to help by contributing with a PR for the changes.
If we could come to a conclusion really fast on the previously intended PEP 508 behaviour, I would gladly put it in this PR right away, but as we probably all have lots of things to do, I feel like that discussion will take quite some time, and it would be unfortunate to block a fix to a live bug for that.
Thanks again for your time!
@dstufft @xavfernandez