[gobject-introspection/fix-msvc-setuptools-distutils] ccompiler.py: Fix running on Visual Studio against SetupTools




commit 68447ee48a4fd5e5cb4b3fe0de12a75fea367ca0
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Jul 26 10:48:31 2022 +0800

    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 a6be9ee6..272e1d5b 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')
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]