Skip to content

Commit

Permalink
gobject-introspection: Fix giscanner with setuptools 74
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandesign committed Sep 2, 2024
1 parent 569a05e commit bd6d608
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gnome/gobject-introspection/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ conflicts gobject-introspection-devel
set my_name gobject-introspection

version 1.78.1
revision 2
revision 3
epoch 1

categories gnome
Expand Down Expand Up @@ -55,6 +55,7 @@ depends_lib-append \
patchfiles-append patch-fix-rpath-gir-typelib.diff
patchfiles-append patch-fix-scanner-in-build-execution.diff
patchfiles-append patch-fix-tools-python.diff
patchfiles-append msvccompiler.patch

post-patch {
reinplace "s|libcairo-gobject\\.2\\.dylib|${prefix}/lib/libcairo-gobject.2.dylib|g" ${worksrcpath}/gir/meson.build
Expand Down
87 changes: 87 additions & 0 deletions gnome/gobject-introspection/files/msvccompiler.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
giscanner: remove dependency on distutils.msvccompiler

It was removed with setuptools 74.0.0. Since we still depend on the
MSVCCompiler class use new_compiler() to get it some other way.

Remove any reference to MSVC9Compiler, which was for Visual Studio 2008
which we no longer support anyway.

https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/515
https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/490
--- giscanner/ccompiler.py.orig 2024-09-01 21:06:18.000000000 -0500
+++ giscanner/ccompiler.py 2024-09-01 21:06:19.000000000 -0500
@@ -26,7 +26,6 @@
import sys
import distutils

-from distutils.msvccompiler import MSVCCompiler
from distutils.unixccompiler import UnixCCompiler
from distutils.cygwinccompiler import Mingw32CCompiler
from distutils.sysconfig import get_config_vars
@@ -167,7 +166,7 @@
# Now, create the distutils ccompiler instance based on the info we have.
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()
+ # MSVCCompiler class, as it does not provide a preprocess()
# implementation
from . import msvccompiler
self.compiler = msvccompiler.get_msvc_compiler()
@@ -453,7 +452,7 @@
return self.compiler.linker_exe

def check_is_msvc(self):
- return isinstance(self.compiler, MSVCCompiler)
+ return self.compiler.compiler_type == "msvc"

# Private APIs
def _set_cpp_options(self, options):
@@ -479,7 +478,7 @@
# macros for compiling using distutils
# get dropped for MSVC builds, so
# escape the escape character.
- if isinstance(self.compiler, MSVCCompiler):
+ if self.check_is_msvc():
macro_value = macro_value.replace('\"', '\\\"')
macros.append((macro_name, macro_value))
elif option.startswith('-U'):
--- giscanner/msvccompiler.py.orig 2023-09-16 06:32:07.000000000 -0500
+++ giscanner/msvccompiler.py 2024-09-01 21:07:08.000000000 -0500
@@ -19,30 +19,30 @@
#

import os
-import distutils
+from typing import Type

from distutils.errors import DistutilsExecError, CompileError
-from distutils.ccompiler import CCompiler, gen_preprocess_options
+from distutils.ccompiler import CCompiler, gen_preprocess_options, new_compiler
from distutils.dep_util import newer

# Distutil's MSVCCompiler does not provide a preprocess()
# Implementation, so do our own here.


+DistutilsMSVCCompiler: Type = type(new_compiler(compiler="msvc"))
+
+
def get_msvc_compiler():
return MSVCCompiler()


-class MSVCCompiler(distutils.msvccompiler.MSVCCompiler):
+class MSVCCompiler(DistutilsMSVCCompiler):

def __init__(self, verbose=0, dry_run=0, force=0):
- super(distutils.msvccompiler.MSVCCompiler, self).__init__()
+ super(DistutilsMSVCCompiler, self).__init__()
CCompiler.__init__(self, verbose, dry_run, force)
self.__paths = []
self.__arch = None # deprecated name
- if os.name == 'nt':
- if isinstance(self, distutils.msvc9compiler.MSVCCompiler):
- self.__version = distutils.msvc9compiler.VERSION
self.initialized = False
self.preprocess_options = None
if self.check_is_clang_cl():

2 comments on commit bd6d608

@barracuda156
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryandesign We also need this for gobject-introspection-devel

@ryandesign
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.