Skip to content

Commit ac21807

Browse files
committed
Remove support for installed eggs distributions
1 parent 06c8024 commit ac21807

File tree

2 files changed

+1
-55
lines changed

2 files changed

+1
-55
lines changed

news/12308.removal.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove support for discovering installed ``egg`` distributions, on Python 3.11+.

src/pip/_internal/metadata/importlib/_envs.py

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import functools
21
import importlib.metadata
32
import logging
43
import os
54
import pathlib
65
import sys
76
import zipfile
8-
import zipimport
97
from typing import Iterator, List, Optional, Sequence, Set, Tuple
108

119
from pip._vendor.packaging.utils import (
@@ -16,7 +14,6 @@
1614
)
1715

1816
from pip._internal.metadata.base import BaseDistribution, BaseEnvironment
19-
from pip._internal.utils.deprecation import deprecated
2017
from pip._internal.utils.filetypes import WHEEL_EXTENSION
2118

2219
from ._compat import BadMetadata, BasePath, get_dist_canonical_name, get_info_location
@@ -112,54 +109,6 @@ def find_linked(self, location: str) -> Iterator[BaseDistribution]:
112109
for dist, info_location in self._find_impl(target_location):
113110
yield Distribution(dist, info_location, path)
114111

115-
def _find_eggs_in_dir(self, location: str) -> Iterator[BaseDistribution]:
116-
from pip._vendor.pkg_resources import find_distributions
117-
118-
from pip._internal.metadata import pkg_resources as legacy
119-
120-
with os.scandir(location) as it:
121-
for entry in it:
122-
if not entry.name.endswith(".egg"):
123-
continue
124-
for dist in find_distributions(entry.path):
125-
yield legacy.Distribution(dist)
126-
127-
def _find_eggs_in_zip(self, location: str) -> Iterator[BaseDistribution]:
128-
from pip._vendor.pkg_resources import find_eggs_in_zip
129-
130-
from pip._internal.metadata import pkg_resources as legacy
131-
132-
try:
133-
importer = zipimport.zipimporter(location)
134-
except zipimport.ZipImportError:
135-
return
136-
for dist in find_eggs_in_zip(importer, location):
137-
yield legacy.Distribution(dist)
138-
139-
def find_eggs(self, location: str) -> Iterator[BaseDistribution]:
140-
"""Find eggs in a location.
141-
142-
This actually uses the old *pkg_resources* backend. We likely want to
143-
deprecate this so we can eventually remove the *pkg_resources*
144-
dependency entirely. Before that, this should first emit a deprecation
145-
warning for some versions when using the fallback since importing
146-
*pkg_resources* is slow for those who don't need it.
147-
"""
148-
if os.path.isdir(location):
149-
yield from self._find_eggs_in_dir(location)
150-
if zipfile.is_zipfile(location):
151-
yield from self._find_eggs_in_zip(location)
152-
153-
154-
@functools.lru_cache(maxsize=None) # Warn a distribution exactly once.
155-
def _emit_egg_deprecation(location: Optional[str]) -> None:
156-
deprecated(
157-
reason=f"Loading egg at {location} is deprecated.",
158-
replacement="to use pip for package installation",
159-
gone_in="25.1",
160-
issue=12330,
161-
)
162-
163112

164113
class Environment(BaseEnvironment):
165114
def __init__(self, paths: Sequence[str]) -> None:
@@ -179,10 +128,6 @@ def _iter_distributions(self) -> Iterator[BaseDistribution]:
179128
finder = _DistributionFinder()
180129
for location in self._paths:
181130
yield from finder.find(location)
182-
if sys.version_info < (3, 14):
183-
for dist in finder.find_eggs(location):
184-
_emit_egg_deprecation(dist.location)
185-
yield dist
186131
# This must go last because that's how pkg_resources tie-breaks.
187132
yield from finder.find_linked(location)
188133

0 commit comments

Comments
 (0)