diff --git a/30675.patch b/30675.patch new file mode 100644 index 0000000..d738c67 --- /dev/null +++ b/30675.patch @@ -0,0 +1,59 @@ +From b843483d308ce1f8bb94e1449bdb2b77da9a327c Mon Sep 17 00:00:00 2001 +From: Elliott Sales de Andrade +Date: Tue, 21 Oct 2025 03:55:51 -0400 +Subject: [PATCH] Backport PR #30657: Fix `AttributeError: module 'gi' has no + attribute 'require_version'` + +--- + lib/matplotlib/backends/backend_gtk3.py | 4 ++-- + lib/matplotlib/backends/backend_gtk4.py | 5 +++-- + 2 files changed, 5 insertions(+), 4 deletions(-) + +diff --git a/lib/matplotlib/backends/backend_gtk3.py b/lib/matplotlib/backends/backend_gtk3.py +index 888f5a770f5d..c27b57e36a0a 100644 +--- a/lib/matplotlib/backends/backend_gtk3.py ++++ b/lib/matplotlib/backends/backend_gtk3.py +@@ -10,14 +10,14 @@ + CloseEvent, KeyEvent, LocationEvent, MouseEvent, ResizeEvent) + + try: +- import gi ++ from gi import require_version as gi_require_version + except ImportError as err: + raise ImportError("The GTK3 backends require PyGObject") from err + + try: + # :raises ValueError: If module/version is already loaded, already + # required, or unavailable. +- gi.require_version("Gtk", "3.0") ++ gi_require_version("Gtk", "3.0") + except ValueError as e: + # in this case we want to re-raise as ImportError so the + # auto-backend selection logic correctly skips. +diff --git a/lib/matplotlib/backends/backend_gtk4.py b/lib/matplotlib/backends/backend_gtk4.py +index cd38968779ed..e3d3548c1cd1 100644 +--- a/lib/matplotlib/backends/backend_gtk4.py ++++ b/lib/matplotlib/backends/backend_gtk4.py +@@ -9,19 +9,20 @@ + KeyEvent, LocationEvent, MouseEvent, ResizeEvent, CloseEvent) + + try: +- import gi ++ from gi import require_version as gi_require_version + except ImportError as err: + raise ImportError("The GTK4 backends require PyGObject") from err + + try: + # :raises ValueError: If module/version is already loaded, already + # required, or unavailable. +- gi.require_version("Gtk", "4.0") ++ gi_require_version("Gtk", "4.0") + except ValueError as e: + # in this case we want to re-raise as ImportError so the + # auto-backend selection logic correctly skips. + raise ImportError(e) from e + ++import gi + from gi.repository import Gio, GLib, Gtk, Gdk, GdkPixbuf + from . import _backend_gtk + from ._backend_gtk import ( # noqa: F401 # pylint: disable=W0611 diff --git a/python-matplotlib.spec b/python-matplotlib.spec index 8ea19da..b6e5c4b 100644 --- a/python-matplotlib.spec +++ b/python-matplotlib.spec @@ -68,26 +68,34 @@ Patch0002: 0005-Partially-revert-TST-Fix-minor-issues-in-interactive.patch # https://github.com/matplotlib/matplotlib/pull/30497 Patch0003: 0006-TST-Use-a-temporary-directory-for-test_save_figure_r.patch +# Fix AttributeError: module 'gi' has no attribute 'require_version' +Patch0004: https://github.com/matplotlib/matplotlib/pull/30675.patch + BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: glibc-langpack-en BuildRequires: freetype-devel BuildRequires: libpng-devel BuildRequires: qhull-devel +%ifnarch %{ix86} BuildRequires: xwayland-run +%endif BuildRequires: zlib-devel +%ifnarch %{ix86} BuildRequires: ghostscript # No ImageMagick for EL8/ELN/EL9 %if 0%{?fedora} || (0%{?rhel} && 0%{?rhel} < 8) BuildRequires: ImageMagick %endif BuildRequires: inkscape +%endif BuildRequires: font(dejavusans) BuildRequires: font(notosanscjkjp) BuildRequires: font(wenquanyizenhei) +%ifnarch %{ix86} BuildRequires: texlive-collection-basic BuildRequires: texlive-collection-fontsrecommended BuildRequires: texlive-collection-latex @@ -136,6 +144,7 @@ BuildRequires: tex(cmr10.tfm) BuildRequires: tex(cmss10.tfm) BuildRequires: tex(cmsy10.tfm) BuildRequires: tex(cmtt10.tfm) +%endif %description Matplotlib is a Python 2D plotting library which produces publication @@ -168,7 +177,9 @@ Obsoletes: python-matplotlib-data-fonts < 3 %package -n python3-matplotlib Summary: Python 2D plotting library BuildRequires: python3-devel +%ifnarch %{ix86} BuildRequires: python3dist(pycairo) +%endif BuildRequires: python3dist(pytz) BuildRequires: python3dist(sphinx) Requires: dejavu-sans-fonts @@ -182,8 +193,10 @@ BuildRequires: python3dist(pytest) BuildRequires: python3dist(pytest-rerunfailures) BuildRequires: python3dist(pytest-timeout) BuildRequires: python3dist(pytest-xdist) +%ifnarch %{ix86} BuildRequires: python3dist(pikepdf) %endif +%endif # Remove in F45. Provides: python3-matplotlib-data = %{version}-%{release} Obsoletes: python3-matplotlib-data < 3.11~~~ @@ -203,8 +216,10 @@ errorcharts, scatterplots, etc, with just a few lines of code. %package -n python3-matplotlib-qt5 Summary: Qt5 backend for python3-matplotlib BuildRequires: python3dist(cairocffi) +%ifnarch %{ix86} BuildRequires: python3dist(pyqt5) BuildRequires: qt5-qtwayland +%endif Requires: python3-matplotlib%{?_isa} = %{version}-%{release} Requires: python3dist(cairocffi) Requires: python3dist(pyqt5) @@ -216,9 +231,11 @@ Obsoletes: python3-matplotlib-qt4 < 3.5.0-0 %package -n python3-matplotlib-qt6 Summary: Qt6 backend for python3-matplotlib BuildRequires: python3dist(cairocffi) +%ifnarch %{ix86} BuildRequires: python3dist(pyqt6) BuildRequires: python3-pyqt6 BuildRequires: qt6-qtwayland +%endif Requires: python3-matplotlib%{?_isa} = %{version}-%{release} Requires: python3dist(cairocffi) Requires: python3dist(pyqt6) @@ -228,9 +245,11 @@ Requires: python3dist(pyqt6) %package -n python3-matplotlib-gtk3 Summary: GTK3 backend for python3-matplotlib +%ifnarch %{ix86} # This should be converted to typelib(Gtk) when supported BuildRequires: gtk3 BuildRequires: python3-gobject +%endif Requires: gtk3%{?_isa} Requires: python3-gobject%{?_isa} Requires: python3-matplotlib%{?_isa} = %{version}-%{release} @@ -240,9 +259,11 @@ Requires: python3-matplotlib%{?_isa} = %{version}-%{release} %package -n python3-matplotlib-gtk4 Summary: GTK4 backend for python3-matplotlib +%ifnarch %{ix86} # This should be converted to typelib(Gtk) when supported BuildRequires: gtk4 BuildRequires: python3-gobject +%endif Requires: gtk4%{?_isa} Requires: python3-gobject%{?_isa} Requires: python3-matplotlib%{?_isa} = %{version}-%{release} @@ -252,8 +273,10 @@ Requires: python3-matplotlib%{?_isa} = %{version}-%{release} %package -n python3-matplotlib-tk Summary: Tk backend for python3-matplotlib +%ifnarch %{ix86} BuildRequires: python3-pillow-tk BuildRequires: python3-tkinter +%endif Requires: python3-matplotlib%{?_isa} = %{version}-%{release} Requires: python3-pillow-tk Requires: python3-tkinter @@ -264,7 +287,9 @@ Requires: python3-tkinter %if %{with wx} %package -n python3-matplotlib-wx Summary: WX backend for python3-matplotlib +%ifnarch %{ix86} BuildRequires: python3dist(wxpython) +%endif Requires: python3-matplotlib%{?_isa} = %{version}-%{release} Requires: python3dist(wxpython) @@ -347,12 +372,14 @@ rm -rf %{buildroot}%{python3_sitearch}/matplotlib/mpl-data/fonts # These files confuse pytest, and we want to test the installed copy. rm -rf build*/ +%ifnarch %{ix86} # We need to prime this LaTeX cache stuff, or it might fail while running tests # in parallel. mktexfmt latex.fmt mktexfmt lualatex.fmt mktexfmt pdflatex.fmt mktexfmt xelatex.fmt +%endif # Also prime the font cache. %{py3_test_envvars} %{python3} -c 'import matplotlib.font_manager' @@ -367,6 +394,7 @@ env MPLCONFIGDIR=$PWD \ %{pytest} -ra -n auto \ -m 'not network' -k "${k-}" \ --pyargs matplotlib mpl_toolkits.axes_grid1 mpl_toolkits.axisartist mpl_toolkits.mplot3d +%ifnarch %{ix86} # Skip GTK3Cairo tests that are broken in virtual display. k="${k-}${k+ and }not (test_interactive_thread_safety and gtk3cairo)" k="${k-}${k+ and }not (test_interactive_timers and gtk3cairo)" @@ -384,6 +412,7 @@ xwfb-run -- env MPLCONFIGDIR=$PWD \ -m 'not network' -k "${k-}" \ --pyargs matplotlib.tests.test_backend_gtk3 matplotlib.tests.test_backend_qt matplotlib.tests.test_backend_tk matplotlib.tests.test_backends_interactive %endif +%endif %files -n python3-matplotlib-data-fonts