Skip to content

Commit

Permalink
Remove support for installed eggs distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Oct 1, 2023
1 parent f6b445b commit baf7f70
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
1 change: 1 addition & 0 deletions news/12308.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove support for discovering installed ``egg`` distributions.
28 changes: 0 additions & 28 deletions src/pip/_internal/metadata/importlib/_envs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import functools
import importlib.metadata
import logging
import os
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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)

Expand Down

0 comments on commit baf7f70

Please sign in to comment.