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.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import logging
  2. from pip._internal.cli.base_command import Command
  3. from pip._internal.operations.check import (
  4. check_package_set, create_package_set_from_installed,
  5. )
  6. logger = logging.getLogger(__name__)
  7. class CheckCommand(Command):
  8. """Verify installed packages have compatible dependencies."""
  9. name = 'check'
  10. usage = """
  11. %prog [options]"""
  12. summary = 'Verify installed packages have compatible dependencies.'
  13. def run(self, options, args):
  14. package_set, parsing_probs = create_package_set_from_installed()
  15. missing, conflicting = check_package_set(package_set)
  16. for project_name in missing:
  17. version = package_set[project_name].version
  18. for dependency in missing[project_name]:
  19. logger.info(
  20. "%s %s requires %s, which is not installed.",
  21. project_name, version, dependency[0],
  22. )
  23. for project_name in conflicting:
  24. version = package_set[project_name].version
  25. for dep_name, dep_version, req in conflicting[project_name]:
  26. logger.info(
  27. "%s %s has requirement %s, but you have %s %s.",
  28. project_name, version, req, dep_name, dep_version,
  29. )
  30. if missing or conflicting or parsing_probs:
  31. return 1
  32. else:
  33. logger.info("No broken requirements found.")