-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add a pip check
command.
#3750
Add a pip check
command.
#3750
Conversation
This command ensures that all packages installed have all the requirements they need, and that requirements have compatible versions. This is useful because pip can install incompatible dependencies[1], or a user may have manually (un)installed a package. [1] pypa#775
Maintainers: does this need anything? |
Pinging @xavfernandez @pfmoore @dstufft @njsmith |
|
||
""" | ||
result = script.pip('check') | ||
assert result.stdout == "" |
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.
As a general UI principle, it's probably better if it explicitly says something like "No problems found 👍" instead of just returning with an empty stdout.
Skimmed the code and made one minor comment. Seems like a good idea to me and the tests make sense, but I don't know pip's internals well enough to say definitively, and don't have permissions to merge anyway :-) |
See also #2687 - which is about the underlying cause of this - is it perhaps worth a link to the bug in docs? |
Looks OK to me. I'll leave it a few hours in case any of the other maintainers have any issues, otherwise I'll merge (ping me if I forget :-)) |
Just had a thought, adding a flag to I don't know about the feasibility or the complexity of this but seems like a nice thing to have. |
present_dist = installed_dists_by_name.get(requirement.project_name) | ||
|
||
if present_dist and present_dist not in requirement: | ||
incompatible_requirements.add((requirement, present_dist)) |
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.
incompatible_requirements
is never used?
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.
Apparently yes, this could be removed.
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've taken the work from @Wilfred in #1001 and updated it to work with the latest code on develop and refactored a bit.
This command ensures that all packages installed have all the requirements they need, and that requirements have compatible versions. This is useful because pip can install incompatible dependencies, or a user may have manually (un)installed a package.
It looks like this if everything is okay:
[marca@marca-mac2 pip]$ pip check
[marca@marca-mac2 pip]$ echo $?
0
but if a package is missing:
[marca@marca-mac2 pip]$ pip check
pyramid 1.5.2 requires WebOb, which is not installed.
[marca@marca-mac2 pip]$ echo $?
1
or is the wrong version:
[marca@marca-mac2 pip]$ pip check
pyramid 1.5.2 has requirement WebOb>=1.3.1, but you have WebOb 0.8.
[marca@marca-mac2 pip]$ echo $?
1
This was automatically migrated from #2492 to reparent it to the
master
branch. Please see original pull request for any previous discussion.Original Submitter: @msabramo