aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/py27compat.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-02-11 22:15:31 -0500
committerJason R. Coombs <jaraco@jaraco.com>2020-02-11 22:15:31 -0500
commitce8e3ee174ed9dee84aa08a461fb174ac1e53535 (patch)
treeda78c024b4491210e61b73e9e2f755d46c8bc1ff /setuptools/py27compat.py
parent53b8523fdfa19173d2e6b11d6b4d175f54b9dfea (diff)
parenta5dec2f14e3414e4ee5dd146bff9c289d573de9a (diff)
downloadexternal_python_setuptools-ce8e3ee174ed9dee84aa08a461fb174ac1e53535.tar.gz
external_python_setuptools-ce8e3ee174ed9dee84aa08a461fb174ac1e53535.tar.bz2
external_python_setuptools-ce8e3ee174ed9dee84aa08a461fb174ac1e53535.zip
Merge branch 'master' into fix/1557
Diffstat (limited to 'setuptools/py27compat.py')
-rw-r--r--setuptools/py27compat.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/setuptools/py27compat.py b/setuptools/py27compat.py
index 2985011b..ba39af52 100644
--- a/setuptools/py27compat.py
+++ b/setuptools/py27compat.py
@@ -2,6 +2,7 @@
Compatibility Support for Python 2.7 and earlier
"""
+import sys
import platform
from setuptools.extern import six
@@ -15,7 +16,7 @@ def get_all_headers(message, key):
if six.PY2:
- def get_all_headers(message, key):
+ def get_all_headers(message, key): # noqa
return message.getheaders(key)
@@ -26,3 +27,34 @@ linux_py2_ascii = (
rmtree_safe = str if linux_py2_ascii else lambda x: x
"""Workaround for http://bugs.python.org/issue24672"""
+
+
+try:
+ from ._imp import find_module, PY_COMPILED, PY_FROZEN, PY_SOURCE
+ from ._imp import get_frozen_object, get_module
+except ImportError:
+ import imp
+ from imp import PY_COMPILED, PY_FROZEN, PY_SOURCE # noqa
+
+ def find_module(module, paths=None):
+ """Just like 'imp.find_module()', but with package support"""
+ parts = module.split('.')
+ while parts:
+ part = parts.pop(0)
+ f, path, (suffix, mode, kind) = info = imp.find_module(part, paths)
+
+ if kind == imp.PKG_DIRECTORY:
+ parts = parts or ['__init__']
+ paths = [path]
+
+ elif parts:
+ raise ImportError("Can't find %r in %s" % (parts, module))
+
+ return info
+
+ def get_frozen_object(module, paths):
+ return imp.get_frozen_object(module)
+
+ def get_module(module, paths, info):
+ imp.load_module(module, *info)
+ return sys.modules[module]