Changed check_pyqt() to work with qtpy

(closes #897, closes #1418)
This commit is contained in:
Dmitri Bogomolov 2018-06-27 17:44:55 +03:00
parent acaa2743ef
commit c39c7d1397
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

View File

@ -18,7 +18,7 @@ if not hasattr(sys, 'hexversion') or sys.hexversion < 0x20300F0:
import logging # noqa:E402 import logging # noqa:E402
import subprocess import subprocess
from distutils import version
from importlib import import_module from importlib import import_module
# We can now use logging so set up a simple configuration # We can now use logging so set up a simple configuration
@ -53,23 +53,22 @@ PACKAGE_MANAGER = {
} }
PACKAGES = { PACKAGES = {
"PyQt4": { "qtpy": {
"OpenBSD": "py-qt4", "OpenBSD": "py-qtpy",
"FreeBSD": "py27-qt4", "FreeBSD": "py27-QtPy",
"Debian": "python-qt4", "Debian": "python-qtpy",
"Ubuntu": "python-qt4", "Ubuntu": "python-qtpy",
"Ubuntu 12": "python-qt4", "Ubuntu 12": "python-qtpy",
"Ubuntu 20": "", "openSUSE": "python-QtPy",
"openSUSE": "python-qt", "Fedora": "python2-QtPy",
"Fedora": "PyQt4", "Guix": "",
"Guix": "python2-pyqt@4.11.4", "Gentoo": "dev-python/QtPy",
"Gentoo": "dev-python/PyQt4",
"optional": True, "optional": True,
"description": "description":
"You only need PyQt if you want to use the GUI." "You only need qtpy if you want to use the GUI."
" When only running as a daemon, this can be skipped.\n" " When only running as a daemon, this can be skipped.\n"
"However, you would have to install it manually" "Also maybe you need to install PyQt5 if your package manager"
" because setuptools does not support PyQt." " not installs it as qtpy dependency"
}, },
"msgpack": { "msgpack": {
"OpenBSD": "py-msgpack", "OpenBSD": "py-msgpack",
@ -383,21 +382,21 @@ def check_pyqt():
Here we are checking for PyQt4 with its version, as for it require Here we are checking for PyQt4 with its version, as for it require
PyQt 4.8 or later. PyQt 4.8 or later.
""" """
QtCore = try_import( qtpy = try_import(
'qtpy.QtCore', 'PyBitmessage requires PyQt 4.8 or later and Qt 4.7 or later.') 'qtpy', 'PyBitmessage requires qtpy, PyQt 4.8 or later and Qt 4.7 or later.')
if not QtCore: if not qtpy:
return False return False
logger.info('PyQt Version: %s', QtCore.PYQT_VERSION_STR) logger.info('PyQt Version: %s', qtpy.PYQT_VERSION)
logger.info('Qt Version: %s', QtCore.QT_VERSION_STR) logger.info('Qt Version: %s', qtpy.QT_VERSION)
passed = True passed = True
if QtCore.PYQT_VERSION < 0x40800: if version.LooseVersion(qtpy.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 QtCore.QT_VERSION < 0x40700: if version.LooseVersion(qtpy.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.')
@ -406,7 +405,7 @@ def check_pyqt():
def check_msgpack(): def check_msgpack():
"""Do sgpack module check. """Do msgpack module check.
simply checking if msgpack package with all its dependency simply checking if msgpack package with all its dependency
is available or not as recommended for messages coding. is available or not as recommended for messages coding.