aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/_imp.py
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/_imp.py')
-rw-r--r--setuptools/_imp.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/setuptools/_imp.py b/setuptools/_imp.py
index a3cce9b2..451e45a8 100644
--- a/setuptools/_imp.py
+++ b/setuptools/_imp.py
@@ -17,9 +17,18 @@ C_BUILTIN = 6
PY_FROZEN = 7
+def find_spec(module, paths):
+ finder = (
+ importlib.machinery.PathFinder().find_spec
+ if isinstance(paths, list) else
+ importlib.util.find_spec
+ )
+ return finder(module, paths)
+
+
def find_module(module, paths=None):
"""Just like 'imp.find_module()', but with package support"""
- spec = importlib.util.find_spec(module, paths)
+ spec = find_spec(module, paths)
if spec is None:
raise ImportError("Can't find %s" % module)
if not spec.has_location and hasattr(spec, 'submodule_search_locations'):
@@ -60,14 +69,14 @@ def find_module(module, paths=None):
def get_frozen_object(module, paths=None):
- spec = importlib.util.find_spec(module, paths)
+ spec = find_spec(module, paths)
if not spec:
raise ImportError("Can't find %s" % module)
return spec.loader.get_code(module)
def get_module(module, paths, info):
- spec = importlib.util.find_spec(module, paths)
+ spec = find_spec(module, paths)
if not spec:
raise ImportError("Can't find %s" % module)
return module_from_spec(spec)