aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/_imp.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2019-10-27 20:40:07 -0400
committerJason R. Coombs <jaraco@jaraco.com>2019-10-27 20:40:07 -0400
commit37d617cd983446dfe8073038d03dd31fc7f66796 (patch)
tree1ef8d672406bf7a7cbc600c66b97cd142bd800da /setuptools/_imp.py
parent773f1ec3c2622a78ee0280eb1d2b03c60871c52b (diff)
downloadexternal_python_setuptools-37d617cd983446dfe8073038d03dd31fc7f66796.tar.gz
external_python_setuptools-37d617cd983446dfe8073038d03dd31fc7f66796.tar.bz2
external_python_setuptools-37d617cd983446dfe8073038d03dd31fc7f66796.zip
Extract _resolve
Diffstat (limited to 'setuptools/_imp.py')
-rw-r--r--setuptools/_imp.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/setuptools/_imp.py b/setuptools/_imp.py
index 6bc90243..c400d455 100644
--- a/setuptools/_imp.py
+++ b/setuptools/_imp.py
@@ -60,13 +60,17 @@ def find_module(module, paths=None):
def get_frozen_object(module, paths):
spec = importlib.util.find_spec(module, paths)
- if hasattr(spec, 'submodule_search_locations'):
- spec = importlib.util.spec_from_loader('__init__.py', spec.loader)
- return spec.loader.get_code(module)
+ return spec.loader.get_code(_resolve(module))
+
+
+def _resolve(spec):
+ return (
+ importlib.util.spec_from_loader('__init__.py', spec.loader)
+ if hasattr(spec, 'submodule_search_locations')
+ else spec
+ )
def get_module(module, paths, info):
spec = importlib.util.find_spec(module, paths)
- if hasattr(spec, 'submodule_search_locations'):
- spec = importlib.util.spec_from_loader('__init__.py', spec.loader)
- return importlib.util.module_from_spec(spec)
+ return importlib.util.module_from_spec(_resolve(spec))