From dc58216bfac0d1db66679842b7d09e8e46a975a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sun, 1 Oct 2023 15:17:13 +0200 Subject: [PATCH] Remove support for installed eggs distributions --- src/pip/_internal/metadata/importlib/_envs.py | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/src/pip/_internal/metadata/importlib/_envs.py b/src/pip/_internal/metadata/importlib/_envs.py index 3850ddaf412..40bea71403b 100644 --- a/src/pip/_internal/metadata/importlib/_envs.py +++ b/src/pip/_internal/metadata/importlib/_envs.py @@ -1,4 +1,3 @@ -import functools import importlib.metadata import logging import os @@ -12,7 +11,6 @@ from pip._internal.metadata.base import BaseDistribution, BaseEnvironment from pip._internal.models.wheel import Wheel -from pip._internal.utils.deprecation import deprecated from pip._internal.utils.filetypes import WHEEL_EXTENSION from ._compat import BadMetadata, BasePath, get_dist_name, get_info_location @@ -131,29 +129,6 @@ def _find_eggs_in_zip(self, location: str) -> Iterator[BaseDistribution]: for dist in find_eggs_in_zip(importer, location): yield legacy.Distribution(dist) - def find_eggs(self, location: str) -> Iterator[BaseDistribution]: - """Find eggs in a location. - - This actually uses the old *pkg_resources* backend. We likely want to - deprecate this so we can eventually remove the *pkg_resources* - dependency entirely. Before that, this should first emit a deprecation - warning for some versions when using the fallback since importing - *pkg_resources* is slow for those who don't need it. - """ - if os.path.isdir(location): - yield from self._find_eggs_in_dir(location) - if zipfile.is_zipfile(location): - yield from self._find_eggs_in_zip(location) - - -@functools.lru_cache(maxsize=None) # Warn a distribution exactly once. -def _emit_egg_deprecation(location: Optional[str]) -> None: - deprecated( - reason=f"Loading egg at {location} is deprecated.", - replacement="to use pip for package installation.", - gone_in="23.3", - ) - class Environment(BaseEnvironment): def __init__(self, paths: Sequence[str]) -> None: @@ -173,9 +148,6 @@ def _iter_distributions(self) -> Iterator[BaseDistribution]: finder = _DistributionFinder() for location in self._paths: yield from finder.find(location) - for dist in finder.find_eggs(location): - _emit_egg_deprecation(dist.location) - yield dist # This must go last because that's how pkg_resources tie-breaks. yield from finder.find_linked(location)