Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 939423 - kde-apps/kajongg-24.05.2 w/o dev-python/QtPy[pyqt6]: err: No module named 'PyQt6'
Summary: kde-apps/kajongg-24.05.2 w/o dev-python/QtPy[pyqt6]: err: No module named 'Py...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo KDE team
URL: https://invent.kde.org/games/kajongg/...
Whiteboard:
Keywords: PATCH, UPSTREAM
Depends on:
Blocks:
 
Reported: 2024-09-10 08:29 UTC by Bug Bugs
Modified: 2025-02-16 14:29 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bug Bugs 2024-09-10 08:29:21 UTC
I tried to use PySide6 api (only) for QtPy with no luck.

kajongg uses PyQt directly (for sip) so either way I ended up by installing PyQt6 too.

Maybe version 24.*.* still ok with default PyQt5 but I guess for kajongg slot (6) it make sense to use PyQt6 api.
Comment 1 Bug Bugs 2024-09-10 08:58:13 UTC
Current status: https://invent.kde.org/games/kajongg/-/blob/d1dd170ec09ece0e0fdc652b7e73aba6119c0cde/src/qt.py#L140-L152

> from PyQt6 import sip

Will trigger error when PyQt api disabled
> err: No module named 'PyQt6'
Comment 2 Andreas Sturmlechner gentoo-dev 2024-09-10 15:49:46 UTC
I think that was an unintended change by upstream during Qt6 porting.
Comment 3 Andreas Sturmlechner gentoo-dev 2024-09-10 16:58:54 UTC
Please check out the newly attached upstream patch to see if it fixes your problem when QtPy is installed without PyQt support.
Comment 4 Bug Bugs 2024-09-10 17:30:18 UTC
$  kajongg
qt.gui.icc: fromIccProfile: failed size sanity 2
C:  * Kajongg is not correctly installed: modules: cannot import name 'sip_cast' from 'qt' (/usr/share/kajongg/qt.py)
Traceback (most recent call last):
  File "/usr/share/kajongg/kdestub.py", line 115, in desktopSize
    result = Internal.app.desktop().availableGeometry()
             ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'KApplication' object has no attribute 'desktop'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/kajongg", line 189, in <module>
    from mainwindow import MainWindow
  File "/usr/share/kajongg/mainwindow.py", line 88, in <module>
    logError("\n".join(f" * {s}" for s in NOTFOUND), showStack=False)
  File "/usr/share/kajongg/log.py", line 146, in logError
    return logMessage(msg, logging.ERROR, True, showStack=showStack, withGamePrefix=withGamePrefix)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/kajongg/log.py", line 135, in logMessage
    return Information(msg) if prio == logging.INFO else Sorry(msg, always=True)
                                                         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/kajongg/dialogs.py", line 193, in __init__
    dialog = Prompt(msg, icon=QMessageBox.Icon.Information,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/kajongg/dialogs.py", line 81, in __init__
    KMessageBox.createKMessageBox(
  File "/usr/share/kajongg/kdestub.py", line 216, in createKMessageBox
    desktop = KApplication.desktopSize()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/kajongg/kdestub.py", line 117, in desktopSize
    assert Internal.mainWindow
           ^^^^^^^^^^^^^^^^^^^
AssertionError
Comment 5 Bug Bugs 2024-09-10 17:36:30 UTC
BTW in case of PySide6 there should also be USE="designer" either for QtPy or Pyside6 and qttools IIRC
Because of
> err: No module named 'PySide6.QtUiTools'
Comment 6 Bug Bugs 2024-09-10 17:58:19 UTC
Not sure if this correct but I added sip_cast to `else` block too
---
else:
    def sip_cast(obj, _type):
        """hide not so nice things in qt.py"""
        return False
    HAVE_SIP = False
---

It launched and About dialog shows PySide6 api in use.
Comment 7 Andreas Sturmlechner gentoo-dev 2024-09-10 17:59:17 UTC
This would be better placed in the upstream bug report ;)
Comment 8 Bug Bugs 2024-09-10 18:12:42 UTC
I'm too lazy to register there right now.
Please copy/paste if you think it worth to mention there.
Comment 9 Andreas Sturmlechner gentoo-dev 2024-09-10 19:58:37 UTC
(In reply to Bug Bugs from comment #5)
> BTW in case of PySide6 there should also be USE="designer" either for QtPy
> or Pyside6 and qttools IIRC
> Because of
> > err: No module named 'PySide6.QtUiTools'
grep returns nothing for that, where was that coming from? Note that kajongg is also silent for me without this flag set on either pyside6 or PyQt6.
Comment 10 Bug Bugs 2024-09-10 20:14:17 UTC
It was from my first attempt to use PySide6 only. I kept rebuilding it with modules kajongg asked.

QtPy-2.4.1/qtpy/uic.py:76
>    if PYSIDE6:
>        from PySide6.QtCore import QMetaObject
>        from PySide6.QtUiTools import QUiLoader, loadUiType
>    elif PYSIDE2:
>        from PySide2.QtCore import QMetaObject
>        from PySide2.QtUiTools import QUiLoader
> ...

Maybe it just want qttools installed. USE="designer" pulled this package for me.
Comment 11 Bug Bugs 2024-09-10 20:43:19 UTC
FYI in new upstream commit they possibly missed QT5/6 -> PYQT5/6 changes.
Not tried those patches yet.

https://invent.kde.org/games/kajongg/-/commit/3f12d305cc56814b72c561b36271494a21cf236d
Comment 12 Larry the Git Cow gentoo-dev 2024-09-11 06:52:08 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/kde.git/commit/?id=d9c29bc3d505f042f6e6d60bed83d82824b56a26

commit d9c29bc3d505f042f6e6d60bed83d82824b56a26
Author:     Andreas Sturmlechner <asturm@gentoo.org>
AuthorDate: 2024-09-10 20:05:39 +0000
Commit:     Andreas Sturmlechner <asturm@gentoo.org>
CommitDate: 2024-09-11 06:34:31 +0000

    kde-apps/kajongg: Add dev-python/QtPy[ || ( pyside6 pykde6 ) ] USEdep
    
    Bug: https://bugs.gentoo.org/939423
    Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>

 kde-apps/kajongg/kajongg-24.08.1.ebuild       | 1 +
 kde-apps/kajongg/kajongg-24.08.49.9999.ebuild | 1 +
 kde-apps/kajongg/kajongg-9999.ebuild          | 1 +
 3 files changed, 3 insertions(+)
Comment 13 Bug Bugs 2024-09-11 09:57:41 UTC
With only patch from the upstream commit
(as expected)
---
$  kajongg
Traceback (most recent call last):
  File "/usr/bin/kajongg", line 19, in <module>
    from qt import QObject, QCommandLineParser, QCommandLineOption, Qt, QGuiApplication
  File "/usr/share/kajongg/qt.py", line 147, in <module>
    from PyQt6 import sip  # type:ignore[no-redef]
    ^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'PyQt6'
---

Obviously we need both patches (proposed fix and that commit).
As was said
>> The kajongg source code he points to sets HAVE_SIP to False if neither PyQt6
>> nor PyQt5 is found.
> No, it sets it to false if both QT5 and QT6 are false (which should
> never happen). You probably want 'if PYQT5' and 'elif PYQT6' instead.
Comment 14 Larry the Git Cow gentoo-dev 2024-09-12 19:29:45 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=67e77a54889d54c697923dd9c9b59ebdf227a258

commit 67e77a54889d54c697923dd9c9b59ebdf227a258
Author:     Andreas Sturmlechner <asturm@gentoo.org>
AuthorDate: 2024-09-12 15:50:34 +0000
Commit:     Andreas Sturmlechner <asturm@gentoo.org>
CommitDate: 2024-09-12 19:27:08 +0000

    kde-apps/kdegames-meta: 24.08.1 version bump, dropping ~riscv,~x86
    
    Bug: https://bugs.gentoo.org/939423
    Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>

 .../kdegames-meta/kdegames-meta-24.08.1.ebuild     | 60 ++++++++++++++++++++++
 1 file changed, 60 insertions(+)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f48d0da29910aef82158d2ae63a3e08a9a17605f

commit f48d0da29910aef82158d2ae63a3e08a9a17605f
Author:     Andreas Sturmlechner <asturm@gentoo.org>
AuthorDate: 2024-09-12 15:50:00 +0000
Commit:     Andreas Sturmlechner <asturm@gentoo.org>
CommitDate: 2024-09-12 19:27:06 +0000

    kde-apps/kajongg: 24.08.1 version bump, dropping ~riscv,~x86
    
    Bug: https://bugs.gentoo.org/939423
    Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>

 kde-apps/kajongg/Manifest               |  1 +
 kde-apps/kajongg/kajongg-24.08.1.ebuild | 47 +++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)
Comment 15 Andreas Sturmlechner gentoo-dev 2024-09-14 13:22:15 UTC
This appears to be finally fixed in git master.
Comment 16 Larry the Git Cow gentoo-dev 2024-09-14 13:43:29 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8749fab502c985af1c3dde0b573de4d5bad45770

commit 8749fab502c985af1c3dde0b573de4d5bad45770
Author:     Andreas Sturmlechner <asturm@gentoo.org>
AuthorDate: 2024-09-14 13:41:37 +0000
Commit:     Andreas Sturmlechner <asturm@gentoo.org>
CommitDate: 2024-09-14 13:43:23 +0000

    kde-apps/kajongg: Fix runtime w/ dev-python/QtPy[pyside6] (w/o PyQt6)
    
    Closes: https://bugs.gentoo.org/939423
    Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>

 .../files/kajongg-24.08.1-fix-w-o-pyqt6.patch      | 156 +++++++++++++++++++++
 kde-apps/kajongg/kajongg-24.08.1-r1.ebuild         |  49 +++++++
 2 files changed, 205 insertions(+)
Comment 17 Andreas Sturmlechner gentoo-dev 2024-09-19 10:06:41 UTC
Finally, also picked for 24.08 branch.
Comment 18 Mr. Beedell, Roke Julian Lockhart 2025-02-16 14:16:30 UTC
(In reply to Larry the Git Cow from comment #12)
>     kde-apps/kajongg: Add dev-python/QtPy[ || ( pyside6 pykde6 ) ] USEdep

Apologies if off-topic, but to my knowledge, there is no PyKDE6; newest, PyKDE5.
Comment 19 Andreas Sturmlechner gentoo-dev 2025-02-16 14:29:45 UTC
I'm not sure how that happened, but what's important here is code:

> || ( dev-python/QtPy[pyqt6] dev-python/QtPy[pyside6] )

Which is correct.