-
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.
#2492
Add a pip check
command.
#2492
Conversation
This is super useful taking into account that pip does not resolve dependencies (#988). |
Quite nice to see it in pip :) A missing (maybe optional) feature would be to show the possible reason for a wrong version. Our internal tool outputs something like:
which is useful to easily find the culprit. |
Tests are failing on Python 3. I'll try to fix this later. |
#1946 is kind of in the same vein, but a different spin. |
d9195ad
to
e7f8afe
Compare
OK, I think e7f8afe should fix the Python 3 failures. |
Can this be implemented as an external command? And if not, why not? To me this seems like a classic use case for a plugin command (see #1409 and #2329). I'm reluctant to keep adding more and more pip subcommands to the core, and yet without a better understanding of why standalone commands aren't feasible it's hard to justify adding a plugin system. One key potential objection to an external command is that pip has no public API to allow external tools to interact with it - but that applies to plugins and core commands as well. Internal API changes could break plugins just as easily as external commands, and adding a command to the core just pushes the maintenance burden of dealing with internal API changes onto the core devs (the command still breaks, but everyone expects us to fix it then). Any other reasons this can't be an external command? (I'm looking for good arguments in favour of a plugin system and/or adding a new core command, not objecting to the PR itself, btw...) |
This can definitely be implemented as an external command (and already is) but I think it would make sense if pip directly provided this command. |
It's already surprising to many that pip does not resolve dependencies. In addition having no way to check if dependencies are correctly installed (if only after the fact) would force users to check things manually or look for some external tool. Making sure dependencies are satisfied is the core competency of installer/package manager thus I don't see why it shouldn't be included in pip itself. |
Another reason for not making it an external command is that I was imagining that in the future (i.e.: not in this PR), the code in Example: How about if
Today they can uninstall
Another possible use is a command for removing orphaned packages -- e.g.: a pip analogue of
e.g.:
|
So you're actually proposing a "check requirements" API (plus a convenience CLI interface to it)? That's somewhat different, and does sound interesting. But I'd rather see the API properly designed in that case, not just put in an "pip.operations" submodule. Unless we start factoring out reusable APIs, we never get any closer to having a pip API that people (both 3rd party and internal) can rely on. Would you be willing to refactor this PR into a check API (with proper docs,unit tests and in a suitable namespace)? I'm not promising that doing that would mean it'd get merged, just that it would be useful (to me at least) to see what the start of a gradual migration to a documented API might look like. |
I guess I was proposing that without even realizing it :) Probably not this week though. I wonder if maintainers would be amenable to merging this PR as-is, or with minor refinements and then then I'll submit another at a later date for the API? I just fear that coming up with a good API could balloon into a big task and discussion and it might be good to "cash in" now and get some incremental progress before this gets lost in the shuffle. |
|
||
|
||
def test_check_missing_dependency_normalize_case(script): | ||
# this will also install ipython, a dependency |
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 appreciate this comment is probably my fault, but it's a copy-paste error :)
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.
Indeed. Thanks! Just updated.
Fantastic, thanks for working on this. I think this would be a big improvement as it would enable users to check their virtualenvs are consistent. This feature would be useful today -- what would the fine pip maintainers like to see, in order to get this merged? |
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
e7f8afe
to
76c3561
Compare
+1 |
👍 This PR is unintrusive to existing codebase, code is clean, it holds big potential, and comes with a test. Also, it should definitely be a core feature as it can be used to test that other commands perform as expected. |
This would be really useful for us. 👍 |
Any blockers for merging this PR? |
How's this going? |
Accidentally closed this, reopening. Sorry! |
Well done. |
Hello! As part of an effort to ease the contribution process and adopt a more standard workflow pip has switched to doing development on the If you do nothing, this Pull Request will be automatically migrated by @BrownTruck for you. If you would like to retain control over this pull request then you should resubmit it against the If you choose to migrate this Pull Request yourself, here is an example message that you can copy and paste:
If this pull request is no longer needed, please feel free to close it. |
This Pull Request has been automatically migrated to #3750 to reparent it to the |
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:
but if a package is missing:
or is the wrong version: