commit:     50adb7ff6f2b959ae8284133adcdb60ff53d15ec
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 10 04:15:54 2021 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Oct 10 04:56:41 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=50adb7ff

dev-python/pyqtgraph: enable py3.10, cleanup

- do the prepare for testing inside src_test
- testing depends on opengl and svg use flags
- use EPYTEST_DESELECT
- add missing "|| die" for git calls

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 .../files/pyqtgraph-0.12.2-fix-py3.10.patch        | 46 ++++++++++++++++++++
 dev-python/pyqtgraph/pyqtgraph-0.12.2.ebuild       | 49 ++++++++++++----------
 2 files changed, 73 insertions(+), 22 deletions(-)

diff --git a/dev-python/pyqtgraph/files/pyqtgraph-0.12.2-fix-py3.10.patch 
b/dev-python/pyqtgraph/files/pyqtgraph-0.12.2-fix-py3.10.patch
new file mode 100644
index 00000000000..bb1e4a8a766
--- /dev/null
+++ b/dev-python/pyqtgraph/files/pyqtgraph-0.12.2-fix-py3.10.patch
@@ -0,0 +1,46 @@
+From db8180d88ed37425467d030bebf7792c86691b83 Mon Sep 17 00:00:00 2001
+From: Scott Talbert <[email protected]>
+Date: Sun, 11 Jul 2021 22:04:00 -0400
+Subject: [PATCH] Fix GLTextItem with Python 3.10
+
+drawText() expects int arguments and Python 3.10 does not allow for
+implicit rounding.
+
+--- a/pyqtgraph/opengl/items/GLTextItem.py
++++ b/pyqtgraph/opengl/items/GLTextItem.py
+@@ -68,15 +68,15 @@ def paint(self):
+         viewport = glGetIntegerv(GL_VIEWPORT)
+
+         text_pos = self.__project(self.pos, modelview, projection, viewport)
+-        text_pos[1] = viewport[3] - text_pos[1]
+
++        text_pos.setY(viewport[3] - text_pos.y())
+         text_pos /= self.view().devicePixelRatio()
+
+         painter = QtGui.QPainter(self.view())
+         painter.setPen(self.color)
+         painter.setFont(self.font)
+         painter.setRenderHints(QtGui.QPainter.RenderHint.Antialiasing | 
QtGui.QPainter.RenderHint.TextAntialiasing)
+-        painter.drawText(text_pos[0], text_pos[1], self.text)
++        painter.drawText(text_pos, self.text)
+         painter.end()
+
+     def __project(self, obj_pos, modelview, projection, viewport):
+@@ -86,12 +86,11 @@ def __project(self, obj_pos, modelview, projection, 
viewport):
+         proj_vec = np.matmul(projection.T, view_vec)
+
+         if proj_vec[3] == 0.0:
+-            return
++            return QtCore.QPointF(0, 0)
+
+         proj_vec[0:3] /= proj_vec[3]
+
+-        return np.array([
+-            viewport[0] + (1.0 + proj_vec[0]) * viewport[2] / 2.0,
+-            viewport[1] + (1.0 + proj_vec[1]) * viewport[3] / 2.0,
+-            (1.0 + proj_vec[2]) / 2.0
+-        ])
++        return QtCore.QPointF(
++            viewport[0] + (1.0 + proj_vec[0]) * viewport[2] / 2,
++            viewport[1] + (1.0 + proj_vec[1]) * viewport[3] / 2
++        )

diff --git a/dev-python/pyqtgraph/pyqtgraph-0.12.2.ebuild 
b/dev-python/pyqtgraph/pyqtgraph-0.12.2.ebuild
index 3bc55a927f1..c6366f824b7 100644
--- a/dev-python/pyqtgraph/pyqtgraph-0.12.2.ebuild
+++ b/dev-python/pyqtgraph/pyqtgraph-0.12.2.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=8
 
-PYTHON_COMPAT=( python3_{8..9} )
+PYTHON_COMPAT=( python3_{8..10} )
 inherit distutils-r1 multiprocessing
 
 TEST_DATA_TAG=test-data-8
@@ -21,6 +21,7 @@ LICENSE="MIT"
 SLOT="0"
 KEYWORDS="amd64 x86"
 IUSE="examples opengl svg"
+REQUIRED_USE="test? ( opengl svg )"
 
 RDEPEND="
        >=dev-python/numpy-1.17[${PYTHON_USEDEP}]
@@ -30,57 +31,61 @@ RDEPEND="
 BDEPEND="
        test? (
                dev-python/h5py[${PYTHON_USEDEP}]
-               dev-python/PyQt5[svg,testlib,${PYTHON_USEDEP}]
+               dev-python/PyQt5[testlib,${PYTHON_USEDEP}]
                dev-python/pytest-xdist[${PYTHON_USEDEP}]
                dev-python/pytest-xvfb[${PYTHON_USEDEP}]
                dev-vcs/git
        )"
 
+PATCHES=(
+       "${FILESDIR}/${P}-fix-py3.10.patch"
+)
+
 distutils_enable_sphinx doc/source
 distutils_enable_tests pytest
 
 python_prepare_all() {
        distutils-r1_python_prepare_all
 
-       if use test; then
-               mkdir "${HOME}"/.pyqtgraph || die
-               mv "${WORKDIR}/test-data-${TEST_DATA_TAG}" \
-                       "${HOME}"/.pyqtgraph/test-data || die
-               cd "${HOME}"/.pyqtgraph/test-data || die
-               # we need to fake a git repo
-               git config --global user.email "[email protected]"
-               git config --global user.name "Your Name"
-               git init -q || die
-               git commit -q --allow-empty -m "dummy commit" || die
-               git tag "${TEST_DATA_TAG}" || die
-               cd - >/dev/null || die
-       fi
        if ! use opengl; then
                rm -r pyqtgraph/opengl || die
        fi
 }
 
 python_test() {
-       local deselect=(
+       local EPYTEST_DESELECT=(
                # apparently fragile
-               --deselect tests/test_reload.py::test_reload
+               tests/test_reload.py::test_reload
 
                # TODO
-               --deselect tests/graphicsItems/test_ROI.py::test_PolyLineROI
+               tests/graphicsItems/test_ROI.py::test_PolyLineROI
 
                # pyside2 is normally skipped if not installed but these two
                # fail if it is installed
                # TODO: this could be due to USE flags, revisit when pyside2
                # gains py3.9
-               --deselect
                'examples/test_examples.py::testExamples[ 
DateAxisItem_QtDesigner.py - PySide2 ]'
-               --deselect
                'examples/test_examples.py::testExamples[ designerExample.py - 
PySide2 ]'
        )
 
        distutils_install_for_testing
-       epytest "${deselect[@]}" \
-               -n "$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")"
+       epytest -n "$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")"
+}
+
+src_test() {
+       mkdir "${HOME}"/.pyqtgraph || die
+       mv "${WORKDIR}/test-data-${TEST_DATA_TAG}" \
+               "${HOME}"/.pyqtgraph/test-data || die
+       cd "${HOME}"/.pyqtgraph/test-data || die
+       # we need to fake a git repo
+       git config --global user.email "[email protected]" || die
+       git config --global user.name "Your Name" || die
+       git init -q || die
+       git commit -q --allow-empty -m "dummy commit" || die
+       git tag "${TEST_DATA_TAG}" || die
+       cd - >/dev/null || die
+
+       distutils-r1_src_test
 }
 
 python_install_all() {

Reply via email to