aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/namespaces.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-12-07 20:51:36 -0500
committerJason R. Coombs <jaraco@jaraco.com>2016-12-07 20:51:36 -0500
commit7e25fd910d1ff5259c0768d3b54a9bf03bce4279 (patch)
treeef02c4c49b271063b75684bf5e5bbef3ed1eb3a5 /setuptools/namespaces.py
parent1474cf0f7e2b973eb102aef311939228b83e31b6 (diff)
downloadexternal_python_setuptools-7e25fd910d1ff5259c0768d3b54a9bf03bce4279.tar.gz
external_python_setuptools-7e25fd910d1ff5259c0768d3b54a9bf03bce4279.tar.bz2
external_python_setuptools-7e25fd910d1ff5259c0768d3b54a9bf03bce4279.zip
Consider using module_from_spec to create the module.
Diffstat (limited to 'setuptools/namespaces.py')
-rwxr-xr-xsetuptools/namespaces.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py
index cc934b7e..b6720609 100755
--- a/setuptools/namespaces.py
+++ b/setuptools/namespaces.py
@@ -34,12 +34,15 @@ class Installer:
return self.target
_nspkg_tmpl = (
- "import sys, types, os",
+ "import sys, types, os, importlib.util, importlib.machinery",
"pep420 = sys.version_info > (3, 3)",
"p = os.path.join(%(root)s, *%(pth)r)",
"ie = os.path.exists(os.path.join(p,'__init__.py'))",
"m = not ie and not pep420 and "
- "sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))",
+ "sys.modules.setdefault(%(pkg)r, "
+ "importlib.util.module_from_spec("
+ "importlib.machinery.PathFinder.find_spec(%(pkg)r, "
+ "[os.path.dirname(p)])))",
"mp = (m or []) and m.__dict__.setdefault('__path__',[])",
"(p not in mp) and mp.append(p)",
)