diff --git a/waflib/Context.py b/waflib/Context.py index e3305fa3..4760bc82 100644 --- a/waflib/Context.py +++ b/waflib/Context.py @@ -6,10 +6,17 @@ Classes and functions enabling the command system """ -import os, re, imp, sys +import os, re, sys from waflib import Utils, Errors, Logs import waflib.Node +if sys.hexversion > 0x3040000: + import types + class imp(object): + new_module = lambda x: types.ModuleType(x) +else: + import imp + # the following 3 constants are updated on each new release (do not touch) HEXVERSION=0x2001200 """Constant updated on new releases""" diff --git a/waflib/Tools/python.py b/waflib/Tools/python.py index 7c45a76f..b1c8dd01 100644 --- a/waflib/Tools/python.py +++ b/waflib/Tools/python.py @@ -620,7 +620,7 @@ def configure(conf): v.PYO = getattr(Options.options, 'pyo', 1) try: - v.PYTAG = conf.cmd_and_log(conf.env.PYTHON + ['-c', "import imp;print(imp.get_tag())"]).strip() + v.PYTAG = conf.cmd_and_log(conf.env.PYTHON + ['-c', "import sys\ntry:\n print(sys.implementation.cache_tag)\nexcept AttributeError:\n import imp\n print(imp.get_tag())\n"]).strip() except Errors.WafError: pass