diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2019-10-28 21:52:40 -0400 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2019-10-28 21:52:40 -0400 |
| commit | 3a0520b43dfac9f6ba507c6d09a60290219a0802 (patch) | |
| tree | 1554961d791f0ccae876eec933ff6e678254016a | |
| parent | 2f4952927e41643100e6e6f58124f34331c14add (diff) | |
| download | python-setuptools-git-3a0520b43dfac9f6ba507c6d09a60290219a0802.tar.gz | |
Extract compatibility function into compatibility module.
| -rw-r--r-- | setuptools/_imp.py | 10 | ||||
| -rw-r--r-- | setuptools/py34compat.py | 8 |
2 files changed, 11 insertions, 7 deletions
diff --git a/setuptools/_imp.py b/setuptools/_imp.py index 49ddc852..ee719c9a 100644 --- a/setuptools/_imp.py +++ b/setuptools/_imp.py @@ -8,6 +8,8 @@ import sys import importlib.util import importlib.machinery +from .py34compat import module_from_spec + PY_SOURCE = 1 PY_COMPILED = 2 @@ -63,12 +65,6 @@ def get_frozen_object(module, paths): return spec.loader.get_code(_resolve(module)) -def _module_from_spec(spec): - if sys.version_info >= (3, 5): - return importlib.util.module_from_spec(spec) - else: - return spec.loader.load_module(spec.name) - def get_module(module, paths, info): spec = importlib.util.find_spec(module, paths) - return _module_from_spec(spec) + return module_from_spec(spec) diff --git a/setuptools/py34compat.py b/setuptools/py34compat.py new file mode 100644 index 00000000..bc7eefa9 --- /dev/null +++ b/setuptools/py34compat.py @@ -0,0 +1,8 @@ +import importlib.util + + +try: + module_from_spec = importlib.util.module_from_spec +except AttributeError: + def module_from_spec(spec): + return spec.loader.load_module(spec.name) |
