Path: blob/main/test/lib/python3.9/site-packages/pip/_internal/commands/check.py
4804 views
import logging1from optparse import Values2from typing import List34from pip._internal.cli.base_command import Command5from pip._internal.cli.status_codes import ERROR, SUCCESS6from pip._internal.operations.check import (7check_package_set,8create_package_set_from_installed,9)10from pip._internal.utils.misc import write_output1112logger = logging.getLogger(__name__)131415class CheckCommand(Command):16"""Verify installed packages have compatible dependencies."""1718usage = """19%prog [options]"""2021def run(self, options: Values, args: List[str]) -> int:2223package_set, parsing_probs = create_package_set_from_installed()24missing, conflicting = check_package_set(package_set)2526for project_name in missing:27version = package_set[project_name].version28for dependency in missing[project_name]:29write_output(30"%s %s requires %s, which is not installed.",31project_name,32version,33dependency[0],34)3536for project_name in conflicting:37version = package_set[project_name].version38for dep_name, dep_version, req in conflicting[project_name]:39write_output(40"%s %s has requirement %s, but you have %s %s.",41project_name,42version,43req,44dep_name,45dep_version,46)4748if missing or conflicting or parsing_probs:49return ERROR50else:51write_output("No broken requirements found.")52return SUCCESS535455