[gobject-introspection/fix-msvc-setuptools-distutils] ccompiler.py: Fix running on Visual Studio against SetupTools
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/fix-msvc-setuptools-distutils] ccompiler.py: Fix running on Visual Studio against SetupTools
- Date: Thu, 21 Jul 2022 04:30:21 +0000 (UTC)
commit aea86f732d7f0ce5eca6db961aa5e08c19dc1858
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Tue Apr 19 15:34:17 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 bail out from customize_compiler() if
the distutils.ccompiler.new_compiler() fails.
This will fix the warn-* tests for G-I.
giscanner/ccompiler.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
index a6be9ee6..b5f800c7 100644
--- a/giscanner/ccompiler.py
+++ b/giscanner/ccompiler.py
@@ -44,7 +44,11 @@ def customize_compiler(compiler):
# 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()
+ try:
+ dummy = distutils.ccompiler.new_compiler()
+ except distutils.errors.DistutilsModuleError:
+ return
+
orig_customize_compiler(dummy)
if compiler.compiler_type == "unix":
@@ -133,7 +137,7 @@ class CCompiler(object):
if compiler_name == 'msvc':
# For MSVC, we need to create a instance of a subclass of distutil's
# MSVC9Compiler class, as it does not provide a preprocess()
- # implementation
+ # implementation. customize_compiler() basically becomes a no-op.
from . import msvccompiler
self.compiler = msvccompiler.get_msvc_compiler()
else:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]