Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/pyside2/files/, dev-python/pyside2/
Date: Thu, 30 Jun 2022 16:57:02
Message-Id: 1656608210.acf04e5ee236c13d4ee5c44dfb26aa887d768e74.sam@gentoo
1 commit: acf04e5ee236c13d4ee5c44dfb26aa887d768e74
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jun 30 15:54:15 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Thu Jun 30 16:56:50 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=acf04e5e
7
8 dev-python/pyside2: add Python 3.11 compatibility
9
10 Signed-off-by: Sam James <sam <AT> gentoo.org>
11
12 .../files/pyside2-5.15.2-python311-fixups.patch | 54 ++++++
13 .../pyside2/files/pyside2-5.15.2-python311.patch | 41 ++++
14 dev-python/pyside2/pyside2-5.15.2-r2.ebuild | 216 +++++++++++++++++++++
15 3 files changed, 311 insertions(+)
16
17 diff --git a/dev-python/pyside2/files/pyside2-5.15.2-python311-fixups.patch b/dev-python/pyside2/files/pyside2-5.15.2-python311-fixups.patch
18 new file mode 100644
19 index 000000000000..d91b0b6806ca
20 --- /dev/null
21 +++ b/dev-python/pyside2/files/pyside2-5.15.2-python311-fixups.patch
22 @@ -0,0 +1,54 @@
23 +The Fedora / upstream fixes (shiboken2-5.15.2-python311.patch) end up breaking
24 +Python 3.8 compatibility (maybe 3.9 too, but didn't get that far).
25 +
26 +Wrap them with PY_VERSION_HEX for Python 3.11.
27 +--- a/libpyside/pysideqflags.cpp
28 ++++ b/libpyside/pysideqflags.cpp
29 +@@ -187,7 +187,12 @@ namespace QFlags
30 + }
31 + newspec.slots = SbkNewQFlagsType_spec.slots;
32 + PyTypeObject *type = (PyTypeObject *)SbkType_FromSpec(&newspec);
33 +- Py_SET_TYPE(type, &PyType_Type);
34 ++
35 ++ #if PY_VERSION_HEX < 0x030B00A1
36 ++ Py_TYPE(type) = &PyType_Type;
37 ++ #else
38 ++ Py_SET_TYPE(type, &PyType_Type);
39 ++ #endif
40 +
41 + PySideQFlagsType *flagsType = reinterpret_cast<PySideQFlagsType *>(type);
42 + PepType_PFTP(flagsType)->converterPtr = &PepType_PFTP(flagsType)->converter;
43 +--- a/libpyside/pysidesignal.cpp
44 ++++ b/libpyside/pysidesignal.cpp
45 +@@ -162,7 +162,13 @@ PyTypeObject *PySideSignalTypeF(void)
46 + if (!type) {
47 + type = reinterpret_cast<PyTypeObject *>(SbkType_FromSpec(&PySideSignalType_spec));
48 + PyTypeObject *hold = Py_TYPE(type);
49 +- Py_SET_TYPE(type, PySideMetaSignalTypeF());
50 ++
51 ++ #if PY_VERSION_HEX < 0x030B00A1
52 ++ Py_TYPE(type) = PySideMetaSignalTypeF();
53 ++ #else
54 ++ Py_SET_TYPE(type, PySideMetaSignalTypeF());
55 ++ #endif
56 ++
57 + Py_INCREF(Py_TYPE(type));
58 + Py_DECREF(hold);
59 + }
60 +--- a/libpyside/pysideweakref.cpp
61 ++++ b/libpyside/pysideweakref.cpp
62 +@@ -90,7 +90,13 @@ PyObject *create(PyObject *obj, PySideWeakRefFunction func, void *userData)
63 +
64 + if (Py_TYPE(PySideCallableObjectTypeF()) == 0)
65 + {
66 +- Py_SET_TYPE(PySideCallableObjectTypeF(), &PyType_Type);
67 ++
68 ++ #if PY_VERSION_HEX < 0x030B00A1
69 ++ Py_TYPE(PySideCallableObjectTypeF()) = &PyType_Type;
70 ++ #else
71 ++ Py_SET_TYPE(PySideCallableObjectTypeF(), &PyType_Type);
72 ++ #endif
73 ++
74 + PyType_Ready(PySideCallableObjectTypeF());
75 + }
76 +
77
78 diff --git a/dev-python/pyside2/files/pyside2-5.15.2-python311.patch b/dev-python/pyside2/files/pyside2-5.15.2-python311.patch
79 new file mode 100644
80 index 000000000000..70b07c4800fd
81 --- /dev/null
82 +++ b/dev-python/pyside2/files/pyside2-5.15.2-python311.patch
83 @@ -0,0 +1,41 @@
84 +https://src.fedoraproject.org/fork/pviktori/rpms/python-pyside2/raw/5da9902bd8732b49eb722d71f306d4ab197c84b8/f/python3.11.patch
85 +
86 +From 77fdd690ca14e97b4c800c4127362ca0c83a716a Mon Sep 17 00:00:00 2001
87 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@×××××××.cz>
88 +Date: Thu, 9 Jun 2022 13:45:07 +0200
89 +Subject: [PATCH] Fix usage of Py_TYPE() for Python 3.11
90 +
91 +The macro was changed to a function, no longer allowing for assignment.
92 +--- a/libpyside/pysideqflags.cpp
93 ++++ b/libpyside/pysideqflags.cpp
94 +@@ -187,7 +187,7 @@ namespace QFlags
95 + }
96 + newspec.slots = SbkNewQFlagsType_spec.slots;
97 + PyTypeObject *type = (PyTypeObject *)SbkType_FromSpec(&newspec);
98 +- Py_TYPE(type) = &PyType_Type;
99 ++ Py_SET_TYPE(type, &PyType_Type);
100 +
101 + PySideQFlagsType *flagsType = reinterpret_cast<PySideQFlagsType *>(type);
102 + PepType_PFTP(flagsType)->converterPtr = &PepType_PFTP(flagsType)->converter;
103 +--- a/libpyside/pysidesignal.cpp
104 ++++ b/libpyside/pysidesignal.cpp
105 +@@ -162,7 +162,7 @@ PyTypeObject *PySideSignalTypeF(void)
106 + if (!type) {
107 + type = reinterpret_cast<PyTypeObject *>(SbkType_FromSpec(&PySideSignalType_spec));
108 + PyTypeObject *hold = Py_TYPE(type);
109 +- Py_TYPE(type) = PySideMetaSignalTypeF();
110 ++ Py_SET_TYPE(type, PySideMetaSignalTypeF());
111 + Py_INCREF(Py_TYPE(type));
112 + Py_DECREF(hold);
113 + }
114 +--- a/libpyside/pysideweakref.cpp
115 ++++ b/libpyside/pysideweakref.cpp
116 +@@ -90,7 +90,7 @@ PyObject *create(PyObject *obj, PySideWeakRefFunction func, void *userData)
117 +
118 + if (Py_TYPE(PySideCallableObjectTypeF()) == 0)
119 + {
120 +- Py_TYPE(PySideCallableObjectTypeF()) = &PyType_Type;
121 ++ Py_SET_TYPE(PySideCallableObjectTypeF(), &PyType_Type);
122 + PyType_Ready(PySideCallableObjectTypeF());
123 + }
124 +
125
126 diff --git a/dev-python/pyside2/pyside2-5.15.2-r2.ebuild b/dev-python/pyside2/pyside2-5.15.2-r2.ebuild
127 new file mode 100644
128 index 000000000000..1956ebcc9ea0
129 --- /dev/null
130 +++ b/dev-python/pyside2/pyside2-5.15.2-r2.ebuild
131 @@ -0,0 +1,216 @@
132 +# Copyright 1999-2022 Gentoo Authors
133 +# Distributed under the terms of the GNU General Public License v2
134 +
135 +EAPI=8
136 +
137 +# TODO: Add PyPy once officially supported. See also:
138 +# https://bugreports.qt.io/browse/PYSIDE-535
139 +PYTHON_COMPAT=( python3_{8..11} )
140 +
141 +inherit cmake python-r1 virtualx
142 +
143 +# TODO: Add conditional support for "QtRemoteObjects" via a new "remoteobjects"
144 +# USE flag after an external "dev-qt/qtremoteobjects" package has been created.
145 +# TODO: Add conditional support for apidoc generation via a new "doc" USE flag.
146 +# Note that doing so requires the Qt source tree, sphinx, and graphviz. Once
147 +# ready, pass the ${QT_SRC_DIR} variable to cmake to enable this support.
148 +# TODO: Disable GLES support if the "gles2-only" USE flag is disabled. Note
149 +# that the "PySide2/QtGui/CMakeLists.txt" and
150 +# "PySide2/QtOpenGLFunctions/CMakeLists.txt" files test for GLES support by
151 +# testing whether the "Qt5::Gui" list property defined by
152 +# "/usr/lib64/cmake/Qt5Gui/Qt5GuiConfig.cmake" at "dev-qt/qtgui" installation
153 +# time contains the substring "opengles2". Since cmake does not permit
154 +# properties to be overridden from the command line, these files must instead
155 +# be conditionally patched to avoid these tests. An issue should be filed with
156 +# upstream requesting a CLI-settable variable to control this.
157 +
158 +MY_P=pyside-setup-opensource-src-${PV}
159 +
160 +DESCRIPTION="Python bindings for the Qt framework"
161 +HOMEPAGE="https://wiki.qt.io/PySide2"
162 +SRC_URI="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${PV}-src/${MY_P}.tar.xz"
163 +S="${WORKDIR}/${MY_P}/sources/pyside2"
164 +
165 +# See "sources/pyside2/PySide2/licensecomment.txt" for licensing details.
166 +LICENSE="|| ( GPL-2 GPL-3+ LGPL-3 )"
167 +SLOT="0"
168 +KEYWORDS="~amd64 ~arm ~arm64 ~x86"
169 +IUSE="
170 + 3d charts concurrent datavis designer gles2-only +gui help location
171 + multimedia +network positioning printsupport qml quick script scripttools
172 + scxml sensors speech sql svg test testlib webchannel webengine websockets
173 + +widgets x11extras xml xmlpatterns
174 +"
175 +
176 +# Manually reextract these requirements on version bumps by running the
177 +# following one-liner from within "${S}":
178 +# $ grep 'set.*_deps' PySide2/Qt*/CMakeLists.txt
179 +# Note that the "designer" USE flag corresponds to the "Qt5UiTools" module.
180 +REQUIRED_USE="${PYTHON_REQUIRED_USE}
181 + 3d? ( gui network )
182 + charts? ( widgets )
183 + datavis? ( gui )
184 + designer? ( widgets xml )
185 + gles2-only? ( gui )
186 + help? ( widgets )
187 + location? ( positioning )
188 + multimedia? ( gui network )
189 + printsupport? ( widgets )
190 + qml? ( gui network )
191 + quick? ( qml )
192 + scripttools? ( gui script widgets )
193 + speech? ( multimedia )
194 + sql? ( widgets )
195 + svg? ( widgets )
196 + testlib? ( widgets )
197 + webengine? (
198 + location quick
199 + widgets? ( gui network printsupport webchannel )
200 + )
201 + websockets? ( network )
202 + widgets? ( gui )
203 + x11extras? ( gui )
204 +"
205 +
206 +# Tests fail pretty bad and I'm not fixing them right now
207 +RESTRICT="test"
208 +
209 +# Minimal supported version of Qt.
210 +QT_PV="$(ver_cut 1-2):5"
211 +
212 +RDEPEND="${PYTHON_DEPS}
213 + >=dev-python/shiboken2-${PV}[${PYTHON_USEDEP}]
214 + dev-qt/qtcore:5=
215 + dev-qt/qtopengl:5=
216 + dev-qt/qtserialport:5=
217 + 3d? ( >=dev-qt/qt3d-${QT_PV}[qml?] )
218 + charts? ( >=dev-qt/qtcharts-${QT_PV}[qml?] )
219 + concurrent? ( >=dev-qt/qtconcurrent-${QT_PV} )
220 + datavis? ( >=dev-qt/qtdatavis3d-${QT_PV}[qml?] )
221 + designer? ( >=dev-qt/designer-${QT_PV} )
222 + gui? ( >=dev-qt/qtgui-${QT_PV}[jpeg,gles2-only?] )
223 + help? ( >=dev-qt/qthelp-${QT_PV} )
224 + location? ( >=dev-qt/qtlocation-${QT_PV} )
225 + multimedia? ( >=dev-qt/qtmultimedia-${QT_PV}[qml?,widgets?] )
226 + network? ( >=dev-qt/qtnetwork-${QT_PV} )
227 + positioning? ( >=dev-qt/qtpositioning-${QT_PV}[qml?] )
228 + printsupport? ( >=dev-qt/qtprintsupport-${QT_PV} )
229 + qml? ( >=dev-qt/qtdeclarative-${QT_PV}[widgets?] )
230 + script? ( >=dev-qt/qtscript-${QT_PV} )
231 + scxml? ( >=dev-qt/qtscxml-${QT_PV} )
232 + sensors? ( >=dev-qt/qtsensors-${QT_PV}[qml?] )
233 + speech? ( >=dev-qt/qtspeech-${QT_PV} )
234 + sql? ( >=dev-qt/qtsql-${QT_PV} )
235 + svg? ( >=dev-qt/qtsvg-${QT_PV} )
236 + testlib? ( >=dev-qt/qttest-${QT_PV} )
237 + webchannel? ( >=dev-qt/qtwebchannel-${QT_PV}[qml?] )
238 + webengine? ( >=dev-qt/qtwebengine-${QT_PV}[widgets?] )
239 + websockets? ( >=dev-qt/qtwebsockets-${QT_PV}[qml?] )
240 + widgets? ( >=dev-qt/qtwidgets-${QT_PV} )
241 + x11extras? ( >=dev-qt/qtx11extras-${QT_PV} )
242 + xml? ( >=dev-qt/qtxml-${QT_PV} )
243 + xmlpatterns? ( >=dev-qt/qtxmlpatterns-${QT_PV}[qml?] )
244 +"
245 +DEPEND="${RDEPEND}
246 + test? ( x11-misc/xvfb-run )
247 +"
248 +
249 +PATCHES=(
250 + "${FILESDIR}/${P}-python310.patch"
251 + "${FILESDIR}/${P}-python311.patch"
252 + "${FILESDIR}"/${PN}-5.15.2-python311-fixups.patch
253 +)
254 +
255 +src_configure() {
256 + # See COLLECT_MODULE_IF_FOUND macros in CMakeLists.txt
257 + local mycmakeargs=(
258 + -DBUILD_TESTS=$(usex test)
259 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt53DAnimation=$(usex !3d)
260 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt53DCore=$(usex !3d)
261 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt53DExtras=$(usex !3d)
262 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt53DInput=$(usex !3d)
263 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt53DLogic=$(usex !3d)
264 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt53DRender=$(usex !3d)
265 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Charts=$(usex !charts)
266 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Concurrent=$(usex !concurrent)
267 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5DataVisualization=$(usex !datavis)
268 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Designer=$(usex !designer)
269 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Gui=$(usex !gui)
270 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Help=$(usex !help)
271 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Location=$(usex !location)
272 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Multimedia=$(usex !multimedia)
273 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5MultimediaWidgets=$(usex !multimedia yes $(usex !widgets))
274 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Network=$(usex !network)
275 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Positioning=$(usex !positioning)
276 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5PrintSupport=$(usex !printsupport)
277 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Qml=$(usex !qml)
278 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Quick=$(usex !quick)
279 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5QuickWidgets=$(usex !quick yes $(usex !widgets))
280 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Script=$(usex !script)
281 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5ScriptTools=$(usex !scripttools)
282 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Scxml=$(usex !scxml)
283 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Sensors=$(usex !sensors)
284 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5TextToSpeech=$(usex !speech)
285 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Sql=$(usex !sql)
286 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Svg=$(usex !svg)
287 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Test=$(usex !testlib)
288 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5UiTools=$(usex !designer)
289 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5WebChannel=$(usex !webchannel)
290 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5WebEngine=$(usex !webengine)
291 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5WebEngineCore=$(usex !webengine)
292 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5WebEngineWidgets=$(usex !webengine yes $(usex !widgets))
293 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5WebSockets=$(usex !websockets)
294 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Widgets=$(usex !widgets)
295 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5X11Extras=$(usex !x11extras)
296 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Xml=$(usex !xml)
297 + -DCMAKE_DISABLE_FIND_PACKAGE_Qt5XmlPatterns=$(usex !xmlpatterns)
298 + )
299 +
300 + pyside2_configure() {
301 + local mycmakeargs=(
302 + "${mycmakeargs[@]}"
303 + -DPYTHON_CONFIG_SUFFIX="-${EPYTHON}"
304 + -DPYTHON_EXECUTABLE="${PYTHON}"
305 + -DPYTHON_SITE_PACKAGES="$(python_get_sitedir)"
306 + -DSHIBOKEN_PYTHON_SHARED_LIBRARY_SUFFIX="-${EPYTHON}"
307 + )
308 + cmake_src_configure
309 + }
310 + python_foreach_impl pyside2_configure
311 +}
312 +
313 +src_compile() {
314 + python_foreach_impl cmake_src_compile
315 +}
316 +
317 +src_test() {
318 + local -x PYTHONDONTWRITEBYTECODE
319 + python_foreach_impl virtx cmake_src_test
320 +}
321 +
322 +src_install() {
323 + pyside2_install() {
324 + cmake_src_install
325 + python_optimize
326 +
327 + # Uniquify the shiboken2 pkgconfig dependency in the PySide2 pkgconfig
328 + # file for the current Python target. See also:
329 + # https://github.com/leycec/raiagent/issues/73
330 + sed -i -e 's~^Requires: shiboken2$~&-'${EPYTHON}'~' \
331 + "${ED}/usr/$(get_libdir)"/pkgconfig/${PN}.pc || die
332 +
333 + # Uniquify the PySide2 pkgconfig file for the current Python target,
334 + # preserving an unversioned "pyside2.pc" file arbitrarily associated
335 + # with the last Python target. (See the previously linked issue.)
336 + cp "${ED}/usr/$(get_libdir)"/pkgconfig/${PN}{,-${EPYTHON}}.pc || die
337 + }
338 + python_foreach_impl pyside2_install
339 +
340 + # CMakeLists.txt installs a "PySide2Targets-gentoo.cmake" file forcing
341 + # downstream consumers (e.g., pyside2-tools) to target one
342 + # "libpyside2-*.so" library linked to one Python interpreter. See also:
343 + # https://bugreports.qt.io/browse/PYSIDE-1053
344 + # https://github.com/leycec/raiagent/issues/74
345 + sed -i -e 's~pyside2-python[[:digit:]]\+\.[[:digit:]]\+~pyside2${PYTHON_CONFIG_SUFFIX}~g' \
346 + "${ED}/usr/$(get_libdir)/cmake/PySide2-${PV}/PySide2Targets-${CMAKE_BUILD_TYPE,,}.cmake" || die
347 +}