Require QtWebEngine with --backend webengine
This commit is contained in:
parent
ed3198db4e
commit
d315a3131d
@ -44,19 +44,25 @@ except ImportError:
|
|||||||
# initialization needs to take place before that!
|
# initialization needs to take place before that!
|
||||||
|
|
||||||
|
|
||||||
def _missing_str(name, *, windows=None, pip=None):
|
def _missing_str(name, *, windows=None, pip=None, webengine=False):
|
||||||
"""Get an error string for missing packages.
|
"""Get an error string for missing packages.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
name: The name of the package.
|
name: The name of the package.
|
||||||
windows: String to be displayed for Windows.
|
windows: String to be displayed for Windows.
|
||||||
pip: pypi package name.
|
pip: pypi package name.
|
||||||
|
webengine: Whether this is checking the QtWebEngine package
|
||||||
"""
|
"""
|
||||||
blocks = ["Fatal error: <b>{}</b> is required to run qutebrowser but "
|
blocks = ["Fatal error: <b>{}</b> is required to run qutebrowser but "
|
||||||
"could not be imported! Maybe it's not installed?".format(name)]
|
"could not be imported! Maybe it's not installed?".format(name)]
|
||||||
lines = ['Please search for the python3 version of {} in your '
|
lines = ['Please search for the python3 version of {} in your '
|
||||||
'distributions packages, or install it via pip.'.format(name)]
|
'distributions packages, or install it via pip.'.format(name)]
|
||||||
blocks.append('<br />'.join(lines))
|
blocks.append('<br />'.join(lines))
|
||||||
|
if webengine:
|
||||||
|
lines = ['Note QtWebEngine is not available for some distributions '
|
||||||
|
'(like Debian/Ubuntu), so you need to start without '
|
||||||
|
'--backend webengine there.']
|
||||||
|
else:
|
||||||
lines = ['<b>If you installed a qutebrowser package for your '
|
lines = ['<b>If you installed a qutebrowser package for your '
|
||||||
'distribution, please report this as a bug.</b>']
|
'distribution, please report this as a bug.</b>']
|
||||||
blocks.append('<br />'.join(lines))
|
blocks.append('<br />'.join(lines))
|
||||||
@ -230,7 +236,7 @@ def check_ssl_support():
|
|||||||
_die(text)
|
_die(text)
|
||||||
|
|
||||||
|
|
||||||
def check_libraries():
|
def check_libraries(args):
|
||||||
"""Check if all needed Python libraries are installed."""
|
"""Check if all needed Python libraries are installed."""
|
||||||
modules = {
|
modules = {
|
||||||
'PyQt5.QtWebKit': _missing_str("PyQt5.QtWebKit"),
|
'PyQt5.QtWebKit': _missing_str("PyQt5.QtWebKit"),
|
||||||
@ -257,6 +263,9 @@ def check_libraries():
|
|||||||
"or Install via pip.",
|
"or Install via pip.",
|
||||||
pip="PyYAML"),
|
pip="PyYAML"),
|
||||||
}
|
}
|
||||||
|
if args.backend == 'webengine':
|
||||||
|
modules['PyQt5.QtWebEngineWidgets'] = _missing_str("QtWebEngine",
|
||||||
|
webengine=True)
|
||||||
for name, text in modules.items():
|
for name, text in modules.items():
|
||||||
try:
|
try:
|
||||||
importlib.import_module(name)
|
importlib.import_module(name)
|
||||||
@ -264,22 +273,6 @@ def check_libraries():
|
|||||||
_die(text, e)
|
_die(text, e)
|
||||||
|
|
||||||
|
|
||||||
def maybe_import_webengine():
|
|
||||||
"""Import QtWebEngineWidgets before QApplication is created.
|
|
||||||
|
|
||||||
See https://github.com/The-Compiler/qutebrowser/pull/1629#issuecomment-231613099
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
from PyQt5 import QtWebEngineWidgets # pylint: disable=unused-variable
|
|
||||||
except ImportError as e:
|
|
||||||
from qutebrowser.utils import log
|
|
||||||
from PyQt5.QtCore import QCoreApplication
|
|
||||||
log.init.debug("Failed to import QtWebEngineWidgets: {}".format(e))
|
|
||||||
if 'QCoreApplication' in str(e):
|
|
||||||
log.init.debug("QApplication instance: {}".format(
|
|
||||||
QCoreApplication.instance()))
|
|
||||||
|
|
||||||
|
|
||||||
def remove_inputhook():
|
def remove_inputhook():
|
||||||
"""Remove the PyQt input hook.
|
"""Remove the PyQt input hook.
|
||||||
|
|
||||||
@ -324,6 +317,5 @@ def earlyinit(args):
|
|||||||
check_qt_version()
|
check_qt_version()
|
||||||
check_ssl_support()
|
check_ssl_support()
|
||||||
remove_inputhook()
|
remove_inputhook()
|
||||||
check_libraries()
|
check_libraries(args)
|
||||||
init_log(args)
|
init_log(args)
|
||||||
maybe_import_webengine()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user