# HG changeset patch # Parent ab9d6c4907e76c45e870935bfb2b33697e15db68 Issue #13994: Since it has been discovered that at least one third-party package had been changed to use the inadvertently released duplicated version of distutils.sysconfig.customize_compiler that was removed from distutils.ccompile in 2.7.3, provide a compatibility wrapper function to avoid breaking of any such modified package. diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py --- a/Lib/distutils/ccompiler.py +++ b/Lib/distutils/ccompiler.py @@ -1091,3 +1091,30 @@ lib_opts.append(compiler.library_option(lib)) return lib_opts + +# Issue13994: during the 2.7 developmenet cycle, customize_compiler was briefly +# moved from its original location in distutils.sysconfig to this module, +# distutils.ccompiler. Prior to 2.7 release, it was decided to freeze +# distutils and revert feature changes. Unfortunately, not everything +# was cleanly reverted. customize_compiler was restored in the original +# location but the new copy was not removed, leaving two versions. For +# 2.7.3, that oversight was corrected but it was discovered that at least +# one third-party package had been modified to use the new, undocumented +# location that was supposed to have been removed before release. This +# wrapper function provides compatibility for that package and any others +# that might have been changed for 2.7. New code should continue to use +# the original, documented import from distutils.sysconfig as only 2.7 +# was affected by this issue. + +_customize_compiler = None + +def customize_compiler(compiler): + """Do any platform-specific customization of a CCompiler instance. + + Wrapper for distutils.sysconfig.customize_compiler to workaround + compatibility issue in Python 2.7.x. + """ + global _customize_compiler + if _customize_compiler is None: + from distutils.sysconfig import customize_compiler as _customize_compiler + return _customize_compiler(compiler)