summaryrefslogtreecommitdiff
path: root/qutebrowser/qt/sip.py
blob: 7e4bf246dd5ecc9b0fc4f0b53611eb6bffab742d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# pylint: disable=wildcard-import,unused-wildcard-import

"""Wrapped Qt imports for PyQt5.sip/PyQt6.sip.

All code in qutebrowser should use this module instead of importing from
PyQt/sip directly. This allows supporting both Qt 5 and Qt 6.

See machinery.py for details on how Qt wrapper selection works.

Any API exported from this module is based on the PyQt6.sip API:
https://www.riverbankcomputing.com/static/Docs/PyQt6/api/sip/sip-module.html

Note that we don't yet abstract between PySide/PyQt here.
"""

from qutebrowser.qt import machinery

machinery.init_implicit()

if machinery.USE_PYSIDE6:  # pylint: disable=no-else-raise
    raise machinery.Unavailable()
elif machinery.USE_PYQT5:
    try:
        from PyQt5.sip import *
    except ImportError:
        from sip import *  # type: ignore[import]
elif machinery.USE_PYQT6:
    try:
        from PyQt6.sip import *
    except ImportError:
        # While upstream recommends using PyQt5.sip ever since PyQt5 5.11, some
        # distributions still package later versions of PyQt5 with a top-level
        # "sip" rather than "PyQt5.sip".
        from sip import *
else:
    raise machinery.UnknownWrapper()