Skip to content

Commit 9a1424c

Browse files
committed
qtpy based fallback for PyQt5
1 parent 2f8734d commit 9a1424c

File tree

2 files changed

+46
-36
lines changed

2 files changed

+46
-36
lines changed

src/depends.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -384,25 +384,25 @@ def check_pyqt():
384384
"""
385385
# pylint: disable=no-member
386386
try:
387-
from fallback import qtpy
387+
from fallback import PyQt5
388388
except ImportError:
389389
logger.error(
390-
'PyBitmessage requires qtpy, PyQt 4.8 or later and Qt 4.7 or later.'
391-
)
392-
qtpy = None
390+
'PyBitmessage requires PyQt5 or qtpy, PyQt 4.8 or later'
391+
' and Qt 4.7 or later.')
392+
PyQt5 = None
393393

394-
if not qtpy:
394+
if not PyQt5:
395395
return False
396396

397-
logger.info('PyQt Version: %s', qtpy.PYQT_VERSION)
398-
logger.info('Qt Version: %s', qtpy.QT_VERSION)
397+
logger.info('PyQt Version: %s', PyQt5.PYQT_VERSION)
398+
logger.info('Qt Version: %s', PyQt5.QT_VERSION)
399399
passed = True
400-
if version.LooseVersion(qtpy.PYQT_VERSION) < '4.8':
400+
if version.LooseVersion(PyQt5.PYQT_VERSION) < '4.8':
401401
logger.error(
402402
'This version of PyQt is too old. PyBitmessage requries'
403403
' PyQt 4.8 or later.')
404404
passed = False
405-
if version.LooseVersion(qtpy.QT_VERSION) < '4.7':
405+
if version.LooseVersion(PyQt5.QT_VERSION) < '4.7':
406406
logger.error(
407407
'This version of Qt is too old. PyBitmessage requries'
408408
' Qt 4.7 or later.')

src/fallback/__init__.py

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,44 @@ def RIPEMD160Hash(data=None):
3232
return hasher
3333

3434
try:
35-
import qtpy
35+
import PyQt5
3636
except ImportError:
3737
try:
38-
from PyQt5 import QtCore, QtGui, QtWidgets, QtNetwork, uic
38+
import qtpy as PyQt5
3939
except ImportError:
40-
qtpy = None
41-
else:
42-
import sys
43-
import types
40+
pass
41+
else:
42+
from PyQt5 import QtCore
43+
44+
QtCore.Signal = QtCore.pyqtSignal
45+
PyQt5.PYQT_VERSION = QtCore.PYQT_VERSION_STR
46+
PyQt5.QT_VERSION = QtCore.QT_VERSION_STR
47+
# try:
48+
# from qtpy import QtCore, QtGui, QtWidgets, QtNetwork, uic
49+
# except ImportError:
50+
# PyQt5 = None
51+
# else:
52+
# import sys
53+
# import types
4454

45-
QtCore.Signal = QtCore.pyqtSignal
46-
context = {
47-
'API': 'pyqt5', # for tr
48-
'PYQT_VERSION': QtCore.PYQT_VERSION_STR,
49-
'QT_VERSION': QtCore.QT_VERSION_STR,
50-
'QtCore': QtCore,
51-
'QtGui': QtGui,
52-
'QtWidgets': QtWidgets,
53-
'QtNetwork': QtNetwork,
54-
'uic': uic
55-
}
56-
try:
57-
from PyQt5 import QtTest
58-
except ImportError:
59-
pass
60-
else:
61-
context['QtTest'] = QtTest
62-
qtpy = types.ModuleType(
63-
'qtpy', 'PyQt5 based dynamic fallback for qtpy')
64-
qtpy.__dict__.update(context)
65-
sys.modules['qtpy'] = qtpy
55+
# QtCore.Signal = QtCore.pyqtSignal
56+
# context = {
57+
# 'API': 'pyqt5', # for tr
58+
# 'PYQT_VERSION': QtCore.PYQT_VERSION_STR,
59+
# 'QT_VERSION': QtCore.QT_VERSION_STR,
60+
# 'QtCore': QtCore,
61+
# 'QtGui': QtGui,
62+
# 'QtWidgets': QtWidgets,
63+
# 'QtNetwork': QtNetwork,
64+
# 'uic': uic
65+
# }
66+
# try:
67+
# from PyQt5 import QtTest
68+
# except ImportError:
69+
# pass
70+
# else:
71+
# context['QtTest'] = QtTest
72+
# PyQt5 = types.ModuleType(
73+
# 'PyQt5', 'qtpy based dynamic fallback for PyQt5')
74+
# PyQt5.__dict__.update(context)
75+
# sys.modules['PyQt5'] = PyQt5

0 commit comments

Comments
 (0)