Skip to contentSkip to conversation

package/gobject-introspection: fix build with latest setuptools

PATCH Applied James Hilliard 2 participants 6 messages Sep 27, 2024 – Oct 10, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/gobject-introspection: fix build with latest setuptools

When setuptools was updated to version 75.1.0 in buildroot commit f01897aa6ceca00831c9b2c14f3ae90faaefce68 it broke gobject introspection builds which relied on a deprecated MSVCCompiler distutils module.

Backport an upstream patch removing this module dependency.

Fixes:
- http://autobuild.buildroot.net/results/8e0/8e020d65509181148c597997280f196c33b28574
- http://autobuild.buildroot.net/results/2db/2db8ce60917b66030286da936c1f1f3aa657b6b7

---
 ...-dependency-on-distutils.msvccompile.patch | 104 ++++++++++++++++++
 1 file changed, 104 insertions(+)
 create mode 100644 package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch
package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch new file +104 -0
new file mode 100644
index 0000000000..a3231a5ad6
@@ -0,0 +1,104 @@
+From c8310afa42dfa598097eb0e003cef7965b5ed7be Mon Sep 17 00:00:00 2001
+From: Christoph Reiter <[email protected]>
+Date: Wed, 28 Aug 2024 21:26:02 +0200
+Subject: [PATCH] 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.
+
+Fixes #515
+
+Signed-off-by: James Hilliard <[email protected]>
+Upstream: https://gitlab.gnome.org/GNOME/gobject-introspection/-/commit/a2139dba59eac283a7f543ed737f038deebddc19
+---
+ giscanner/ccompiler.py    |  7 +++----
+ giscanner/msvccompiler.py | 14 +++++++-------
+ 2 files changed, 10 insertions(+), 11 deletions(-)
+
+diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
+index 2912fe0e..766c9a36 100644
+--- a/giscanner/ccompiler.py
++++ b/giscanner/ccompiler.py
+@@ -26,7 +26,6 @@ import tempfile
+ 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 @@ class CCompiler(object):
+         # 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 @@ class CCompiler(object):
+             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 @@ class CCompiler(object):
+                     # 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'):
+diff --git a/giscanner/msvccompiler.py b/giscanner/msvccompiler.py
+index 0a543982..e333a80f 100644
+--- a/giscanner/msvccompiler.py
++++ b/giscanner/msvccompiler.py
+@@ -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.34.1
+
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Am 28.09.24 um 01:52 schrieb James Hilliard:

Quoted 6 lines

When setuptools was updated to version 75.1.0 in buildroot commit f01897aa6ceca00831c9b2c14f3ae90faaefce68 it broke gobject introspection builds which relied on a deprecated MSVCCompiler distutils module.

Backport an upstream patch removing this module dependency.

I'd prefer to see the update to gobject-introspection 1.82.0 merged instead, which already includes the patch. Though the backport could be a stop-gap measure if the update series needs any lengthy fixes. :-)

See:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/
Series: https://patchwork.ozlabs.org/project/buildroot/list/?series=425356

Best regards,
Fiona

Quoted 110 lines

Fixes:
- http://autobuild.buildroot.net/results/8e0/8e020d65509181148c597997280f196c33b28574
- http://autobuild.buildroot.net/results/2db/2db8ce60917b66030286da936c1f1f3aa657b6b7

---
  ...-dependency-on-distutils.msvccompile.patch | 104 ++++++++++++++++++
  1 file changed, 104 insertions(+)

create mode 100644 package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch

package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch new file +94 -0
new file mode 100644
index 0000000000..a3231a5ad6
@@ -0,0 +1,104 @@
+From c8310afa42dfa598097eb0e003cef7965b5ed7be Mon Sep 17 00:00:00 2001
+From: Christoph Reiter <[email protected]>
+Date: Wed, 28 Aug 2024 21:26:02 +0200
+Subject: [PATCH] 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.
+
+Fixes #515
+
+Signed-off-by: James Hilliard <[email protected]>
+Upstream: https://gitlab.gnome.org/GNOME/gobject-introspection/-/commit/a2139dba59eac283a7f543ed737f038deebddc19
+---
+ giscanner/ccompiler.py    |  7 +++----
+ giscanner/msvccompiler.py | 14 +++++++-------
+ 2 files changed, 10 insertions(+), 11 deletions(-)
+
+diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
+index 2912fe0e..766c9a36 100644
+--- a/giscanner/ccompiler.py
++++ b/giscanner/ccompiler.py
+@@ -26,7 +26,6 @@ import tempfile
+ 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 @@ class CCompiler(object):
+         # 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 @@ class CCompiler(object):
+             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 @@ class CCompiler(object):
+                     # 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'):
+diff --git a/giscanner/msvccompiler.py b/giscanner/msvccompiler.py
+index 0a543982..e333a80f 100644
+--- a/giscanner/msvccompiler.py
++++ b/giscanner/msvccompiler.py
+@@ -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 = []

package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch line 104

Quoted 10 lines
package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch new file +10 -0
+         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.34.1
+

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw
Quoted 6 lines · Fiona Klute

Am 28.09.24 um 01:52 schrieb James Hilliard:

Quoted 5 lines

When setuptools was updated to version 75.1.0 in buildroot commit f01897aa6ceca00831c9b2c14f3ae90faaefce68 it broke gobject introspection builds which relied on a deprecated MSVCCompiler distutils module.

Quoted 6 lines
Quoted 1 line

Backport an upstream patch removing this module dependency.

I'd prefer to see the update to gobject-introspection 1.82.0 merged instead, which already includes the patch. Though the backport could be a stop-gap measure if the update series needs any lengthy fixes. :-)

Yeah, probably best to just use the updated gobject-introspection if it's not too problematic to merge.

Quoted 132 lines

See:

https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/
Series: https://patchwork.ozlabs.org/project/buildroot/list/?series=425356

Best regards,
Fiona

Quoted 2 lines

Fixes:
-

http://autobuild.buildroot.net/results/8e0/8e020d65509181148c597997280f196c33b28574

Quoted 1 line

-

http://autobuild.buildroot.net/results/2db/2db8ce60917b66030286da936c1f1f3aa657b6b7

Quoted 6 lines
---
  ...-dependency-on-distutils.msvccompile.patch | 104 ++++++++++++++++++
  1 file changed, 104 insertions(+)

create mode 100644

package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch

Quoted 2 lines

diff --git

a/package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch b/package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch

Quoted 4 lines

new file mode 100644
index 0000000000..a3231a5ad6
--- /dev/null
+++

b/package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch

Quoted 6 lines
package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch new file +5 -0
@@ -0,0 +1,104 @@
+From c8310afa42dfa598097eb0e003cef7965b5ed7be Mon Sep 17 00:00:00 2001
+From: Christoph Reiter <[email protected]>
+Date: Wed, 28 Aug 2024 21:26:02 +0200
+Subject: [PATCH] giscanner: remove dependency on distutils.msvccompiler
+

package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch line 15

Quoted 10 lines
package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch new file +10 -0
+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.
+
+Fixes #515
+
+Signed-off-by: James Hilliard <[email protected]>
+Upstream:

https://gitlab.gnome.org/GNOME/gobject-introspection/-/commit/a2139dba59eac283a7f543ed737f038deebddc19

Quoted 9 lines
package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch new file +9 -0
+---
+ giscanner/ccompiler.py    |  7 +++----
+ giscanner/msvccompiler.py | 14 +++++++-------
+ 2 files changed, 10 insertions(+), 11 deletions(-)
+
+diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
+index 2912fe0e..766c9a36 100644
+--- a/giscanner/ccompiler.py
++++ b/giscanner/ccompiler.py

package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch

Quoted 10 lines
package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch new file +10 -0
+@@ -26,7 +26,6 @@ import tempfile
+ 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 @@ class CCompiler(object):
+         # Now, create the distutils ccompiler instance based on the

info we have.

Review line 36

Quoted 2 lines
(quoted diff) +2 -0
+         if compiler_name == 'msvc':
+             # For MSVC, we need to create a instance of a subclass of

distutil's

Review line 37

Quoted 1 line
(quoted diff) +1 -0
+-            # MSVC9Compiler class, as it does not provide a

preprocess()

Quoted 26 lines
package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch new file +26 -0
++            # MSVCCompiler class, as it does not provide a preprocess()
+             # implementation
+             from . import msvccompiler
+             self.compiler = msvccompiler.get_msvc_compiler()
+@@ -453,7 +452,7 @@ class CCompiler(object):
+             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 @@ class CCompiler(object):
+                     # 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'):
+diff --git a/giscanner/msvccompiler.py b/giscanner/msvccompiler.py
+index 0a543982..e333a80f 100644
+--- a/giscanner/msvccompiler.py
++++ b/giscanner/msvccompiler.py

package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch

Quoted 10 lines
package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch new file +10 -0
+@@ -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

Quoted 23 lines
package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch new file +23 -0
+ 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':
Quoted 10 lines

package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch line 104

Quoted 8 lines
package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch new file +8 -0
+-            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.34.1
+

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
In reply to Fiona Klute via buildroot
Quoted 5 lines · On Mon, 30 Sep 2024 12:33:00 +0200 Fiona Klute via buildroot…
Quoted 1 line

Backport an upstream patch removing this module dependency.

I'd prefer to see the update to gobject-introspection 1.82.0 merged instead, which already includes the patch. Though the backport could be a stop-gap measure if the update series needs any lengthy fixes. :-)

Fundamentally, I agree with you that updating GOI with your patch series is the way to go, but as this build failure has been impacting severely our autobuilders, we need an immediate fix, which is why I have applied the patch from James.

BTW James, thanks for documenting very nicely in your commit which Buildroot commit introduced the issue: this is *exactly* what we need, and therefore it is much appreciated!

Best regards,

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

Am 09.10.24 um 22:38 schrieb Thomas Petazzoni:

Quoted 5 lines
Quoted 2 lines · On Mon, 30 Sep 2024 12:33:00 +0200 Fiona Klute via buildroot…
Quoted 1 line

Backport an upstream patch removing this module dependency.

Quoted 8 lines
Quoted 3 lines

I'd prefer to see the update to gobject-introspection 1.82.0 merged instead, which already includes the patch. Though the backport could be a stop-gap measure if the update series needs any lengthy fixes. :-)

Fundamentally, I agree with you that updating GOI with your patch series is the way to go, but as this build failure has been impacting severely our autobuilders, we need an immediate fix, which is why I have applied the patch from James.

Makes sense, I just wish I could do something to get that series merged. Now it'll need a trivial update to remove the backported patch with the update, but if there's anything else that needs fixing I'd like to do it soon instead of accumulating more changes.

Or is it just waiting for someone with commit access to get to it?

Best regards,
Fiona

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#5 lore raw
In reply to James Hilliard
Quoted 11 lines · On Fri, 27 Sep 2024 17:52:59 -0600 James Hilliard <[email protected]>…

When setuptools was updated to version 75.1.0 in buildroot commit f01897aa6ceca00831c9b2c14f3ae90faaefce68 it broke gobject introspection builds which relied on a deprecated MSVCCompiler distutils module.

Backport an upstream patch removing this module dependency.

Fixes:
- http://autobuild.buildroot.net/results/8e0/8e020d65509181148c597997280f196c33b28574
- http://autobuild.buildroot.net/results/2db/2db8ce60917b66030286da936c1f1f3aa657b6b7

Quoted 5 lines
---
 ...-dependency-on-distutils.msvccompile.patch | 104 ++++++++++++++++++
 1 file changed, 104 insertions(+)
 create mode 100644 package/gobject-introspection/0003-giscanner-remove-dependency-on-distutils.msvccompile.patch

Applied to master, thanks.

Thomas

Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot