commit:     d818d4f5528ca5db8095b4c7466013c1086c2801
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 30 01:45:58 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Aug 30 01:45:58 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d818d4f5

media-gfx/mypaint: fix runtime issues w/ >=numpy-2

Unfortunately, the testsuite is disabled still as it relies on `setup.py test`.

Upstream are slowly porting to Meson though.

Closes: https://bugs.gentoo.org/961072
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../mypaint/files/mypaint-2.0.1-numpy-2.patch      | 83 ++++++++++++++++++
 media-gfx/mypaint/mypaint-2.0.1-r5.ebuild          | 98 ++++++++++++++++++++++
 2 files changed, 181 insertions(+)

diff --git a/media-gfx/mypaint/files/mypaint-2.0.1-numpy-2.patch 
b/media-gfx/mypaint/files/mypaint-2.0.1-numpy-2.patch
new file mode 100644
index 000000000000..3cefe0895395
--- /dev/null
+++ b/media-gfx/mypaint/files/mypaint-2.0.1-numpy-2.patch
@@ -0,0 +1,83 @@
+https://bugs.gentoo.org/961072
+
+Original commits:
+* 
https://github.com/mypaint/mypaint/commit/2a92b6baf452aba2cff3cc0a7782b301da3933d7
+* 
https://github.com/mypaint/mypaint/commit/ab017e073e83a4930a0fb09608682bf4b7ab1874
+
+Use the backport variants from wip/2.x-backports:
+* 
https://github.com/mypaint/mypaint/commit/1b5fa7ab6f13858d5747ca6eee6b4e8a6de265d1
+* 
https://github.com/mypaint/mypaint/commit/cbc3a41c4d4333a3cd4930dc833385febc0ccfab
+
+From 1b5fa7ab6f13858d5747ca6eee6b4e8a6de265d1 Mon Sep 17 00:00:00 2001
+From: Jan Tojnar <[email protected]>
+Date: Sun, 4 Aug 2024 05:41:28 +0200
+Subject: [PATCH] strokemap: Replace deprecated tostring with tobytes
+
+https: 
//numpy.org/devdocs/reference/generated/numpy.ndarray.tostring.html#numpy.ndarray.tostring
+
+(cherry picked from commit 2a92b6baf452aba2cff3cc0a7782b301da3933d7)
+---
+ lib/strokemap.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/strokemap.py b/lib/strokemap.py
+index 204c1da72..fe3f85d72 100644
+--- a/lib/strokemap.py
++++ b/lib/strokemap.py
+@@ -411,7 +411,7 @@ class _Tile:
+ 
+     """
+ 
+-    _ZDATA_ONES = zlib.compress(np.ones((N, N), 'uint8').tostring())
++    _ZDATA_ONES = zlib.compress(np.ones((N, N), 'uint8').tobytes())
+ 
+     def __init__(self):
+         """Initialize, as a tile filled with all ones."""
+@@ -451,7 +451,7 @@ def new_from_array(cls, array):
+             tile._zdata = None
+         else:
+             tile._all = False
+-            tile._zdata = zlib.compress(array.tostring())
++            tile._zdata = zlib.compress(array.tobytes())
+         return tile
+ 
+     @classmethod
+From cbc3a41c4d4333a3cd4930dc833385febc0ccfab Mon Sep 17 00:00:00 2001
+From: askmeaboutlo0m <[email protected]>
+Date: Mon, 23 Jun 2025 15:51:28 +0200
+Subject: [PATCH] Replace tostring() with tobytes() in stroke.py (#1300)
+
+Because numpy removed the former function (in a minor release) with
+numpy/numpy#28254. The function was an alias, so there's no change in
+behavior, i.e. it always returned bytes.
+
+See also 2a92b6baf452aba2cff3cc0a7782b301da3933d7, where the same
+function was already replaced in strokemap.py.
+
+(cherry picked from commit ab017e073e83a4930a0fb09608682bf4b7ab1874)
+---
+ lib/stroke.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/stroke.py b/lib/stroke.py
+index 22991bc4a..7c41e8481 100644
+--- a/lib/stroke.py
++++ b/lib/stroke.py
+@@ -43,7 +43,7 @@ def start_recording(self, brush):
+ 
+         states = brush.get_states_as_array()
+         assert states.dtype == 'float32'
+-        self.brush_state = states.tostring()
++        self.brush_state = states.tobytes()
+ 
+         self.brush = brush
+         self.brush.new_stroke()  # resets the stroke_* members of the brush
+@@ -63,7 +63,7 @@ def stop_recording(self):
+         # - for space: just gzip? use integer datatypes?
+         # - for time: maybe already use array storage while recording?
+         data = np.array(self.tmp_event_list, dtype='float64')
+-        data = data.tostring()
++        data = data.tobytes()
+         version = b'2'
+         self.stroke_data = version + data
+ 

diff --git a/media-gfx/mypaint/mypaint-2.0.1-r5.ebuild 
b/media-gfx/mypaint/mypaint-2.0.1-r5.ebuild
new file mode 100644
index 000000000000..470f6273b82b
--- /dev/null
+++ b/media-gfx/mypaint/mypaint-2.0.1-r5.ebuild
@@ -0,0 +1,98 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{11..13} )
+
+inherit desktop edo python-single-r1 toolchain-funcs xdg
+
+DESCRIPTION="Fast and easy graphics application for digital painters"
+HOMEPAGE="https://www.mypaint.app/en/";
+SRC_URI="https://github.com/mypaint/${PN}/releases/download/v${PV}/${P}.tar.xz";
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~arm64 ~x86"
+IUSE="openmp"
+LANGS="cs de en_CA en_GB es fr hu id it ja ko nb nn_NO pl pt_BR ro ru sl sv uk 
zh_CN zh_TW"
+# Relies on setup.py test (long-removed) and nose (also long-removed)
+# See bug #927525 and https://github.com/mypaint/mypaint/issues/1191
+RESTRICT="test"
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+
+RDEPEND="
+       ${PYTHON_DEPS}
+       $(python_gen_cond_dep '
+               dev-python/pygobject:3[${PYTHON_USEDEP}]
+               dev-python/numpy[${PYTHON_USEDEP}]
+               >=dev-python/pycairo-1.4[${PYTHON_USEDEP}]
+               dev-python/protobuf[${PYTHON_USEDEP}]
+       ')
+       >=dev-libs/json-c-0.11:=
+       gnome-base/librsvg
+       media-gfx/mypaint-brushes:2.0
+       media-libs/lcms:2
+       >=media-libs/libmypaint-1.5.0[openmp?]
+       media-libs/libpng:=
+       sys-devel/gettext
+       llvm-runtimes/openmp
+       x11-libs/gdk-pixbuf[jpeg]
+       x11-libs/gtk+:3
+"
+DEPEND="${RDEPEND}"
+BDEPEND="
+       ${PYTHON_DEPS}
+       $(python_gen_cond_dep '
+               dev-python/setuptools[${PYTHON_USEDEP}]
+       ')
+       dev-lang/swig
+       sys-devel/gettext
+       virtual/pkgconfig
+"
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-2.0.1-r1-build-system.patch
+       "${FILESDIR}"/${P}-GIL-hold.patch
+       "${FILESDIR}"/${P}-setuptools.patch
+       "${FILESDIR}"/${PN}-2.0.1-python3.11.patch
+       "${FILESDIR}"/${PN}-2.0.1-numpy-2.patch
+)
+
+pkg_pretend() {
+       [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
+}
+
+pkg_setup() {
+       [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
+       python-single-r1_pkg_setup
+}
+
+src_compile() {
+       # --disable-openmp can't be passed to setup.py build,
+       # only setup.py build_ext.
+       # Trying to call build_ext then build and such fails.
+       #
+       # We just override the environment instead for simplicity.
+       local openmp=$(usex openmp '-fopenmp' '-fno-openmp')
+
+       local -x OPENMP_CFLAG="${openmp}" OPENMP_LDFLAG="${openmp}"
+       edo ${EPYTHON} setup.py build
+}
+
+src_install() {
+       edo ${EPYTHON} setup.py install --prefix="${EPREFIX}/usr" --root="${D}"
+       python_fix_shebang "${ED}"/usr/bin
+       python_optimize
+       python_optimize "${ED}/usr/lib/mypaint"
+       einstalldocs
+
+       newicon pixmaps/${PN}_logo.png ${PN}.png
+
+       local lang=
+       for lang in ${LANGS}; do
+               if ! has ${lang} ${LINGUAS}; then
+                       rm -rf "${ED}"/usr/share/locale/${lang} || die
+               fi
+       done
+}

Reply via email to