Skip to content

Commit ecbaaa1

Browse files
Revert "Remove the dependency on pkg_resources and hence setuptools on python>=3.10"
This reverts commit b29b580.
1 parent e512718 commit ecbaaa1

1 file changed

Lines changed: 5 additions & 21 deletions

File tree

src/wrapt/importer.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,36 +82,20 @@ def register_post_import_hook(hook, name):
8282

8383
def _create_import_hook_from_entrypoint(entrypoint):
8484
def import_hook(module):
85-
entrypoint_value = entrypoint.value.split(":")
86-
module_name = entrypoint_value[0]
87-
__import__(module_name)
88-
callback = sys.modules[module_name]
89-
90-
if len(entrypoint_value) > 1:
91-
attrs = entrypoint_value[1].split(".")
92-
for attr in attrs:
93-
callback = getattr(callback, attr)
94-
return callback(module)
95-
96-
def import_hook_legacy(module):
9785
__import__(entrypoint.module_name)
9886
callback = sys.modules[entrypoint.module_name]
9987
for attr in entrypoint.attrs:
10088
callback = getattr(callback, attr)
10189
return callback(module)
102-
103-
if sys.version_info < (3, 10):
104-
return import_hook_legacy
10590
return import_hook
10691

10792
def discover_post_import_hooks(group):
108-
if sys.version_info >= (3, 10):
109-
from importlib.metadata import entry_points
110-
else:
111-
from pkg_resources import iter_entry_points as entry_points
93+
try:
94+
import pkg_resources
95+
except ImportError:
96+
return
11297

113-
for entrypoint in entry_points(group=group):
114-
entrypoint.load()
98+
for entrypoint in pkg_resources.iter_entry_points(group=group):
11599
callback = _create_import_hook_from_entrypoint(entrypoint)
116100
register_post_import_hook(callback, entrypoint.name)
117101

0 commit comments

Comments
 (0)