Skip to content

Conversation

@QuLogic
Copy link
Member

@QuLogic QuLogic commented Sep 9, 2025

PR summary

This adds requirements for all of Gdk/GdkPixbuf /Gio/GLib/GObject before using them, as we do for Gtk.

Note, Gdk is bunded with Gtk, so it's the only one that changes versions depending on backend.

Fixes #30525

PR checklist

@QuLogic QuLogic added this to the v3.10.7 milestone Sep 9, 2025
@QuLogic
Copy link
Member Author

QuLogic commented Sep 9, 2025

Note, this doesn't explicitly do GioUnix, but as that comes with Gio (but is platform-specific), I'm hoping that's enough to fix it.

@LangQi99
Copy link
Contributor

LangQi99 commented Sep 9, 2025

What about

    try:
        gi.require_version("GioUnix", "2.0")
    except ValueError:
        # GioUnix is not available on this platform, which is fine
        pass

I tried it in #30535

@QuLogic QuLogic force-pushed the gtk-require-version branch from 8a720cb to 93a5b91 Compare September 9, 2025 06:38
@tacaswell
Copy link
Member

Sorry I was going down the issue list in order and merged #30535 before I got to this one.

@QuLogic
Copy link
Member Author

QuLogic commented Sep 11, 2025

That is okay; this has turned into more of a cleanup on the tests a bit than fully fixing the original issue.

@QuLogic
Copy link
Member Author

QuLogic commented Sep 18, 2025

Upstream should have made a new release (or two) with the correct exceptions to make the previous change unnecessary, so I've reverted #30535, fixing #30537.

@QuLogic QuLogic linked an issue Sep 18, 2025 that may be closed by this pull request
@timhoffm
Copy link
Member

Is the test failure real? It's suspicious that a gtk test segfaults after this change.

_________ test_backend_getattr[matplotlib.backends.backend_gtk4cairo] __________
[gw0] linux -- Python 3.12.11 /opt/hostedtoolcache/Python/3.12.11/arm64/bin/python

module_name = 'matplotlib.backends.backend_gtk4cairo'

[...]

E               subprocess.CalledProcessError: Command '['/opt/hostedtoolcache/Python/3.12.11/arm64/bin/python', '-c', "import importlib.util;_spec = importlib.util.spec_from_file_location('matplotlib.tests.test_getattr', '/home/runner/work/matplotlib/matplotlib/lib/matplotlib/tests/test_getattr.py');_module = importlib.util.module_from_spec(_spec);_spec.loader.exec_module(_module);_module._test_module_getattr()", 'matplotlib.backends.backend_gtk4cairo']' died with <Signals.SIGSEGV: 11>.

/opt/hostedtoolcache/Python/3.12.11/arm64/lib/python3.12/subprocess.py:571: CalledProcessError
------------------------------ Captured log call -------------------------------
ERROR    matplotlib.testing:__init__.py:112 Subprocess error:
Fatal Python error: Segmentation fault

@QuLogic
Copy link
Member Author

QuLogic commented Sep 18, 2025

It does seem related, yes. Previously, GTK4 would never fully be hit by this test because GTK3 was already imported. How it manages to segfault though, I'm unsure just yet.

@QuLogic QuLogic force-pushed the gtk-require-version branch from 7d56088 to 1ae4f92 Compare September 19, 2025 02:52
@QuLogic
Copy link
Member Author

QuLogic commented Sep 19, 2025

Is the test failure real? It's suspicious that a gtk test segfaults after this change.

It looks like the update to Ubuntu 24.04 fixed it. And since the ubuntu-22.04-arm image seems to have accidentally switched to 24.04 as well, I won't spend any time trying to figure it out.

Upstream has fixed PyGObject in 3.51.1.

This reverts commit 75e7802, reversing
changes made to 352b419.
This adds requirements for all of Gdk/GdkPixbuf before using them, as we
do for Gtk. Note that Gio/GLib/GObject are already accepted without
version by PyGObject as they are tied to the version it's compiled
against.

Fixes matplotlib#30525
This test has been an expected failure since it was created, and in that
time, `gtk_test_widget_send_key` was never made to work, nor was a
replacement found. In GTK4, that API doesn't exist either.
For example, GTK3 and GTK4 conflict, and which one is tested depends on
which one loads first. Running in a subprocess ensures that both work,
but we only do that for backends as adding ~100 more subprocesses is
overkill.
@tacaswell tacaswell merged commit 875379d into matplotlib:main Dec 11, 2025
40 checks passed
@QuLogic QuLogic deleted the gtk-require-version branch December 11, 2025 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Permanent solution for GioUnix warning [Bug]: Pipeline fails with "GioUnix was imported without specifying a version first"

5 participants