From fcec3315a52368a58457a9c428a3d1cff5761714 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 30 Dec 2012 12:57:49 -0500 Subject: [PATCH] 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. --- swc-installation-test-2.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 -- 2.26.2