|
| 1 | +From a2139dba59eac283a7f543ed737f038deebddc19 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Christoph Reiter <reiter.christoph@gmail.com> |
| 3 | +Date: Wed, 28 Aug 2024 21:26:02 +0200 |
| 4 | +Subject: [PATCH] giscanner: remove dependency on distutils.msvccompiler |
| 5 | + |
| 6 | +It was removed with setuptools 74.0.0. Since we still depend on the |
| 7 | +MSVCCompiler class use new_compiler() to get it some other way. |
| 8 | + |
| 9 | +Remove any reference to MSVC9Compiler, which was for Visual Studio 2008 |
| 10 | +which we no longer support anyway. |
| 11 | + |
| 12 | +Fixes #515 |
| 13 | +--- |
| 14 | + giscanner/ccompiler.py | 7 +++---- |
| 15 | + giscanner/msvccompiler.py | 14 +++++++------- |
| 16 | + 2 files changed, 10 insertions(+), 11 deletions(-) |
| 17 | + |
| 18 | +diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py |
| 19 | +index d0ed70a3..9a732cd5 100644 |
| 20 | +--- a/giscanner/ccompiler.py |
| 21 | ++++ b/giscanner/ccompiler.py |
| 22 | +@@ -26,7 +26,6 @@ import tempfile |
| 23 | + import sys |
| 24 | + import distutils |
| 25 | + |
| 26 | +-from distutils.msvccompiler import MSVCCompiler |
| 27 | + from distutils.unixccompiler import UnixCCompiler |
| 28 | + from distutils.cygwinccompiler import Mingw32CCompiler |
| 29 | + from distutils.sysconfig import get_config_vars |
| 30 | +@@ -167,7 +166,7 @@ class CCompiler(object): |
| 31 | + # Now, create the distutils ccompiler instance based on the info we have. |
| 32 | + if compiler_name == 'msvc': |
| 33 | + # For MSVC, we need to create a instance of a subclass of distutil's |
| 34 | +- # MSVC9Compiler class, as it does not provide a preprocess() |
| 35 | ++ # MSVCCompiler class, as it does not provide a preprocess() |
| 36 | + # implementation |
| 37 | + from . import msvccompiler |
| 38 | + self.compiler = msvccompiler.get_msvc_compiler() |
| 39 | +@@ -460,7 +459,7 @@ class CCompiler(object): |
| 40 | + return self.compiler.linker_exe |
| 41 | + |
| 42 | + def check_is_msvc(self): |
| 43 | +- return isinstance(self.compiler, MSVCCompiler) |
| 44 | ++ return self.compiler.compiler_type == "msvc" |
| 45 | + |
| 46 | + # Private APIs |
| 47 | + def _set_cpp_options(self, options): |
| 48 | +@@ -486,7 +485,7 @@ class CCompiler(object): |
| 49 | + # macros for compiling using distutils |
| 50 | + # get dropped for MSVC builds, so |
| 51 | + # escape the escape character. |
| 52 | +- if isinstance(self.compiler, MSVCCompiler): |
| 53 | ++ if self.check_is_msvc(): |
| 54 | + macro_value = macro_value.replace('\"', '\\\"') |
| 55 | + macros.append((macro_name, macro_value)) |
| 56 | + elif option.startswith('-U'): |
| 57 | +diff --git a/giscanner/msvccompiler.py b/giscanner/msvccompiler.py |
| 58 | +index 0a543982..e333a80f 100644 |
| 59 | +--- a/giscanner/msvccompiler.py |
| 60 | ++++ b/giscanner/msvccompiler.py |
| 61 | +@@ -19,30 +19,30 @@ |
| 62 | + # |
| 63 | + |
| 64 | + import os |
| 65 | +-import distutils |
| 66 | ++from typing import Type |
| 67 | + |
| 68 | + from distutils.errors import DistutilsExecError, CompileError |
| 69 | +-from distutils.ccompiler import CCompiler, gen_preprocess_options |
| 70 | ++from distutils.ccompiler import CCompiler, gen_preprocess_options, new_compiler |
| 71 | + from distutils.dep_util import newer |
| 72 | + |
| 73 | + # Distutil's MSVCCompiler does not provide a preprocess() |
| 74 | + # Implementation, so do our own here. |
| 75 | + |
| 76 | + |
| 77 | ++DistutilsMSVCCompiler: Type = type(new_compiler(compiler="msvc")) |
| 78 | ++ |
| 79 | ++ |
| 80 | + def get_msvc_compiler(): |
| 81 | + return MSVCCompiler() |
| 82 | + |
| 83 | + |
| 84 | +-class MSVCCompiler(distutils.msvccompiler.MSVCCompiler): |
| 85 | ++class MSVCCompiler(DistutilsMSVCCompiler): |
| 86 | + |
| 87 | + def __init__(self, verbose=0, dry_run=0, force=0): |
| 88 | +- super(distutils.msvccompiler.MSVCCompiler, self).__init__() |
| 89 | ++ super(DistutilsMSVCCompiler, self).__init__() |
| 90 | + CCompiler.__init__(self, verbose, dry_run, force) |
| 91 | + self.__paths = [] |
| 92 | + self.__arch = None # deprecated name |
| 93 | +- if os.name == 'nt': |
| 94 | +- if isinstance(self, distutils.msvc9compiler.MSVCCompiler): |
| 95 | +- self.__version = distutils.msvc9compiler.VERSION |
| 96 | + self.initialized = False |
| 97 | + self.preprocess_options = None |
| 98 | + if self.check_is_clang_cl(): |
| 99 | +-- |
| 100 | +2.46.2 |
| 101 | + |
0 commit comments