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

Prevent the use of PIP_NO_USE_PEP517 to head off user confusion #6134

Merged
merged 2 commits into from
Jan 19, 2019

Conversation

cjerdonek
Copy link
Member

This PR is a follow-up to PR #5743 (the PEP 517 PR). I'm hoping it can be merged in the same release that PEP 517 goes out since for backwards compatibility reasons we might not be able to merge it afterwards.

This PR addresses an issue I raised with that PR and discussed with @pfmoore in that issue. He and I agreed I would take care of it: #5743 (comment)

Basically, the change is to prevent from happening with the new --no-use-pep517 option a confusion that happened in the past with certain other "no" options (like --no-cache-dir): #5735
Namely, without this PR, someone can pass PIP_NO_USE_PEP517=true, and it will result in options.use_pep517 being True instead of False, which is what one would logically expect.

This PR prevents this by not allowing the environment variable PIP_NO_USE_PEP517 to be used. Instead, it instructs the user to use an appropriate value for PIP_USE_PEP517. Here is what the output looks like:

$ PIP_NO_USE_PEP517=true pip download xxx

Usage:   
  pip download [options] <requirement specifier> [package-index-options] ...
  pip download [options] -r <requirements file> [package-index-options] ...
  pip download [options] <vcs project url> ...
  pip download [options] <local project path> ...
  pip download [options] <archive url/path> ...

--no-use-pep517 error: A value was passed for --no-use-pep517,
probably using either the PIP_NO_USE_PEP517 environment variable or
the "no-use-pep517" config file option. Use an appropriate value of
the PIP_USE_PEP517 environment variable or the "use-pep517" config
file option instead.

The PR also improves handling of the corresponding --no-cache-dir scenario by raising a parser error instead of a ValueError, since I noticed that while implementing this PR. This results in a better error message display. Instead of a ValueError stack trace, the user will get this:

$ PIP_NO_CACHE_DIR=invalid pip list

Usage:   
  pip <command> [options]

--no-cache-dir error: invalid truth value 'invalid'

After this PR, it shouldn't be too hard also to address @pradyunsg's suggestions that he made here:
#5743 (comment)
since this PR sets up the option callback and tests, etc, needed for his suggestion.

@cjerdonek cjerdonek added C: configuration Configuration management and loading skip news Does not need a NEWS file entry (eg: trivial changes) C: PEP 517 impact Affected by PEP 517 processing C: cli Command line interface related things (optparse, option grouping etc) labels Jan 14, 2019
@cjerdonek cjerdonek added this to the 19.0 milestone Jan 14, 2019
@pradyunsg
Copy link
Member

Could you add a release blocker label to this? (on my mobile)

@cjerdonek cjerdonek added the !release blocker Hold a release until this is resolved label Jan 14, 2019
@cjerdonek
Copy link
Member Author

Done!

@cjerdonek
Copy link
Member Author

By the way, the unit tests I added reveal that use_pep517 will be 0 or 1 rather than True or False if the option is invoked via an environment variable or config file option rather than the command-line option. This is because the strtobool() function that the parser uses returns 0 or 1 rather than True or False. However, the main part of the code uses is rather than == when deciding whether use_pep517 has been specified, e.g. here:

if use_pep517 is False:

And here:
if use_pep517 is False:

I don't know if there are other places that the code distinguishes between 0 and False, etc.

@cjerdonek
Copy link
Member Author

If the if use_pep517 is False: lines are changed to if use_pep517 is not None and not use_pep517:, it looks like that might be sufficient to address the issue. It seems like that change would be good in any case. That way use_pep517=0 and use_pep517=False will result in the same behavior.

@pradyunsg pradyunsg requested a review from pfmoore January 14, 2019 15:26
@pradyunsg
Copy link
Member

Pinging @pfmoore for comments on this. :)

@pfmoore
Copy link
Member

pfmoore commented Jan 14, 2019

I'll try to get some time to review, but I'm super busy at the moment, so it may be a while. Please don't hold the release on the basis of waiting for me to have free time. Sorry! (I agree with @cjerdonek that it would be nice for this to go in alongside the PEP 517 change, though).

@pradyunsg
Copy link
Member

Please don't hold the release on the basis of waiting for me to have free time.

Roger that! I'll try to do a review on this myself, later this week.

Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@cjerdonek cjerdonek merged commit f982845 into pypa:master Jan 19, 2019
@cjerdonek cjerdonek deleted the pip-no-use-pep517 branch January 19, 2019 21:08
@pradyunsg pradyunsg removed !release blocker Hold a release until this is resolved labels Feb 8, 2019
@lock
Copy link

lock bot commented May 29, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: cli Command line interface related things (optparse, option grouping etc) C: configuration Configuration management and loading C: PEP 517 impact Affected by PEP 517 processing skip news Does not need a NEWS file entry (eg: trivial changes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants