python (3.11.7)
       1  import logging
       2  from optparse import Values
       3  from typing import List
       4  
       5  from pip._internal.cli.base_command import Command
       6  from pip._internal.cli.status_codes import ERROR, SUCCESS
       7  from pip._internal.operations.check import (
       8      check_package_set,
       9      create_package_set_from_installed,
      10      warn_legacy_versions_and_specifiers,
      11  )
      12  from pip._internal.utils.misc import write_output
      13  
      14  logger = logging.getLogger(__name__)
      15  
      16  
      17  class ESC[4;38;5;81mCheckCommand(ESC[4;38;5;149mCommand):
      18      """Verify installed packages have compatible dependencies."""
      19  
      20      usage = """
      21        %prog [options]"""
      22  
      23      def run(self, options: Values, args: List[str]) -> int:
      24          package_set, parsing_probs = create_package_set_from_installed()
      25          warn_legacy_versions_and_specifiers(package_set)
      26          missing, conflicting = check_package_set(package_set)
      27  
      28          for project_name in missing:
      29              version = package_set[project_name].version
      30              for dependency in missing[project_name]:
      31                  write_output(
      32                      "%s %s requires %s, which is not installed.",
      33                      project_name,
      34                      version,
      35                      dependency[0],
      36                  )
      37  
      38          for project_name in conflicting:
      39              version = package_set[project_name].version
      40              for dep_name, dep_version, req in conflicting[project_name]:
      41                  write_output(
      42                      "%s %s has requirement %s, but you have %s %s.",
      43                      project_name,
      44                      version,
      45                      req,
      46                      dep_name,
      47                      dep_version,
      48                  )
      49  
      50          if missing or conflicting or parsing_probs:
      51              return ERROR
      52          else:
      53              write_output("No broken requirements found.")
      54              return SUCCESS