Report install errors and failures in JSON format#14083
Open
Vishvendra47 wants to merge 3 commits into
Open
Conversation
Author
|
pre-commit.ci autofix |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR addresses issue #11316 by ensuring that when
pip installis executed with the--reportoption, any installation or dependency resolution errors are outputted in JSON format instead of terminating with plain text logs on stdout.Changes
src/pip/_internal/commands/install.py:requirement_set = Nonebefore the installation try-block.(InstallationError, CommandError, InstallWheelBuildError).--reportis specified, the handler creates anInstallationReport(with whatever requirements were parsed up to that point), converts it to a dictionary, injects anerrordictionary containingcode(the exception class name) anddescription(the error message), outputs it (to stdout or a file), and then re-raises the exception.tests/functional/test_install_report.py:test_install_report_errorandtest_install_report_error_stdoutto verify the error reporting output.news/11316.feature.rstnews fragment file.Output Example
Running
pip install "pip-tools==6.8.0" "pip==20.1" --dry-run --report -now outputs:{ "version": "1", "pip_version": "26.2.dev0", "install": [], "environment": { ... }, "error": { "code": "DistributionNotFound", "description": "ResolutionImpossible: ..." } }