0003-giscanner-remove-dependency-on-distutils.msvccompile.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. From c8310afa42dfa598097eb0e003cef7965b5ed7be 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. It was removed with setuptools 74.0.0. Since we still depend on the
  6. MSVCCompiler class use new_compiler() to get it some other way.
  7. Remove any reference to MSVC9Compiler, which was for Visual Studio 2008
  8. which we no longer support anyway.
  9. Fixes #515
  10. Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
  11. Upstream: https://gitlab.gnome.org/GNOME/gobject-introspection/-/commit/a2139dba59eac283a7f543ed737f038deebddc19
  12. ---
  13. giscanner/ccompiler.py | 7 +++----
  14. giscanner/msvccompiler.py | 14 +++++++-------
  15. 2 files changed, 10 insertions(+), 11 deletions(-)
  16. diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
  17. index 2912fe0e..766c9a36 100644
  18. --- a/giscanner/ccompiler.py
  19. +++ b/giscanner/ccompiler.py
  20. @@ -26,7 +26,6 @@ import tempfile
  21. import sys
  22. import distutils
  23. -from distutils.msvccompiler import MSVCCompiler
  24. from distutils.unixccompiler import UnixCCompiler
  25. from distutils.cygwinccompiler import Mingw32CCompiler
  26. from distutils.sysconfig import get_config_vars
  27. @@ -167,7 +166,7 @@ class CCompiler(object):
  28. # Now, create the distutils ccompiler instance based on the info we have.
  29. if compiler_name == 'msvc':
  30. # For MSVC, we need to create a instance of a subclass of distutil's
  31. - # MSVC9Compiler class, as it does not provide a preprocess()
  32. + # MSVCCompiler class, as it does not provide a preprocess()
  33. # implementation
  34. from . import msvccompiler
  35. self.compiler = msvccompiler.get_msvc_compiler()
  36. @@ -453,7 +452,7 @@ class CCompiler(object):
  37. return self.compiler.linker_exe
  38. def check_is_msvc(self):
  39. - return isinstance(self.compiler, MSVCCompiler)
  40. + return self.compiler.compiler_type == "msvc"
  41. # Private APIs
  42. def _set_cpp_options(self, options):
  43. @@ -479,7 +478,7 @@ class CCompiler(object):
  44. # macros for compiling using distutils
  45. # get dropped for MSVC builds, so
  46. # escape the escape character.
  47. - if isinstance(self.compiler, MSVCCompiler):
  48. + if self.check_is_msvc():
  49. macro_value = macro_value.replace('\"', '\\\"')
  50. macros.append((macro_name, macro_value))
  51. elif option.startswith('-U'):
  52. diff --git a/giscanner/msvccompiler.py b/giscanner/msvccompiler.py
  53. index 0a543982..e333a80f 100644
  54. --- a/giscanner/msvccompiler.py
  55. +++ b/giscanner/msvccompiler.py
  56. @@ -19,30 +19,30 @@
  57. #
  58. import os
  59. -import distutils
  60. +from typing import Type
  61. from distutils.errors import DistutilsExecError, CompileError
  62. -from distutils.ccompiler import CCompiler, gen_preprocess_options
  63. +from distutils.ccompiler import CCompiler, gen_preprocess_options, new_compiler
  64. from distutils.dep_util import newer
  65. # Distutil's MSVCCompiler does not provide a preprocess()
  66. # Implementation, so do our own here.
  67. +DistutilsMSVCCompiler: Type = type(new_compiler(compiler="msvc"))
  68. +
  69. +
  70. def get_msvc_compiler():
  71. return MSVCCompiler()
  72. -class MSVCCompiler(distutils.msvccompiler.MSVCCompiler):
  73. +class MSVCCompiler(DistutilsMSVCCompiler):
  74. def __init__(self, verbose=0, dry_run=0, force=0):
  75. - super(distutils.msvccompiler.MSVCCompiler, self).__init__()
  76. + super(DistutilsMSVCCompiler, self).__init__()
  77. CCompiler.__init__(self, verbose, dry_run, force)
  78. self.__paths = []
  79. self.__arch = None # deprecated name
  80. - if os.name == 'nt':
  81. - if isinstance(self, distutils.msvc9compiler.MSVCCompiler):
  82. - self.__version = distutils.msvc9compiler.VERSION
  83. self.initialized = False
  84. self.preprocess_options = None
  85. if self.check_is_clang_cl():
  86. --
  87. 2.34.1