aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/namespaces.py
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/namespaces.py')
-rwxr-xr-xsetuptools/namespaces.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py
index cc934b7e..dc16106d 100755
--- a/setuptools/namespaces.py
+++ b/setuptools/namespaces.py
@@ -30,15 +30,29 @@ class Installer:
with open(filename, 'wt') as f:
f.writelines(lines)
+ def uninstall_namespaces(self):
+ filename, ext = os.path.splitext(self._get_target())
+ filename += self.nspkg_ext
+ if not os.path.exists(filename):
+ return
+ log.info("Removing %s", filename)
+ os.remove(filename)
+
def _get_target(self):
return self.target
_nspkg_tmpl = (
"import sys, types, os",
- "pep420 = sys.version_info > (3, 3)",
+ "has_mfs = sys.version_info > (3, 5)",
"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 "
+ "importlib = has_mfs and __import__('importlib.util')",
+ "has_mfs and __import__('importlib.machinery')",
+ "m = has_mfs and "
+ "sys.modules.setdefault(%(pkg)r, "
+ "importlib.util.module_from_spec("
+ "importlib.machinery.PathFinder.find_spec(%(pkg)r, "
+ "[os.path.dirname(p)])))",
+ "m = m or "
"sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))",
"mp = (m or []) and m.__dict__.setdefault('__path__',[])",
"(p not in mp) and mp.append(p)",