Porting bitmessageqt to Qt5 #1389

Open
g1itch wants to merge 34 commits from g1itch/qt5-wip into v0.6
2 changed files with 46 additions and 36 deletions
Showing only changes of commit 9a1424c189 - Show all commits

View File

@ -384,25 +384,25 @@ def check_pyqt():
""" """
PeterSurda commented 2018-11-11 18:25:52 +01:00 (Migrated from github.com)
Review

These tests are wrong as they compare strings and it thinks '4.11.4' < '4.8'. You need to use

from distiutils.version import LooseVersion

and then wrap these comparisons in LooseVersion like qtpy does it.

These tests are wrong as they compare strings and it thinks '4.11.4' < '4.8'. You need to use `from distiutils.version import LooseVersion` and then wrap these comparisons in `LooseVersion` like qtpy does it.
PeterSurda commented 2018-11-11 18:26:10 +01:00 (Migrated from github.com)
Review

same problem here, should use LooseVersion

same problem here, should use `LooseVersion`
# pylint: disable=no-member # pylint: disable=no-member
try: try:
from fallback import qtpy from fallback import PyQt5
except ImportError: except ImportError:
logger.error( logger.error(
'PyBitmessage requires qtpy, PyQt 4.8 or later and Qt 4.7 or later.' 'PyBitmessage requires PyQt5 or qtpy, PyQt 4.8 or later'
) ' and Qt 4.7 or later.')
qtpy = None PyQt5 = None
if not qtpy: if not PyQt5:
return False return False
logger.info('PyQt Version: %s', qtpy.PYQT_VERSION) logger.info('PyQt Version: %s', PyQt5.PYQT_VERSION)
logger.info('Qt Version: %s', qtpy.QT_VERSION) logger.info('Qt Version: %s', PyQt5.QT_VERSION)
passed = True passed = True
if version.LooseVersion(qtpy.PYQT_VERSION) < '4.8': if version.LooseVersion(PyQt5.PYQT_VERSION) < '4.8':
logger.error( logger.error(
'This version of PyQt is too old. PyBitmessage requries' 'This version of PyQt is too old. PyBitmessage requries'
' PyQt 4.8 or later.') ' PyQt 4.8 or later.')
passed = False passed = False
if version.LooseVersion(qtpy.QT_VERSION) < '4.7': if version.LooseVersion(PyQt5.QT_VERSION) < '4.7':
logger.error( logger.error(
'This version of Qt is too old. PyBitmessage requries' 'This version of Qt is too old. PyBitmessage requries'
' Qt 4.7 or later.') ' Qt 4.7 or later.')

View File

@ -32,34 +32,44 @@ else:
return hasher return hasher
try: try:
import qtpy import PyQt5
except ImportError: except ImportError:
try: try:
from PyQt5 import QtCore, QtGui, QtWidgets, QtNetwork, uic import qtpy as PyQt5
except ImportError: except ImportError:
qtpy = None pass
else: else:
import sys from PyQt5 import QtCore
import types
QtCore.Signal = QtCore.pyqtSignal QtCore.Signal = QtCore.pyqtSignal
context = { PyQt5.PYQT_VERSION = QtCore.PYQT_VERSION_STR
'API': 'pyqt5', # for tr PyQt5.QT_VERSION = QtCore.QT_VERSION_STR
'PYQT_VERSION': QtCore.PYQT_VERSION_STR, # try:
'QT_VERSION': QtCore.QT_VERSION_STR, # from qtpy import QtCore, QtGui, QtWidgets, QtNetwork, uic
'QtCore': QtCore, # except ImportError:
'QtGui': QtGui, # PyQt5 = None
'QtWidgets': QtWidgets, # else:
'QtNetwork': QtNetwork, # import sys
'uic': uic # import types
}
try: # QtCore.Signal = QtCore.pyqtSignal
from PyQt5 import QtTest # context = {
except ImportError: # 'API': 'pyqt5', # for tr
pass # 'PYQT_VERSION': QtCore.PYQT_VERSION_STR,
else: # 'QT_VERSION': QtCore.QT_VERSION_STR,
context['QtTest'] = QtTest # 'QtCore': QtCore,
qtpy = types.ModuleType( # 'QtGui': QtGui,
'qtpy', 'PyQt5 based dynamic fallback for qtpy') # 'QtWidgets': QtWidgets,
qtpy.__dict__.update(context) # 'QtNetwork': QtNetwork,
sys.modules['qtpy'] = qtpy # 'uic': uic
# }
# try:
# from PyQt5 import QtTest
# except ImportError:
# pass
# else:
# context['QtTest'] = QtTest
# PyQt5 = types.ModuleType(
# 'PyQt5', 'qtpy based dynamic fallback for PyQt5')
# PyQt5.__dict__.update(context)
# sys.modules['PyQt5'] = PyQt5