From 7baf54a4e4e5d8672a4c617cc3578418f4aeb471 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 26 Jul 2022 10:48:31 +0800 Subject: ccompiler.py: Fix running on Visual Studio against SetupTools ...when we use the distutils that is packaged with SetupTools instead of the one that comes with Python stdlib, which is often the case on newer Python 3.9+ (or so) installations. Calling distutils.ccompiler.new_compiler() in this case won't work when running on Visual Studio builds, and we use the compiler instance for distutils's customize_compiler(), which was never meant for Visual Studio. So, we do nothing in customize_compiler() if we are not using a unix compiler type. This will fix the warn-* tests for G-I on Python 3.9.x or later when the default distutils used is now the one that comes with setuptools, without needing to use the envvar SETUPTOOLS_USE_DISTUTILS=stdlib. --- giscanner/ccompiler.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py index 2912fe0e..7a8dee78 100644 --- a/giscanner/ccompiler.py +++ b/giscanner/ccompiler.py @@ -40,14 +40,12 @@ def customize_compiler(compiler): any macOS specific bits and which tries to avoid using any Python specific defaults if alternatives through env vars are given. """ - - # The original customize_compiler() in distutils calls into macOS setup - # code the first time it is called. This makes sure we run that setup - # code as well. - dummy = distutils.ccompiler.new_compiler() - orig_customize_compiler(dummy) - if compiler.compiler_type == "unix": + # The original customize_compiler() in distutils calls into macOS setup + # code the first time it is called. This makes sure we run that setup + # code as well. + dummy = distutils.ccompiler.new_compiler() + orig_customize_compiler(dummy) (cc, cxx, ldshared, shlib_suffix, ar, ar_flags) = \ get_config_vars('CC', 'CXX', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS') -- cgit v1.2.1