diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2016-12-11 16:02:14 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2016-12-11 16:02:14 -0500 |
commit | 8fa9a8640eb85e7250b8e3ca15124e74ce6014e7 (patch) | |
tree | 2088e1fb5e8b0a043bb018f1578e1b3af6f6b0c4 /setuptools/namespaces.py | |
parent | 6070cc15ed234a71777747c4cdd55f228f3d7b90 (diff) | |
download | external_python_setuptools-8fa9a8640eb85e7250b8e3ca15124e74ce6014e7.tar.gz external_python_setuptools-8fa9a8640eb85e7250b8e3ca15124e74ce6014e7.tar.bz2 external_python_setuptools-8fa9a8640eb85e7250b8e3ca15124e74ce6014e7.zip |
Only import modules when they're expected to be present
Diffstat (limited to 'setuptools/namespaces.py')
-rwxr-xr-x | setuptools/namespaces.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index 69debe4b..0a889f22 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -43,9 +43,11 @@ class Installer: return self.target _nspkg_tmpl = ( - "import sys, types, os, importlib.util, importlib.machinery", + "import sys, types, os", "has_mfs = sys.version_info > (3, 5)", "p = os.path.join(%(root)s, *%(pth)r)", + "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(" |