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@gentoo.org>
This commit is contained in:
Arthur Zamarin
2021-10-10 07:15:54 +03:00
parent ec1aaa4681
commit 50adb7ff6f
2 changed files with 73 additions and 22 deletions

View File

@@ -0,0 +1,46 @@
From db8180d88ed37425467d030bebf7792c86691b83 Mon Sep 17 00:00:00 2001
From: Scott Talbert <swt@techie.net>
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
+ )

View File

@@ -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 "you@example.com"
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 "you@example.com" || 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() {