Bug 1895298

Summary: PyQt4 fails to build with Python 3.10: Please migrate to new buffer protocol
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: PyQt4Assignee: Rex Dieter <rdieter>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: kde-sig, mhroncok, rdieter, than, thrnciar, vstinner
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-12-08 11:32:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1890881    

Description Tomáš Hrnčiar 2020-11-06 09:34:15 UTC
PyQt4 fails to build with Python 3.10.0a1.

In file included from /usr/include/QtCore/QString:1,
                 from ../../../qpy/QtCore/qpycore_qstring.cpp:24:
/usr/include/QtCore/qstring.h: In member function 'int QStringRef::compare(QLatin1String, Qt::CaseSensitivity) const':
/usr/include/QtCore/qstring.h:1254:62: warning: implicitly-declared 'constexpr QLatin1String::QLatin1String(const QLatin1String&)' is deprecated [-Wdeprecated-copy]
 1254 | { return QString::compare_helper(constData(), length(), s, cs); }
      |                                                              ^
/usr/include/QtCore/qstring.h:658:27: note: because 'QLatin1String' has user-provided 'QLatin1String& QLatin1String::operator=(const QLatin1String&)'
  658 |     inline QLatin1String &operator=(const QLatin1String &other)
      |                           ^~~~~~~~
/usr/include/QtCore/qstring.h:634:45: note:   initializing argument 3 of 'static int QString::compare_helper(const QChar*, int, QLatin1String, Qt::CaseSensitivity)'
  634 |                               QLatin1String s2,
      |                               ~~~~~~~~~~~~~~^~
/usr/include/QtCore/qstring.h: In static member function 'static int QStringRef::compare(const QStringRef&, QLatin1String, Qt::CaseSensitivity)':
/usr/include/QtCore/qstring.h:1260:69: warning: implicitly-declared 'constexpr QLatin1String::QLatin1String(const QLatin1String&)' is deprecated [-Wdeprecated-copy]
 1260 | { return QString::compare_helper(s1.constData(), s1.length(), s2, cs); }
      |                                                                     ^
/usr/include/QtCore/qstring.h:658:27: note: because 'QLatin1String' has user-provided 'QLatin1String& QLatin1String::operator=(const QLatin1String&)'
  658 |     inline QLatin1String &operator=(const QLatin1String &other)
      |                           ^~~~~~~~
/usr/include/QtCore/qstring.h:634:45: note:   initializing argument 3 of 'static int QString::compare_helper(const QChar*, int, QLatin1String, Qt::CaseSensitivity)'
  634 |                               QLatin1String s2,
      |                               ~~~~~~~~~~~~~~^~
/usr/include/QtCore/qstring.h: In member function 'QBool QStringRef::contains(QLatin1String, Qt::CaseSensitivity) const':
/usr/include/QtCore/qstring.h:1278:32: warning: implicitly-declared 'constexpr QLatin1String::QLatin1String(const QLatin1String&)' is deprecated [-Wdeprecated-copy]
 1278 | { return QBool(indexOf(s, 0, cs) != -1); }
      |                                ^
/usr/include/QtCore/qstring.h:658:27: note: because 'QLatin1String' has user-provided 'QLatin1String& QLatin1String::operator=(const QLatin1String&)'
  658 |     inline QLatin1String &operator=(const QLatin1String &other)
      |                           ^~~~~~~~
/usr/include/QtCore/qstring.h:1125:31: note:   initializing argument 1 of 'int QStringRef::indexOf(QLatin1String, int, Qt::CaseSensitivity) const'
 1125 |     int indexOf(QLatin1String str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
      |                 ~~~~~~~~~~~~~~^~~
../../../qpy/QtCore/qpycore_qstring.cpp: In function 'const char* qpycore_encode(PyObject**, QCoreApplication::Encoding)':
../../../qpy/QtCore/qpycore_qstring.cpp:301:14: error: 'PyObject_AsCharBuffer' was not declared in this scope; did you mean 'PyObject_CheckBuffer'?
  301 |     else if (PyObject_AsCharBuffer(obj, &es, &sz) >= 0)
      |              ^~~~~~~~~~~~~~~~~~~~~
      |              PyObject_CheckBuffer
make[2]: *** [Makefile:447: qpycore_qstring.o] Error 1

https://docs.python.org/3.10/whatsnew/changelog.html#id11

bpo-41103: PyObject_AsCharBuffer(), PyObject_AsReadBuffer(), PyObject_CheckReadBuffer(), and PyObject_AsWriteBuffer() are removed. Please migrate to new buffer protocol; PyObject_GetBuffer() and PyBuffer_Release().

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/01746717-PyQt4/

For all our attempts to build PyQt4 with Python 3.10, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/PyQt4/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.10:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/

Let us know here if you have any questions.

Python 3.10 will be included in Fedora 35. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.10.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Victor Stinner 2020-11-23 17:28:30 UTC
PyQt4 is no longer supported upstream: PyQt4 version 4.12.3 is the last version of PyQt4.

"This is the last release of PyQt4. No more releases will be made."
https://riverbankcomputing.com/software/pyqt/download

---

It seems like the stable version is now PyQt5: "PyQt5 is a comprehensive set of Python bindings for Qt v5."

PyQt5 is packaged in Fedora as: https://src.fedoraproject.org/rpms/python-qt5/blob/master/f/python-qt5.spec

I don't know if Qt5 is backward compatible with Qt4.

Is it possible to consider removing the PyQt4 package in Rawhide? The following packages require PyQt4:

* PyMca
* flatcam
* ibus-bogo
* pymol
* python-pyqtgraph
* python-qdarkstyle
* python3-PyQt4-devel
* python3-PyQt4-webkit
* python3-cclib
* python3-iep
* python3-matplotlib-qt4
* python3-pyqtgraph
* python3-pyudev-qt4

---

The issue comes from qpycore_encode() function of PyQt4. First of all, this function is deprecated:
"#if QT_DEPRECATED_SINCE(5, 0)"

Morever, qpycore_encode() has been removed from PyQt5. PyQt 5.15.1 doesn't use PyObject_AsBuffer() anymore (the discussed function removed in Python 3.10).

---

The Fedora package uses PyQt4 version 4.12.3 since August 2018:

* Fri Aug 31 2018 Rex Dieter <rdieter> - 4.12.3-1
- 4.12.3

Comment 2 Victor Stinner 2020-11-23 17:46:11 UTC
I'm working on a fix: https://src.fedoraproject.org/rpms/PyQt4/pull-request/2