From 194daaa0df5ff17432f53a18be0cfb7e8e17e5ecce4e18de6679f653d4f1432a Mon Sep 17 00:00:00 2001
From: Christophe Marin <christophe+obs@krop.fr>
Date: Fri, 1 Mar 2024 22:23:56 +0000
Subject: [PATCH] - Build with newer python on Leap 15

OBS-URL: https://build.opensuse.org/package/show/KDE:Extra/krita?expand=0&rev=197
---
 krita.changes |  5 +++++
 krita.spec    | 21 ++++++++-------------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/krita.changes b/krita.changes
index 75d9c42..b8ddb0f 100644
--- a/krita.changes
+++ b/krita.changes
@@ -1,3 +1,8 @@
+-------------------------------------------------------------------
+Fri Mar  1 21:47:15 UTC 2024 - Christophe Marin <christophe@krop.fr>
+
+- Build with newer python on Leap 15
+
 -------------------------------------------------------------------
 Fri Jan 26 15:34:05 UTC 2024 - Ben Greiner <code@bnavigator.de>
 
diff --git a/krita.spec b/krita.spec
index 503b8f4..2a257f2 100644
--- a/krita.spec
+++ b/krita.spec
@@ -24,8 +24,11 @@
 %endif
 %endif
 # Default python version is too old in Leap 15
+%{?sle15_python_module_pythons}
 %if 0%{?suse_version} > 1500
-%bcond_without python
+%define pyver python3
+%else
+%define pyver python311
 %endif
 # SR#1043861 for 15.5
 %if 0%{?suse_version} > 1500 || (0%{?is_opensuse} && 0%{?sle_version} > 150400)
@@ -71,11 +74,9 @@ BuildRequires:  libtiff-devel
 BuildRequires:  openjpeg2-devel
 BuildRequires:  perl
 BuildRequires:  pkgconfig
-%if %{with python}
-BuildRequires:  python3-devel
-BuildRequires:  python3-qt5-devel
-BuildRequires:  python3-sip-devel
-%endif
+BuildRequires:  %{pyver}-devel
+BuildRequires:  %{pyver}-qt5-devel
+BuildRequires:  %{pyver}-sip-devel
 BuildRequires:  update-desktop-files
 BuildRequires:  zlib-devel
 BuildRequires:  cmake(Immer)
@@ -127,9 +128,7 @@ BuildRequires:  pkgconfig(libwebp)
 BuildRequires:  pkgconfig(xcb-atom)
 BuildRequires:  pkgconfig(xcb-xinput)
 BuildRequires:  pkgconfig(xi) >= 1.4.99.1
-%if %{with python}
-Recommends:     python3-qt5
-%endif
+Recommends:     %{pyver}-qt5
 Obsoletes:      calligra-krita < %{version}
 Provides:       calligra-krita = %{version}
 Recommends:     krita-plugin-gmic
@@ -165,10 +164,8 @@ Development headers and libraries for Krita.
 
 chmod -x %{buildroot}%{_kf5_applicationsdir}/*.desktop
 
-%if %{with python}
 # remove shebang to avoid rpmlint warning, that file is not supposed to be run directly anyway
 sed -i "/#!\/usr\/bin\/env/d" %{buildroot}%{_kf5_libdir}/krita-python-libs/krita/sceditor/highlighter.py
-%endif
 
 %ldconfig_scriptlets
 
@@ -183,9 +180,7 @@ sed -i "/#!\/usr\/bin\/env/d" %{buildroot}%{_kf5_libdir}/krita-python-libs/krita
 %{_kf5_appstreamdir}/
 %{_kf5_libdir}/libkrita*.so.*
 %{_kf5_libdir}/kritaplugins/
-%if %{with python}
 %{_kf5_libdir}/krita-python-libs/
-%endif
 %{_kf5_qmldir}
 %{_kf5_sharedir}/kritaplugins/
 %{_kf5_sharedir}/color/