From: W. Trevor King Date: Sun, 30 Dec 2012 17:57:49 +0000 (-0500) Subject: swc-installation-test-2.py: Add import_module for older Pythons X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fcec3315a52368a58457a9c428a3d1cff5761714;p=swc-setup-installation-test.git swc-installation-test-2.py: Add import_module for older Pythons importlib is new in Python 2.7 / 3.1. Add a minimal workaround for earlier versions. --- diff --git a/swc-installation-test-2.py b/swc-installation-test-2.py index 69ef169..0617550 100755 --- a/swc-installation-test-2.py +++ b/swc-installation-test-2.py @@ -25,7 +25,19 @@ of Python that you have installed with 'swc-installation-test-1.py'. from __future__ import print_function # for Python 2.6 compatibility import distutils.ccompiler as _distutils_ccompiler -import importlib as _importlib +try: # Python 2.7 and 3.x + import importlib as _importlib +except ImportError: # Python 2.6 and earlier + class _Importlib (object): + """Minimal workarounds for functions we need + """ + @staticmethod + def import_module(name): + module = __import__(name) + for n in name.split('.')[1:]: + module = getattr(module, n) + return module + _importlib = _Importlib() import logging as _logging import os as _os import platform as _platform