|
25 | 25 | from pip._vendor.packaging.requirements import Requirement
|
26 | 26 | from pip._vendor.packaging.specifiers import InvalidSpecifier, SpecifierSet
|
27 | 27 | from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
|
28 |
| -from pip._vendor.packaging.version import LegacyVersion, Version |
| 28 | +from pip._vendor.packaging.version import Version |
29 | 29 |
|
30 | 30 | from pip._internal.exceptions import NoneMetadataError
|
31 | 31 | from pip._internal.locations import site_packages, user_site
|
|
41 | 41 |
|
42 | 42 | from ._json import msg_to_json
|
43 | 43 |
|
44 |
| -DistributionVersion = Union[LegacyVersion, Version] |
45 |
| - |
46 | 44 | InfoPath = Union[str, pathlib.PurePath]
|
47 | 45 |
|
48 | 46 | logger = logging.getLogger(__name__)
|
@@ -140,10 +138,10 @@ def from_wheel(cls, wheel: "Wheel", name: str) -> "BaseDistribution":
|
140 | 138 | raise NotImplementedError()
|
141 | 139 |
|
142 | 140 | def __repr__(self) -> str:
|
143 |
| - return f"{self.raw_name} {self.version} ({self.location})" |
| 141 | + return f"{self.raw_name} {self.raw_version} ({self.location})" |
144 | 142 |
|
145 | 143 | def __str__(self) -> str:
|
146 |
| - return f"{self.raw_name} {self.version}" |
| 144 | + return f"{self.raw_name} {self.raw_version}" |
147 | 145 |
|
148 | 146 | @property
|
149 | 147 | def location(self) -> Optional[str]:
|
@@ -274,7 +272,11 @@ def canonical_name(self) -> NormalizedName:
|
274 | 272 | raise NotImplementedError()
|
275 | 273 |
|
276 | 274 | @property
|
277 |
| - def version(self) -> DistributionVersion: |
| 275 | + def version(self) -> Version: |
| 276 | + raise NotImplementedError() |
| 277 | + |
| 278 | + @property |
| 279 | + def raw_version(self) -> str: |
278 | 280 | raise NotImplementedError()
|
279 | 281 |
|
280 | 282 | @property
|
@@ -443,24 +445,19 @@ def iter_dependencies(self, extras: Collection[str] = ()) -> Iterable[Requiremen
|
443 | 445 | """
|
444 | 446 | raise NotImplementedError()
|
445 | 447 |
|
446 |
| - def iter_provided_extras(self) -> Iterable[str]: |
| 448 | + def iter_raw_dependencies(self) -> Iterable[str]: |
| 449 | + """Raw Requires-Dist metadata.""" |
| 450 | + return self.metadata.get_all("Requires-Dist", []) |
| 451 | + |
| 452 | + def iter_provided_extras(self) -> Iterable[NormalizedName]: |
447 | 453 | """Extras provided by this distribution.
|
448 | 454 |
|
449 | 455 | For modern .dist-info distributions, this is the collection of
|
450 | 456 | "Provides-Extra:" entries in distribution metadata.
|
451 | 457 |
|
452 |
| - The return value of this function is not particularly useful other than |
453 |
| - display purposes due to backward compatibility issues and the extra |
454 |
| - names being poorly normalized prior to PEP 685. If you want to perform |
455 |
| - logic operations on extras, use :func:`is_extra_provided` instead. |
456 |
| - """ |
457 |
| - raise NotImplementedError() |
458 |
| - |
459 |
| - def is_extra_provided(self, extra: str) -> bool: |
460 |
| - """Check whether an extra is provided by this distribution. |
461 |
| -
|
462 |
| - This is needed mostly for compatibility issues with pkg_resources not |
463 |
| - following the extra normalization rules defined in PEP 685. |
| 458 | + The return value of this function is expected to be normalised names, |
| 459 | + per PEP 685, with the returned value being handled appropriately by |
| 460 | + `iter_dependencies`. |
464 | 461 | """
|
465 | 462 | raise NotImplementedError()
|
466 | 463 |
|
|
0 commit comments