-
Notifications
You must be signed in to change notification settings - Fork 3k
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
2020 resolver: list out helpful info on basic resolution failures #9405
Conversation
50f6fdc
to
7a5ab7f
Compare
This comment has been minimized.
This comment has been minimized.
Thanks for the PR! Could you also show a sample of how this looks, so that we can discuss the design before we dive into the implementation? |
This comment has been minimized.
This comment has been minimized.
f"Cache dir:\n" | ||
f"{cache_dir or '(not used)'}" | ||
) | ||
logger.warning(diagnostic_hint) |
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 approach lgtm, but the message formatting is much too complicated imo. I would simplify this to something like
Available versions: <list of versions joined by comma>
Sources:
<list of source URLs joined by newline and indented>
Some points to note:
- The project name is already shown in the message directly above and would be duplicated info here.
- Available versions need to be sorted to be readable (they are not right now).
- Showing the cache directory is not useful imo. Cache is only a factor during package build and install, not here.
comes_from
is not necessarily an index page.
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.
Thanks.
The project name is already shown in the message directly above and would be duplicated info here.
Correct. Removed
Available versions need to be sorted to be readable (they are not right now).
Added sorting to versions using distutils.version.LooseVersion
. Indexes are now sorted too, as to ensure that they don't jump around on different runs.
Showing the cache directory is not useful imo.
Yea, I guess even if it was, you might as well just do pip cache info
. Having it in every one of these outputs is just too verbose anyway. I removed it.
comes_from
is not necessarily an index page.
Huh? What else could it be at that point? Replaced Index(es):
with Sources:
.
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.
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.
Instead of making this a separate logging.warning call, I think we should be adding this information to the original logging.critical call.
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.
Added sorting to versions using
distutils.version.LooseVersion
We should use the version type from packaging
. I don't think we should add a dependency on distutils here, as Python core is planning on removing that at some point.
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.
@pfmoore I didn't know about that. Will do.
@pradyunsg The point of doing that was to make it different from the error messages, as - technically - these aren't, and for readability. I can change that too, no problem there.
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.
"Could not find a version, here are the versions" is OK as an error message. I don't think we need to make it look distinct or whatever.
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.
Huh? What else could it be at that point? Replaced
Index(es):
withSources:
.
PackageFinder also looks at find-links pages, which are technically not package indexes.
This reminds me though, we should add a check and display this whole message only when the user did not specify any direct URL requirements on the package. It would be quite confusing IMO if the user specify foo @ git+https://github.com/...
and pip displays this.
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.
@pfmoore Done.
@pradyunsg Done. This is a comparison of the before / after:
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.
@uranusjr The sources section has been removed. Not sure how to go about the foo@git+...
thing though. I was of the impression that it is not possible to get a ResolutionImpossible
exception when doing that.
f"Cache dir:\n" | ||
f"{cache_dir or '(not used)'}" | ||
) | ||
logger.warning(diagnostic_hint) |
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.
"Could not find a version, here are the versions" is OK as an error message. I don't think we need to make it look distinct or whatever.
Also, can I go on record as saying that while reporting the available versions in case of an error is a reasonable thing to do, I am absolutely against making If that functionality is useful (and I can see that it is) then it should be a command in its own right. And invalid requirement specifiers like |
This comment has been minimized.
This comment has been minimized.
@pradyunsg |
e083038
to
d5ce3a0
Compare
@MrMino I'm not going to get into an extended debate on this. I've stated my opinion and I stick by it. Other pip maintainers may differ, and if so we'll come to a consensus at some point. None of which alters the fact that this is useful as diagnostic data after an error. (Which is how I'd prefer to frame this PR). IMO there's no reasonable way to interpret PEP 440 as allowing ¹ Normally, I'd raise a bug report against packaging. I'm not doing so at the moment in this case as I feel that would be needlessly passive-aggressive given that pip users do value this loophole currently. |
@pfmoore I was asking to find a good mental model that would make me understand your position. Alright - I won't go into that here anymore. |
I have no problem with clarifying my thinking if it helps, I just don't intend to try to persuade you if you believe differently 🙂 My model is simple. If people want to find out what versions of Does that help you understand my logic? |
I opened a thread in |
@pfmoore I understand the willingness to make it follow a spec. But I'd say that following the spec ≠ usability of a CLI. It's strange to me that you would prioritize former over the latter, but I guess it's a matter of opinion. Agree to disagree? Anything else I should add to this PR? |
I don't think there's more needed here. And, also, I hate that we constantly hit Hyrum's Law. :) |
This comment has been minimized.
This comment has been minimized.
Apologies, this is the first I'm hearing of Hyrum's Law being considered derogatory. If you would be willing to elaborate/share on why that is, I'd like to know more! :) I thought it applied here because we made a change to an undocumented only-an-implementation-detail behaviour of pip, which broke users (which is what this PR is fixing). On a completely different note, thanks a lot @MrMino for being so receptive on feedback and being, overall, a pleasure to collaborate with so far in this PR! Much appreciated! ^.^ |
@pradyunsg The way I see it, you wouldn't like to tell your son that he's a result of a Murphy's law, it wouldn't be a good PR to tell your contractor that his refactor shows signs of Tesler's law, it wouldn't look good if I told you that your website is a failure in application of Jakob's Law. IMO applications of Hyrum's law as a label should be limited to the places where there's a clear API contract. UX / GUIs / CLIs (for the most part) don't have that.
I'm always surprised to hear this, as to myself I sound like a huge pain in the butt most of the time 😉. Thanks though, appreciated. |
caaf4d9
to
fde5f6f
Compare
Commits squashed, news entry reworded (I'm bad at sticking to my word choices). Should there be anything else to change / add - I'm all ears. Thanks for the reviews, it was a pleasure to work with you guys :). |
Great work @MrMino !
@pradyunsg could you clarify what this bug is about? Is it something that the PR Author should fix or a known bug that is unrelated to the changes? |
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
3017504
to
40df5c2
Compare
In this case, what will become the new approach to trigger this output? |
There isn't one yet, because no-one has proposed an approach or written a PR. |
If you just want a “reasonable hack”, something like |
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
In the new resolver the "(from versions ...)" message, shown on failure to resolve a package, has been removed. This commit brings it back.
40df5c2
to
a2c5794
Compare
One nitpick, the rebase looks good to me. |
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
Good to know, thank you. |
Fixes #9139
Adds the old diagnostic information ("from versions:") to the new resolver.
If there was a failure in resolution of a requirement that stemmed from
a simple fact of there being no candidate found that could possibly
satisfy it, make pip output diagnostic information about which versions
of the package are available to pip (outputs "(none)" if there weren't any).
Note: since
finder.find_all_candidates()
useslru_cache
, this avoids performing additional API calls to PyPI.