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.

candidate.py 1.1KB

12345678910111213141516171819202122232425262728293031
  1. from pip._vendor.packaging.version import parse as parse_version
  2. from pip._internal.utils.models import KeyBasedCompareMixin
  3. from pip._internal.utils.typing import MYPY_CHECK_RUNNING
  4. if MYPY_CHECK_RUNNING:
  5. from pip._vendor.packaging.version import _BaseVersion # noqa: F401
  6. from pip._internal.models.link import Link # noqa: F401
  7. from typing import Any, Union # noqa: F401
  8. class InstallationCandidate(KeyBasedCompareMixin):
  9. """Represents a potential "candidate" for installation.
  10. """
  11. def __init__(self, project, version, location):
  12. # type: (Any, str, Link) -> None
  13. self.project = project
  14. self.version = parse_version(version) # type: _BaseVersion
  15. self.location = location
  16. super(InstallationCandidate, self).__init__(
  17. key=(self.project, self.version, self.location),
  18. defining_class=InstallationCandidate
  19. )
  20. def __repr__(self):
  21. # type: () -> str
  22. return "<InstallationCandidate({!r}, {!r}, {!r})>".format(
  23. self.project, self.version, self.location,
  24. )