Skip to contentSkip to conversation

python-sip: fix compile error

PATCH In review Ralf Dragon 4 participants 13 messages Dec 12, 2023 – Mar 10, 2024 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 python-sip: fix compile error

Without the patch, python-sip fails to compile with:

siplib.c: In function ‘sip_api_get_frame’:
siplib.c:13750:22: error: invalid use of undefined type ‘struct _frame’
13750 | frame = frame->f_back;

This likely fixes bug 15201 [1].

[1] https://bugs.buildroot.org/show_bug.cgi?id=15201

---
Backport to: 2023.02.x

 package/python-sip/0002-fixframe.patch | 55 ++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 package/python-sip/0002-fixframe.patch
package/python-sip/0002-fixframe.patch new file +55 -0
new file mode 100644
index 0000000000..befe76fc73
@@ -0,0 +1,55 @@
+siplib: fix build with python >= 3.11
+
+With python 3.11, the PyFrameObject structure members have been
+removed from the public C API:
+
+https://docs.python.org/3.11/whatsnew/3.11.html#whatsnew311-c-api-porting
+https://docs.python.org/3.11/whatsnew/3.11.html#pyframeobject-3-11-hiding
+
+This patch migrates to the opaque PyFrameObject.
+
+Signed-off-by: Ralf Dragon <[email protected]>
+Upstream: N/A as SIP v4 is no longer supported. 4.19.25 is the last release.
+
+--- host-python-sip-4.19.25.orig/siplib/sip.h
++++ host-python-sip-4.19.25/siplib/sip.h
+@@ -1799,7 +1799,7 @@
+     int (*api_get_time)(PyObject *, sipTimeDef *);
+     PyObject *(*api_from_time)(const sipTimeDef *);
+     int (*api_is_user_type)(const sipWrapperType *);
+-    struct _frame *(*api_get_frame)(int);
++    PyFrameObject *(*api_get_frame)(int);
+     int (*api_check_plugin_for_type)(const sipTypeDef *, const char *);
+     PyObject *(*api_unicode_new)(SIP_SSIZE_T, unsigned, int *, void **);
+     void (*api_unicode_write)(int, void *, int, unsigned);
+
+
+--- host-python-sip-4.19.25.orig/siplib/siplib.c
++++ host-python-sip-4.19.25/siplib/siplib.c
+@@ -448,7 +448,7 @@
+ static int sip_api_get_time(PyObject *obj, sipTimeDef *time);
+ static PyObject *sip_api_from_time(const sipTimeDef *time);
+ static int sip_api_is_user_type(const sipWrapperType *wt);
+-static struct _frame *sip_api_get_frame(int);
++static PyFrameObject *sip_api_get_frame(int);
+ static int sip_api_check_plugin_for_type(const sipTypeDef *td,
+         const char *name);
+ static PyObject *sip_api_unicode_new(SIP_SSIZE_T len, unsigned maxchar,
+@@ -13741,13 +13741,13 @@
+ /*
+  * Return a frame from the execution stack.
+  */
+-static struct _frame *sip_api_get_frame(int depth)
++static PyFrameObject *sip_api_get_frame(int depth)
+ {
+-    struct _frame *frame = PyEval_GetFrame();
++    PyFrameObject *frame = PyEval_GetFrame();
+ 
+     while (frame != NULL && depth > 0)
+     {
+-        frame = frame->f_back;
++        frame = PyFrame_GetBack(frame);
+         --depth;
+     }
+ 
+
Signature · 6 lines
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 2/2 python-qt5: add PyQt5.sip module

This fixes the following runtime error when importing PyQt5 in python:

from PyQt5.QtCore import *
ModuleNotFoundError: No module named 'PyQt5.sip'

---
Backport to: 2023.02.x

 package/Config.in                              |  1 +
 package/python-pyqt5-sip/Config.in             |  6 ++++++
 package/python-pyqt5-sip/python-pyqt5-sip.hash |  4 ++++
 package/python-pyqt5-sip/python-pyqt5-sip.mk   | 15 +++++++++++++++
 package/python-pyqt5/Config.in                 |  1 +
 5 files changed, 27 insertions(+)
 create mode 100644 package/python-pyqt5-sip/Config.in
 create mode 100644 package/python-pyqt5-sip/python-pyqt5-sip.hash
 create mode 100644 package/python-pyqt5-sip/python-pyqt5-sip.mk
package/Config.in +1 -0
index fcc09b07c4..2d6a077d16 100644
@@ -1253,6 +1253,7 @@ menu "External python modules"
 	source "package/python-pyphen/Config.in"
 	source "package/python-pyqrcode/Config.in"
 	source "package/python-pyqt5/Config.in"
+	source "package/python-pyqt5-sip/Config.in"
 	source "package/python-pyratemp/Config.in"
 	source "package/python-pyroute2/Config.in"
 	source "package/python-pyrsistent/Config.in"
package/python-pyqt5-sip/Config.in new file +6 -0
new file mode 100644
index 0000000000..6f26271f70
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_PYTHON_PYQT5_SIP
+	bool "python-pyqt5-sip"
+	depends on BR2_PACKAGE_PYTHON_PYQT5
+	depends on BR2_PACKAGE_PYTHON_SIP
+	help
+	  This is the PyQt5.sip module which is needed to run PyQt5.
package/python-pyqt5-sip/python-pyqt5-sip.hash new file +4 -0
new file mode 100644
index 0000000000..8039cdafd9
@@ -0,0 +1,4 @@
+# from https://pypi.org/project/PyQt5-sip/12.12.1
+
+sha256  8fdc6e0148abd12d977a1d3828e7b79aae958e83c6cb5adae614916d888a6b10  PyQt5_sip-12.12.1.tar.gz
+md5  c2117da3b4c0e081c1c5a9088b8a4d55  PyQt5_sip-12.12.1.tar.gz
package/python-pyqt5-sip/python-pyqt5-sip.mk new file +15 -0
new file mode 100644
index 0000000000..3f689b9d47
@@ -0,0 +1,15 @@
+################################################################################
+#
+# python-SIP-QT5
+#
+################################################################################
+
+PYTHON_PYQT5_SIP_VERSION = 12.12.1
+PYTHON_PYQT5_SIP_SITE = https://files.pythonhosted.org/packages/c1/61/4055e7a0f36339964956ff415e36f4abf82561904cc49c021da32949fc55
+PYTHON_PYQT5_SIP_SOURCE = PyQt5_sip-$(PYTHON_PYQT5_SIP_VERSION).tar.gz
+PYTHON_PYQT5_SIP_LICENSE = MIT
+PYTHON_PYQT5_SIP_LICENSE_FILES = LICENSE
+PYTHON_PYQT5_SIP_SETUP_TYPE = setuptools
+PYTHON_PYQT5_SIP_DEPENDENCIES += python-sip
+
+$(eval $(python-package))
package/python-pyqt5/Config.in +1 -0
index 9fa7676f98..c2a1976950 100644
@@ -5,6 +5,7 @@ config BR2_PACKAGE_PYTHON_PYQT5
 	bool "python-pyqt5"
 	depends on BR2_PACKAGE_QT5
 	select BR2_PACKAGE_PYTHON_SIP
+	select BR2_PACKAGE_PYTHON_PYQT5_SIP
 	select BR2_PACKAGE_QT5BASE_GUI
 	help
 	  Python bindings for Qt 5
Signature · 6 lines
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [PATCH 2/2] python-qt5: add PyQt5.sip module

Hello Ralf,

Quoted 4 lines · On Tue, 12 Dec 2023 17:01:12 +0100 Ralf Dragon <[email protected]> wrote:

This fixes the following runtime error when importing PyQt5 in python:

from PyQt5.QtCore import *
ModuleNotFoundError: No module named 'PyQt5.sip'

So it means that python-pyqt5 requires this new python-pyqt5-sip package? How come has python-pyqt5 ever worked?

package/python-pyqt5-sip/Config.in line 4

Quoted 10 lines
package/python-pyqt5-sip/Config.in new file +4 -0
new file mode 100644
index 0000000000..6f26271f70
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_PYTHON_PYQT5_SIP
+	bool "python-pyqt5-sip"
+	depends on BR2_PACKAGE_PYTHON_PYQT5
+	depends on BR2_PACKAGE_PYTHON_SIP

But, but, according to what you described above, it seems like python-pyqt5 needs python-pyqt5-sip, but here you have a python-pyqt5-sip -> python-pyqt5 dependency.

So with your patch applied, it's still possible to enable only python-pyqt5, so we would still have the failure you're mentioning in your commit log.

Could you clarify?

Also, it would very, very good to add a runtime test case in support/testing/ for this, as such Python issues are only visible at runtime. I have added Julien Olivain in Cc, who can probably help with this, as he is our resident expert in writing support/testing tests :-)

package/python-pyqt5-sip/python-pyqt5-sip.hash line 2

Quoted 8 lines
package/python-pyqt5-sip/python-pyqt5-sip.hash new file +2 -0
new file mode 100644
index 0000000000..8039cdafd9
@@ -0,0 +1,4 @@
+# from https://pypi.org/project/PyQt5-sip/12.12.1
+

Empty line not needed.

package/python-pyqt5-sip/python-pyqt5-sip.mk line 3

Quoted 11 lines
package/python-pyqt5-sip/python-pyqt5-sip.hash new file +2 -0
+sha256  8fdc6e0148abd12d977a1d3828e7b79aae958e83c6cb5adae614916d888a6b10  PyQt5_sip-12.12.1.tar.gz
+md5  c2117da3b4c0e081c1c5a9088b8a4d55  PyQt5_sip-12.12.1.tar.gz
package/python-pyqt5-sip/python-pyqt5-sip.mk new file +3 -0
new file mode 100644
index 0000000000..3f689b9d47
@@ -0,0 +1,15 @@
+################################################################################
+#
+# python-SIP-QT5

Should be all lower-case.

package/python-pyqt5-sip/python-pyqt5-sip.mk line 13

Quoted 10 lines
package/python-pyqt5-sip/python-pyqt5-sip.mk new file +10 -0
+#
+################################################################################
+
+PYTHON_PYQT5_SIP_VERSION = 12.12.1
+PYTHON_PYQT5_SIP_SITE = https://files.pythonhosted.org/packages/c1/61/4055e7a0f36339964956ff415e36f4abf82561904cc49c021da32949fc55
+PYTHON_PYQT5_SIP_SOURCE = PyQt5_sip-$(PYTHON_PYQT5_SIP_VERSION).tar.gz
+PYTHON_PYQT5_SIP_LICENSE = MIT
+PYTHON_PYQT5_SIP_LICENSE_FILES = LICENSE
+PYTHON_PYQT5_SIP_SETUP_TYPE = setuptools
+PYTHON_PYQT5_SIP_DEPENDENCIES += python-sip

No +=, just =.

package/python-pyqt5/Config.in config BR2_PACKAGE_PYTHON_PYQT5 · line 8

Quoted 11 lines
package/python-pyqt5-sip/python-pyqt5-sip.mk new file +2 -0
+
+$(eval $(python-package))
package/python-pyqt5/Config.in +1 -0
index 9fa7676f98..c2a1976950 100644
@@ -5,6 +5,7 @@ config BR2_PACKAGE_PYTHON_PYQT5
 	bool "python-pyqt5"
 	depends on BR2_PACKAGE_QT5
 	select BR2_PACKAGE_PYTHON_SIP
+	select BR2_PACKAGE_PYTHON_PYQT5_SIP

Ah, so python-pyqt5 now selects python-pyqt5-sip, and python-pyqt5-sip also selects python-pyqt5. This sounds like a circular dependency.

Could you perhaps give a bit more background, so that we can provide some better guidance on how to resolve this issue properly?

Thanks a lot!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Re: [Buildroot] [PATCH 2/2] python-qt5: add PyQt5.sip module

Hello Thomas,

Quoted 2 lines

So it means that python-pyqt5 requires this new python-pyqt5-sip package? How come has python-pyqt5 ever worked?

It worked for our community firmware [1] in a buildroot release from 1-2 years ago. When we switched to the 2023 release, we had problems, but I could not imagine that it was a problem for everyone. I think that 5.11 changed the location of the sip module to PyQt5.sip [2] and required building that in a new module (the build instructions [3] do not say since which release that was needed):

[1] https://cfw.ftcommunity.de/ftcommunity-TXT/en
[2] https://www.riverbankcomputing.com/static/Docs/PyQt5/incompatibilities.html#pyqt-v5-11
[3] https://www.riverbankcomputing.com/static/Docs/PyQt5/installation.html#building-the-sip-module

Quoted 8 lines

But, but, according to what you described above, it seems like python-pyqt5 needs python-pyqt5-sip, but here you have a python-pyqt5-sip -> python-pyqt5 dependency.
So with your patch applied, it's still possible to enable only python-pyqt5, so we would still have the failure you're mentioning in your commit log.

Could you clarify?

Both can be compiled independently (when I wrote the patch, I assumed that PyQt5.sip can only be compiled when PyQt5 is available, but it really seems only to depend on the sip library). During runtime, PyQt5 does not work without PyQt5.sip, but it seems that PyQt5.sip can be used without PyQt5. That is also how it is modeled in Debian 12.

So correctly it would be: python-pyqt5 needs python-pyqt5-sip during runtime. I would model that with "select", not "depends on", or?

Quoted 4 lines

Also, it would very, very good to add a runtime test case in support/testing/ for this, as such Python issues are only visible at runtime. I have added Julien Olivain in Cc, who can probably help with this, as he is our resident expert in writing support/testing tests :-)

Just python3 -c "import PyQt5" would probably be enough to reproduce this error.

I will push another patch with the dependency clarified and the other comments.

Is it possible that both patches get integrated into the 2023 lts branch?

Thanks,

Ralf

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw

Re: [Buildroot] [PATCH 2/2] python-qt5: add PyQt5.sip module

Hello Ralf,

Quoted 10 lines · On Mon, 18 Dec 2023 19:22:14 +0100 Ralf Dragon <[email protected]> wrote:
Quoted 2 lines

So it means that python-pyqt5 requires this new python-pyqt5-sip package? How come has python-pyqt5 ever worked?

It worked for our community firmware [1] in a buildroot release from 1-2 years ago. When we switched to the 2023 release, we had problems, but I could not imagine that it was a problem for everyone. I think that 5.11 changed the location of the sip module to PyQt5.sip [2] and required building that in a new module (the build instructions [3] do not say since which release that was needed):

Quoted 5 lines

[1] https://cfw.ftcommunity.de/ftcommunity-TXT/en
[2]
https://www.riverbankcomputing.com/static/Docs/PyQt5/incompatibilities.html#pyqt-v5-11
[3]
https://www.riverbankcomputing.com/static/Docs/PyQt5/installation.html#building-the-sip-module

Thanks for the additional research. However, we need a bit better than "I think". Indeed, we need to understand for sure since when things got broken, so that we understand how this fix should be backported.

Quoted 9 lines
Quoted 8 lines

But, but, according to what you described above, it seems like python-pyqt5 needs python-pyqt5-sip, but here you have a python-pyqt5-sip -> python-pyqt5 dependency.
So with your patch applied, it's still possible to enable only python-pyqt5, so we would still have the failure you're mentioning in your commit log.

Could you clarify?

Quoted 8 lines

Both can be compiled independently (when I wrote the patch, I assumed that PyQt5.sip can only be compiled when PyQt5 is available, but it really seems only to depend on the sip library). During runtime, PyQt5 does not work without PyQt5.sip, but it seems that PyQt5.sip can be used without PyQt5. That is also how it is modeled in Debian 12.

So correctly it would be: python-pyqt5 needs python-pyqt5-sip during runtime. I would model that with "select", not "depends on", or?

python-pyqt5 should then "select BR2_PACKAGE_PYTHON_PYQT5_SIP" with a "# runtime" comment, but it should not have python-pyqt5-sip in its <pkg>_DEPENDENCIES.

Quoted 7 lines
Quoted 4 lines

Also, it would very, very good to add a runtime test case in support/testing/ for this, as such Python issues are only visible at runtime. I have added Julien Olivain in Cc, who can probably help with this, as he is our resident expert in writing support/testing tests :-)

Just python3 -c "import PyQt5" would probably be enough to reproduce this error.

This would already be a good test case indeed.

Quoted 4 lines

I will push another patch with the dependency clarified and the other comments.

Is it possible that both patches get integrated into the 2023 lts branch?

Yes, if we understand when things got broken exactly, as discussed above.

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Re: [Buildroot] [PATCH 2/2] python-qt5: add PyQt5.sip module

Hi Thomas,

Quoted 3 lines

Thanks for the additional research. However, we need a bit better than "I think". Indeed, we need to understand for sure since when things got broken, so that we understand how this fix should be backported.

PyQt 5.13 did not mention this module yet in their installation instructions [1], but for the sake of backporting it is apparently not needed to know when the incompatibility happened:

Not ok are: 2023.02.8, 2023.02.7 and 2023.02.3 (PyQt 5.15) Ok is: 2021.11.3 (PyQt 5.7)

In between these, the only commit touching PyQt's hash is b36ce7e which does this PyQt upgrade in one step. So all LTS branches which have this commit are probably affected. (For completeness: 51c22b4ba905f8 and 7e346f494c1507648f6 also touch the directory but they look both less suspicious.)

Unfortunately I don't have the setup to build and test these branches in an automated way. Maybe the author of the PyQt5 upgrade could clarify whether he used this PyQt5 in practice.

Best,
Ralf

[1] https://web.archive.org/web/20190717063706/https://www.riverbankcomputing.com/static/Docs/PyQt5/installation.html#building-the-sip-module
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#7 lore raw

Re: [Buildroot] [PATCH 2/2] python-qt5: add PyQt5.sip module

In reply to a message not in the archive

Hi Thomas,

here is an updated patch which reflects everything that we discussed. The new package has no dependency which looks quite particular in this part of the code base, but indeed it only depends on Python which is available for setuptools-based packets.

Thank you!

Best,
Ralf

From 80685182d67a35056cc6fc72719fd74f5d1c32e8 Mon Sep 17 00:00:00 2001
From: Ralf Dragon <[email protected]>
Date: Thu, 23 Nov 2023 18:23:59 +0100
Subject: [PATCH 1/1] python-pyqt5-sip: add PyQt5.sip module

This fixes the following runtime error when importing PyQt5 in python:

from PyQt5.QtCore import *
ModuleNotFoundError: No module named 'PyQt5.sip'

The official documentation [1] mentions that this module is needed during PyQt5 runtime. It is currently compiled without any dependencies to Qt or PyQt5, but it seems quite useless without it. The module was introduced together with PyQt 5.11 [2].

The problem was likely triggered by the atomic upgrade from 5.7 to 5.15 in b36ce7e. This commit is part of the 2022 and 2023 LTS branches.

[1] https://www.riverbankcomputing.com/static/Docs/PyQt5/installation.html#building-and-installing-from-source
[2] https://www.riverbankcomputing.com/static/Docs/PyQt5/incompatibilities.html#pyqt-v5-11

---
Backport to: 2023.02.x
(2022 LTS branches are probably also affected but I could not test any, 2021.11.3 is fine)

---
 package/Config.in                              |  1 +
 package/python-pyqt5-sip/Config.in             |  4 ++++
 package/python-pyqt5-sip/python-pyqt5-sip.hash |  4 ++++
 package/python-pyqt5-sip/python-pyqt5-sip.mk   | 14 ++++++++++++++
 package/python-pyqt5/Config.in                 |  1 +
 5 files changed, 24 insertions(+)
 create mode 100644 package/python-pyqt5-sip/Config.in
 create mode 100644 package/python-pyqt5-sip/python-pyqt5-sip.hash
 create mode 100644 package/python-pyqt5-sip/python-pyqt5-sip.mk
package/Config.in +1 -0
index d5d89c50aa..7b130fc173 100644
@@ -1268,6 +1268,7 @@ menu "External python modules"
 	source "package/python-pyphen/Config.in"
 	source "package/python-pyqrcode/Config.in"
 	source "package/python-pyqt5/Config.in"
+	source "package/python-pyqt5-sip/Config.in"
 	source "package/python-pyratemp/Config.in"
 	source "package/python-pyroute2/Config.in"
 	source "package/python-pyrsistent/Config.in"
package/python-pyqt5-sip/Config.in new file +4 -0
new file mode 100644
index 0000000000..f7be60c8ec
@@ -0,0 +1,4 @@
+config BR2_PACKAGE_PYTHON_PYQT5_SIP
+	bool "python-pyqt5-sip"
+	help
+	  This is the PyQt5.sip module which is needed to run PyQt5.
package/python-pyqt5-sip/python-pyqt5-sip.hash new file +4 -0
new file mode 100644
index 0000000000..8039cdafd9
@@ -0,0 +1,4 @@
+# from https://pypi.org/project/PyQt5-sip/12.12.1
+
+sha256  8fdc6e0148abd12d977a1d3828e7b79aae958e83c6cb5adae614916d888a6b10  PyQt5_sip-12.12.1.tar.gz
+md5  c2117da3b4c0e081c1c5a9088b8a4d55  PyQt5_sip-12.12.1.tar.gz
package/python-pyqt5-sip/python-pyqt5-sip.mk new file +14 -0
new file mode 100644
index 0000000000..051fa4e77d
@@ -0,0 +1,14 @@
+################################################################################
+#
+# python-SIP-QT5
+#
+################################################################################
+
+PYTHON_PYQT5_SIP_VERSION = 12.12.1
+PYTHON_PYQT5_SIP_SITE = https://files.pythonhosted.org/packages/c1/61/4055e7a0f36339964956ff415e36f4abf82561904cc49c021da32949fc55
+PYTHON_PYQT5_SIP_SOURCE = PyQt5_sip-$(PYTHON_PYQT5_SIP_VERSION).tar.gz
+PYTHON_PYQT5_SIP_LICENSE = MIT
+PYTHON_PYQT5_SIP_LICENSE_FILES = LICENSE
+PYTHON_PYQT5_SIP_SETUP_TYPE = setuptools
+
+$(eval $(python-package))
package/python-pyqt5/Config.in +1 -0
index 9fa7676f98..0b37f14317 100644
@@ -5,6 +5,7 @@ config BR2_PACKAGE_PYTHON_PYQT5
 	bool "python-pyqt5"
 	depends on BR2_PACKAGE_QT5
 	select BR2_PACKAGE_PYTHON_SIP
+	select BR2_PACKAGE_PYTHON_PYQT5_SIP # runtime
 	select BR2_PACKAGE_QT5BASE_GUI
 	help
 	  Python bindings for Qt 5
Signature · 1 line
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#8 lore raw

Re: [Buildroot] [PATCH 2/2] python-qt5: add PyQt5.sip module

In reply to Thomas Petazzoni via buildroot

Dear Thomas,

attached is an updated clean patch.

Best,

Ralf

From 9ec3b38b1e1f0f06c0561adbb48aa7e106d36975 Mon Sep 17 00:00:00 2001
From: Ralf Dragon <[email protected]>
Date: Thu, 23 Nov 2023 18:23:59 +0100
Subject: [PATCH 2/2] python-qt5: add PyQt5.sip module

This fixes the following runtime error when importing PyQt5 in python:

from PyQt5.QtCore import *
ModuleNotFoundError: No module named 'PyQt5.sip'

---
 package/Config.in                              |  1 +
 package/python-pyqt5-sip/Config.in             |  5 +++++
 package/python-pyqt5-sip/python-pyqt5-sip.hash |  3 +++
 package/python-pyqt5-sip/python-pyqt5-sip.mk   | 15 +++++++++++++++
 package/python-pyqt5/Config.in                 |  1 +
 5 files changed, 25 insertions(+)
 create mode 100644 package/python-pyqt5-sip/Config.in
 create mode 100644 package/python-pyqt5-sip/python-pyqt5-sip.hash
 create mode 100644 package/python-pyqt5-sip/python-pyqt5-sip.mk
package/Config.in +1 -0
index fcc09b07c4..2d6a077d16 100644
@@ -1253,6 +1253,7 @@ menu "External python modules"
 	source "package/python-pyphen/Config.in"
 	source "package/python-pyqrcode/Config.in"
 	source "package/python-pyqt5/Config.in"
+	source "package/python-pyqt5-sip/Config.in"
 	source "package/python-pyratemp/Config.in"
 	source "package/python-pyroute2/Config.in"
 	source "package/python-pyrsistent/Config.in"
package/python-pyqt5-sip/Config.in new file +5 -0
new file mode 100644
index 0000000000..1e58818a1e
@@ -0,0 +1,5 @@
+config BR2_PACKAGE_PYTHON_PYQT5_SIP
+	bool "python-pyqt5-sip"
+	depends on BR2_PACKAGE_PYTHON_SIP
+	help
+	  This is the PyQt5.sip module which is needed to run PyQt5.
package/python-pyqt5-sip/python-pyqt5-sip.hash new file +3 -0
new file mode 100644
index 0000000000..a55c74ed8f
@@ -0,0 +1,3 @@
+# from https://pypi.org/project/PyQt5-sip/12.12.1
+sha256  8fdc6e0148abd12d977a1d3828e7b79aae958e83c6cb5adae614916d888a6b10  PyQt5_sip-12.12.1.tar.gz
+md5  c2117da3b4c0e081c1c5a9088b8a4d55  PyQt5_sip-12.12.1.tar.gz
package/python-pyqt5-sip/python-pyqt5-sip.mk new file +15 -0
new file mode 100644
index 0000000000..f2d50c2e03
@@ -0,0 +1,15 @@
+################################################################################
+#
+# python-pyqt5-sip
+#
+################################################################################
+
+PYTHON_PYQT5_SIP_VERSION = 12.12.1
+PYTHON_PYQT5_SIP_SITE = https://files.pythonhosted.org/packages/c1/61/4055e7a0f36339964956ff415e36f4abf82561904cc49c021da32949fc55
+PYTHON_PYQT5_SIP_SOURCE = PyQt5_sip-$(PYTHON_PYQT5_SIP_VERSION).tar.gz
+PYTHON_PYQT5_SIP_LICENSE = MIT
+PYTHON_PYQT5_SIP_LICENSE_FILES = LICENSE
+PYTHON_PYQT5_SIP_SETUP_TYPE = setuptools
+PYTHON_PYQT5_SIP_DEPENDENCIES = python-sip
+
+$(eval $(python-package))
package/python-pyqt5/Config.in +1 -0
index 9fa7676f98..c2a1976950 100644
@@ -5,6 +5,7 @@ config BR2_PACKAGE_PYTHON_PYQT5
 	bool "python-pyqt5"
 	depends on BR2_PACKAGE_QT5
 	select BR2_PACKAGE_PYTHON_SIP
+	select BR2_PACKAGE_PYTHON_PYQT5_SIP
 	select BR2_PACKAGE_QT5BASE_GUI
 	help
 	  Python bindings for Qt 5
Signature · 1 line
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#9 lore raw

Re: [Buildroot] [PATCH 2/2] python-qt5: add PyQt5.sip module

In reply to Thomas Petazzoni via buildroot

Hi Thomas, Ralf, All,

Quoted 1 line · Thomas Petazzoni

Hello Ralf,

[...]

Quoted 4 lines

Also, it would very, very good to add a runtime test case in support/testing/ for this, as such Python issues are only visible at runtime. I have added Julien Olivain in Cc, who can probably help with this, as he is our resident expert in writing support/testing tests :-)

I was able to craft a full PyQt5 runtime test, using the Kernel VKMS (as we used in some other graphical tests), and using the Qt QPA eglfs, which runs application directly on kms/drm.

I'll post an early version soon, at least to get some early comments.

Best regards,

Julien.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#10 lore raw

Re: [Buildroot] [PATCH 2/2] python-qt5: add PyQt5.sip module

Quoted 10 lines · On Wed, 10 Jan 2024 20:21:48 +0100 Julien Olivain <[email protected]> wrote:
Quoted 4 lines

Also, it would very, very good to add a runtime test case in support/testing/ for this, as such Python issues are only visible at runtime. I have added Julien Olivain in Cc, who can probably help with this, as he is our resident expert in writing support/testing tests :-)

I was able to craft a full PyQt5 runtime test, using the Kernel VKMS (as we used in some other graphical tests), and using the Qt QPA eglfs, which runs application directly on kms/drm.

I'll post an early version soon, at least to get some early comments.

Excellent, looking forward to it!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#11 lore raw

Re: [Buildroot] [PATCH 2/2] python-qt5: add PyQt5.sip module

In reply to Ralf Dragon

Hi Ralf, All,

Thanks for this patch. I have few comments on it.

There was an improved version of this patch, sent as an attachment here:
https://lists.buildroot.org/pipermail/buildroot/2023-December/681200.html
This may be the reason why this series got forgotten. For sending updated patches, see:
https://nightly.buildroot.org/manual.html#_patch_revision_changelog

I am commenting this earlier patch revision. I believe my comments also applies to the other version.

First, I think this patch could be split in two, in the same series:
1. the introduction of the new package python-pyqt5-sip (alone) The commit log should describe what the package is and why it is
needed.
2. The runtime fix for python-pyqt5
The commit log should describe what is broken, when the problem was
introduced.
(see examples later)

In order to follow the Buildroot convention, the first patch one-line title could be changed to:
"package/python-pyqt5-sip: new package"

Quoted 4 lines · Ralf Dragon

This fixes the following runtime error when importing PyQt5 in python:

from PyQt5.QtCore import *
ModuleNotFoundError: No module named 'PyQt5.sip'

You could also add a quick package description and the reason you would like to add the package in the commit log, for example:
"""
The sip extension module provides support for the PyQt5 package.

This package is needed at runtime by python-pyqt5 version >= 5.11. """

Quoted 47 lines

---
Backport to: 2023.02.x

 package/Config.in                              |  1 +
 package/python-pyqt5-sip/Config.in             |  6 ++++++
 package/python-pyqt5-sip/python-pyqt5-sip.hash |  4 ++++
 package/python-pyqt5-sip/python-pyqt5-sip.mk   | 15 +++++++++++++++
 package/python-pyqt5/Config.in                 |  1 +
 5 files changed, 27 insertions(+)
 create mode 100644 package/python-pyqt5-sip/Config.in
 create mode 100644 package/python-pyqt5-sip/python-pyqt5-sip.hash
 create mode 100644 package/python-pyqt5-sip/python-pyqt5-sip.mk
package/Config.in +1 -0
index fcc09b07c4..2d6a077d16 100644
@@ -1253,6 +1253,7 @@ menu "External python modules"
 	source "package/python-pyphen/Config.in"
 	source "package/python-pyqrcode/Config.in"
 	source "package/python-pyqt5/Config.in"
+	source "package/python-pyqt5-sip/Config.in"
 	source "package/python-pyratemp/Config.in"
 	source "package/python-pyroute2/Config.in"
 	source "package/python-pyrsistent/Config.in"
package/python-pyqt5-sip/Config.in new file +6 -0
new file mode 100644
index 0000000000..6f26271f70
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_PYTHON_PYQT5_SIP
+	bool "python-pyqt5-sip"
+	depends on BR2_PACKAGE_PYTHON_PYQT5
+	depends on BR2_PACKAGE_PYTHON_SIP
+	help
+	  This is the PyQt5.sip module which is needed to run PyQt5.
package/python-pyqt5-sip/python-pyqt5-sip.hash new file +3 -0
new file mode 100644
index 0000000000..8039cdafd9
@@ -0,0 +1,4 @@
+# from https://pypi.org/project/PyQt5-sip/12.12.1
+
+sha256  
Quoted 2 lines

8fdc6e0148abd12d977a1d3828e7b79aae958e83c6cb5adae614916d888a6b10 PyQt5_sip-12.12.1.tar.gz +md5 c2117da3b4c0e081c1c5a9088b8a4d55 PyQt5_sip-12.12.1.tar.gz

Can you add here hashes for the 3 license files? See also comment in the .mk file. You can then check with a "make python-pyqt5-sip-legal-info" or "make legal-info".

package/python-pyqt5-sip/python-pyqt5-sip.mk line 7

Quoted 13 lines
package/python-pyqt5-sip/python-pyqt5-sip.mk new file +7 -0
new file mode 100644
index 0000000000..3f689b9d47
@@ -0,0 +1,15 @@
+################################################################################
+#
+# python-SIP-QT5
+#
+################################################################################
+
+PYTHON_PYQT5_SIP_VERSION = 12.12.1

There is now a v12.13.0 available. See:
https://pypi.org/project/PyQt5-sip/

Since this patch will likely need a v2, could you see if you can updating to this new version?

package/python-pyqt5-sip/python-pyqt5-sip.mk line 10

Quoted 4 lines
package/python-pyqt5-sip/python-pyqt5-sip.mk new file +1 -0
+PYTHON_PYQT5_SIP_SITE = 

https://files.pythonhosted.org/packages/c1/61/4055e7a0f36339964956ff415e36f4abf82561904cc49c021da32949fc55

package/python-pyqt5-sip/python-pyqt5-sip.mk new file +2 -0
+PYTHON_PYQT5_SIP_SOURCE = PyQt5_sip-$(PYTHON_PYQT5_SIP_VERSION).tar.gz
+PYTHON_PYQT5_SIP_LICENSE = MIT

License seems to be:
"SIP or GPL-2.0 or GPL-3.0"
Where is the source of this MIT license? (I grep'ed "MIT" in the sources and was not able to any occurrence of it).

Quoted 1 line

+PYTHON_PYQT5_SIP_LICENSE_FILES = LICENSE

The package also contains the license files:
LICENSE-GPL2 and LICENSE-GPL3.
Can you add those here? (see also comment in the .hash file).

package/python-pyqt5/Config.in config BR2_PACKAGE_PYTHON_PYQT5 · line 8

Quoted 13 lines
package/python-pyqt5-sip/python-pyqt5-sip.mk new file +4 -0
+PYTHON_PYQT5_SIP_SETUP_TYPE = setuptools
+PYTHON_PYQT5_SIP_DEPENDENCIES += python-sip
+
+$(eval $(python-package))
package/python-pyqt5/Config.in +1 -0
index 9fa7676f98..c2a1976950 100644
@@ -5,6 +5,7 @@ config BR2_PACKAGE_PYTHON_PYQT5
 	bool "python-pyqt5"
 	depends on BR2_PACKAGE_QT5
 	select BR2_PACKAGE_PYTHON_SIP
+	select BR2_PACKAGE_PYTHON_PYQT5_SIP

This line could go in a separate "python-pyqt5 fix" patch. Could you also flag this dependency as "runtime"?

select BR2_PACKAGE_PYTHON_PYQT5_SIP # runtime

The commit log of this second patch should describe issue, for example:
"""
Commit b36ce7eda0 "package/python-pyqt5: bump to version 5.15.6" updated PyQt5 from version 5.7 to 5.15.6. This commit forgot to take into account an upstream incompatible change about a PyQt5 SIP module. See [1]. Without this pyqt5-sip module, pyqt5 is failing to load at runtime.

The issue can be reproduced with the command:

python3 -c 'from PyQt5.QtCore import *'

This commit fixes the issue by adding this missing runtime dependency.

Fixes:

ModuleNotFoundError: No module named 'PyQt5.sip'

[1] https://www.riverbankcomputing.com/static/Docs/PyQt5/incompatibilities.html#pyqt-v5-11
"""

Quoted 10 lines
package/python-pyqt5/Config.in +0 -1
 	select BR2_PACKAGE_QT5BASE_GUI
 	help
 	  Python bindings for Qt 5
--

2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

Best regards,

Julien.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#12 lore raw
In reply to Ralf Dragon

Hello Ralf,

Thanks for the patch! I have applied it, with some changes, see below.

Quoted 9 lines · On Tue, 12 Dec 2023 17:01:11 +0100 Ralf Dragon <[email protected]> wrote:

Without the patch, python-sip fails to compile with:

siplib.c: In function ‘sip_api_get_frame’:
siplib.c:13750:22: error: invalid use of undefined type ‘struct _frame’
13750 | frame = frame->f_back;

This likely fixes bug 15201 [1].

[1] https://bugs.buildroot.org/show_bug.cgi?id=15201

I am not sure it fixes this bug. This bug is more about upgrading python-sip, which indeed would be very nice to do as SIP 4.x is no longer maintained, as you pointed out.

However, your patch fixes
http://autobuild.buildroot.net/results/7b01739e7514e48c06182bc1804b32497ce2e414/
for sure, so I've used that in the commit log.

Quoted 8 lines
package/python-sip/0002-fixframe.patch new file +2 -0
new file mode 100644
index 0000000000..befe76fc73
@@ -0,0 +1,55 @@
+siplib: fix build with python >= 3.11
+

package/python-sip/0002-fixframe.patch line 12

Quoted 10 lines
package/python-sip/0002-fixframe.patch new file +10 -0
+With python 3.11, the PyFrameObject structure members have been
+removed from the public C API:
+
+https://docs.python.org/3.11/whatsnew/3.11.html#whatsnew311-c-api-porting
+https://docs.python.org/3.11/whatsnew/3.11.html#pyframeobject-3-11-hiding
+
+This patch migrates to the opaque PyFrameObject.
+
+Signed-off-by: Ralf Dragon <[email protected]>
+Upstream: N/A as SIP v4 is no longer supported. 4.19.25 is the last release.

I reformatted this patch using "git format-patch" to be like patch 0001. I also slightly improved the commit log.

See the final commit:

https://gitlab.com/buildroot.org/buildroot/-/commit/3ef6884e6d59744d83649170822a4829eed146fc

Thanks a lot!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#13 lore raw
In reply to Ralf Dragon
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Ralf" == Ralf Dragon <[email protected]> writes:

Without the patch, python-sip fails to compile with:
siplib.c: In function ‘sip_api_get_frame’:
siplib.c:13750:22: error: invalid use of undefined type ‘struct _frame’
13750 | frame = frame->f_back;

This likely fixes bug 15201 [1].

Quoted 6 lines

[1] https://bugs.buildroot.org/show_bug.cgi?id=15201

---
Backport to: 2023.02.x

Committed to 2023.02.x and 2023.11.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot