You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

check.py 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # The following comment should be removed at some point in the future.
  2. # mypy: disallow-untyped-defs=False
  3. import logging
  4. from pip._internal.cli.base_command import Command
  5. from pip._internal.operations.check import (
  6. check_package_set,
  7. create_package_set_from_installed,
  8. )
  9. from pip._internal.utils.misc import write_output
  10. logger = logging.getLogger(__name__)
  11. class CheckCommand(Command):
  12. """Verify installed packages have compatible dependencies."""
  13. usage = """
  14. %prog [options]"""
  15. def run(self, options, args):
  16. package_set, parsing_probs = create_package_set_from_installed()
  17. missing, conflicting = check_package_set(package_set)
  18. for project_name in missing:
  19. version = package_set[project_name].version
  20. for dependency in missing[project_name]:
  21. write_output(
  22. "%s %s requires %s, which is not installed.",
  23. project_name, version, dependency[0],
  24. )
  25. for project_name in conflicting:
  26. version = package_set[project_name].version
  27. for dep_name, dep_version, req in conflicting[project_name]:
  28. write_output(
  29. "%s %s has requirement %s, but you have %s %s.",
  30. project_name, version, req, dep_name, dep_version,
  31. )
  32. if missing or conflicting or parsing_probs:
  33. return 1
  34. else:
  35. write_output("No broken requirements found.")