From 9d07efa0dc6e7ebd715487be5e0092a608964cf0 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Sat, 4 Jan 2025 03:49:25 -0600 Subject: [PATCH] gobject-introspection: patch to import setuptools before distutils (#47879) --- .../packages/gobject-introspection/package.py | 14 ++++- .../gobject-introspection/setuptools.patch | 60 +++++++++++++++++++ 2 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 var/spack/repos/builtin/packages/gobject-introspection/setuptools.patch diff --git a/var/spack/repos/builtin/packages/gobject-introspection/package.py b/var/spack/repos/builtin/packages/gobject-introspection/package.py index 9163c22515c..5371677ce8f 100644 --- a/var/spack/repos/builtin/packages/gobject-introspection/package.py +++ b/var/spack/repos/builtin/packages/gobject-introspection/package.py @@ -55,6 +55,10 @@ class GobjectIntrospection(MesonPackage, AutotoolsPackage): # https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/283 depends_on("libffi@:3.3", when="@:1.72") # libffi 3.4 caused seg faults depends_on("python") + with when("^python@3.12:"): + depends_on("py-setuptools@48:", type=("build", "run")) + # https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/490 + depends_on("py-setuptools@:73", type=("build", "run"), when="@:1.81.0") # This package creates several scripts from # toosl/g-ir-tool-template.in. In their original form these @@ -91,10 +95,14 @@ class GobjectIntrospection(MesonPackage, AutotoolsPackage): when="@:1.63.1", ) - # https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/361 - # https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/395 + # g-ir-scanner uses distutils + # - https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/361 + # - https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/395 + # for new enough versions we import setuptools first + patch("setuptools.patch", when="@1.78: ^python@3.12:") + # for older versions we conflict with newer python conflicts( - "^python@3.12:", + "@:1.77 ^python@3.12:", msg="gobject-introspection still uses distutils which was removed in Python 3.12", ) conflicts( diff --git a/var/spack/repos/builtin/packages/gobject-introspection/setuptools.patch b/var/spack/repos/builtin/packages/gobject-introspection/setuptools.patch new file mode 100644 index 00000000000..5d44935440d --- /dev/null +++ b/var/spack/repos/builtin/packages/gobject-introspection/setuptools.patch @@ -0,0 +1,60 @@ +diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py +index 2f03fd85..8e7424b7 100644 +--- a/giscanner/ccompiler.py ++++ b/giscanner/ccompiler.py +@@ -24,6 +24,7 @@ import subprocess + import tempfile + + import sys ++import setuptools + import distutils + + from distutils.unixccompiler import UnixCCompiler +diff --git a/giscanner/msvccompiler.py b/giscanner/msvccompiler.py +index e333a80f..5168930a 100644 +--- a/giscanner/msvccompiler.py ++++ b/giscanner/msvccompiler.py +@@ -21,6 +21,7 @@ + import os + from typing import Type + ++import setuptools + from distutils.errors import DistutilsExecError, CompileError + from distutils.ccompiler import CCompiler, gen_preprocess_options, new_compiler + from distutils.dep_util import newer +diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py +index 987df819..08cb432f 100644 +--- a/giscanner/scannermain.py ++++ b/giscanner/scannermain.py +@@ -552,6 +552,7 @@ def scanner_main(args): + (options, args) = parser.parse_args(args) + + if options.verbose: ++ import setuptools + import distutils + distutils.log.set_threshold(distutils.log.DEBUG) + if options.passthrough_gir: +diff --git a/giscanner/utils.py b/giscanner/utils.py +index 9840143c..6fbcbce4 100644 +--- a/giscanner/utils.py ++++ b/giscanner/utils.py +@@ -382,6 +382,7 @@ def get_msvcr_overwrite(): + return ['vcruntime140'] + + ++import setuptools + import distutils.cygwinccompiler + orig_get_msvcr = distutils.cygwinccompiler.get_msvcr # type: ignore + distutils.cygwinccompiler.get_msvcr = get_msvcr_overwrite # type: ignore +diff --git a/tests/scanner/test_ccompiler.py b/tests/scanner/test_ccompiler.py +index 6c0674a1..248df21c 100644 +--- a/tests/scanner/test_ccompiler.py ++++ b/tests/scanner/test_ccompiler.py +@@ -15,6 +15,7 @@ + # Free Software Foundation, Inc., 59 Temple Place - Suite 330, + # Boston, MA 02111-1307, USA. + ++import setuptools + import distutils + import os + import shlex