mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Add direct URL accessor
This commit is contained in:
parent
76cd70ac42
commit
da8eee63ad
2 changed files with 11 additions and 0 deletions
|
@ -14,6 +14,7 @@ from typing import (
|
|||
from pip._vendor.packaging.requirements import Requirement
|
||||
from pip._vendor.packaging.version import LegacyVersion, Version
|
||||
|
||||
from pip._internal.models.direct_url import DirectUrl
|
||||
from pip._internal.utils.misc import stdlib_pkgs # TODO: Move definition here.
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
@ -50,6 +51,10 @@ class BaseDistribution(Protocol):
|
|||
def version(self) -> DistributionVersion:
|
||||
raise NotImplementedError()
|
||||
|
||||
@property
|
||||
def direct_url(self) -> Optional[DirectUrl]:
|
||||
raise NotImplementedError()
|
||||
|
||||
@property
|
||||
def installer(self) -> str:
|
||||
raise NotImplementedError()
|
||||
|
|
|
@ -7,7 +7,9 @@ from pip._vendor.packaging.requirements import Requirement
|
|||
from pip._vendor.packaging.utils import canonicalize_name
|
||||
from pip._vendor.packaging.version import parse as parse_version
|
||||
|
||||
from pip._internal.models.direct_url import DirectUrl
|
||||
from pip._internal.utils import misc # TODO: Move definition here.
|
||||
from pip._internal.utils.direct_url_helpers import dist_get_direct_url
|
||||
from pip._internal.utils.packaging import get_installer
|
||||
from pip._internal.utils.wheel import pkg_resources_distribution_for_wheel
|
||||
|
||||
|
@ -45,6 +47,10 @@ class Distribution(BaseDistribution):
|
|||
def version(self) -> DistributionVersion:
|
||||
return parse_version(self._dist.version)
|
||||
|
||||
@property
|
||||
def direct_url(self) -> Optional[DirectUrl]:
|
||||
return dist_get_direct_url(self._dist)
|
||||
|
||||
@property
|
||||
def installer(self) -> str:
|
||||
return get_installer(self._dist)
|
||||
|
|
Loading…
Reference in a new issue