-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Validate platforms #12241
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
Closed
Closed
Validate platforms #12241
Conversation
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
I'm going to put this back up once I can get testing to work fully! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #6369
This pr adds two bits of functionality:
1. adds validation on user submitted platform tags
Within Issue #6369 was a request to add "error message when the user provides something wrong to any of those (platforms, implementation, python_version, abi) flags. It would be helpful to provide the user’s platform default as an example input." This pr attempts to resolve this for platform tags and set up a simple system to add messages for the remaining flags.
As suggested in issue #6369, the call to validation occurs in the common base class to
DownloadCommand
andInstallCommand
, namely theCommand
class. The other base classes (RequirementCommand
,IndexGroupCommand
, andSessionCommandMixin
) did not provide appropriate context or opportunity to serve as the place to initiate these checks on the platform tags. The functions that perform the validation are added to cmdoptions.py because this seemed like the most logical place to have them. You'll note that first a function namedvalidate_user_options
is called. This is because additional functionality (as discussed in the issue) will be called through this (specifically to check implementation and abi user options). Though the issue calls for an 'error' message, I wasn't sure if this was literal. I decided to make this provide awarning
via thelogger
, especially given that a) it provided for more flexibility for non-standard packages that may exist and b) faulty input for this tag should, as far as I can tell, have no downstream problems since a user will either get exactly what they want or will get the next best package available.The main functionality is found in
validate_platform_options
. The main sources of information used to generate the logic here were PEPs 425, 513, 571, 599, and 600. I outline the reasoning for some of the less obvious approaches used.There is a second pr that will be either already up or up soon that adds validation for
--implementation
.Regarding testing. I added a test that should, seemingly work, but could not figure out how to do it!! Beyond running nox, I did local testing with execution of the installed pip to ensure expected behavior.
Final (skippable) note: pip give an
ERROR
when no matching package is found. The error is vague in that it does not give the exact reason a package could not be found (implementation v platform v abi v etc). However, adding detail here seemed very involved and poor place to add this particular functionality without worrying about all the other potential causes.2. extends platform help text to include suggestions for valid platform tags
I noticed that some other options (e.g.
implementation
andpython_version
) had help text that provided examples, but that the help text forplatform
did not. I went ahead and added some common examples.