-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
Deduplicate Platform
and PlatformConstraint
#11157
Merged
Eric-Arellano
merged 3 commits into
pantsbuild:master
from
Eric-Arellano:platform-constraint
Nov 12, 2020
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
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
Oops, something went wrong.
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.
This was baked into PlatformConstraint previously, but it does seem odd to have a single field with optionality baked in here. At use sites this reads "I have a required field ... but that (wrapped) field is optional." It would seem the same could be achieved with no loss of clarity by having the use site just say its an Option doing away with this type altogether. Maybe more knobs were planned for a
PlatformConstraint
but never materialized?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.
Very true. I'd be happy to remove
PlatformConstraint
and make itOptional[Platform]
at call sites.It looks like we're not using
PlatformConstraint
in any@rules
as a param, so no need to "newtype" it.Any context we're missing @stuhood @hrfuller?
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 ended up putting the context on the main PR thread rather than here... so yea, can refer to that. IIRC,
Platform
was a concrete single platform, whilePlatformConstraint
was meant to select multiplePlatform
s.I think that pushing further the PEP425 parallel while working on https://docs.google.com/document/d/1fFjMlQ7fLKsq3bomaoDoNgMxL2zMZPiqk0wjqZX8AFM/edit#heading=h.pquqi3lvc4go might be useful... @jsirois would know better, but my understanding of the PEP425 tags is that when they are partially specified they represent a set of platforms that share the specified portion of the tag. So not a range, per-se... more like a prefix match maybe? So a partially specified tag is like a
PlatformConstraint
, and a fully specified tag is like aPlatform
.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.
@stuhood that's how things work in spirit, but you cannot actually partially specify a tag, it must be a complete tag. That tag can contain elements that make it looser though like
any
andnone
in certain slots. For the python ecosystem, the flecibility is provided by platform sets. The match within a set must be exact, but the set itself contains both exact platform matches and looser ones too. Unfortunately the logic for generating the sets is not codified in any PEP I know and the defacto standard only exists in https://github.com/pypa/packaging/blob/master/packaging/tags.py#L805.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.
The idea was to have a concrete type to wrap a value of None to indicate that no platform constraint was applied. The ergonomics of that were supposed to be that None could be confusing by itself as the platform constraint, but in retrospect the class doesn't offer much beside a nicer name around None. I'm fine with the simplification as the intended purpose doesn't seem to have been clear anyway.