Simplify package output in earlyinit.py.

It doesn't really help much to have package names for distributions in there,
and it's way too much effort. Closes #475.
This commit is contained in:
Florian Bruhin 2015-03-20 07:16:47 +01:00
parent adb11360db
commit f77c0f9afa

View File

@ -35,34 +35,26 @@ except ImportError:
# initialisation needs to take place before that! # initialisation needs to take place before that!
def _missing_str(name, debian=None, arch=None, windows=None, pip=None): def _missing_str(name, *, windows=None, pip=None):
"""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.
debian: String to be displayed for Debian.
arch: String to be displayed for Archlinux.
windows: String to be displayed for Windows. windows: String to be displayed for Windows.
pip: pypi package name. pip: pypi package name.
""" """
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)]
if debian is not None: lines = ['Please search for the python3 version of {} in your '
lines = ["<b>On Debian/Ubuntu:</b>"] 'distributions packages, or install it via pip.'.format(name)]
lines += debian.splitlines()
blocks.append('<br />'.join(lines)) blocks.append('<br />'.join(lines))
if arch is not None: lines = ['<b>If you installed a qutebrowser package for your '
lines = ["<b>On Archlinux:</b>"] 'distribution, please report this as a bug.</b>']
lines += arch.splitlines()
blocks.append('<br />'.join(lines)) blocks.append('<br />'.join(lines))
if windows is not None: if windows is not None:
lines = ["<b>On Windows:</b>"] lines = ["<b>On Windows:</b>"]
lines += windows.splitlines() lines += windows.splitlines()
blocks.append('<br />'.join(lines)) blocks.append('<br />'.join(lines))
lines = ["<b>For other distributions:</b>",
"Check your package manager for similarly named packages or "
"install via pip."]
blocks.append('<br />'.join(lines))
if pip is not None: if pip is not None:
lines = ["<b>Using pip:</b>"] lines = ["<b>Using pip:</b>"]
lines.append("pip3 install {}".format(pip)) lines.append("pip3 install {}".format(pip))
@ -179,10 +171,6 @@ def check_pyqt_core():
import PyQt5.QtCore # pylint: disable=unused-variable import PyQt5.QtCore # pylint: disable=unused-variable
except ImportError as e: except ImportError as e:
text = _missing_str('PyQt5', text = _missing_str('PyQt5',
debian="apt-get install python3-pyqt5 "
"python3-pyqt5.qtwebkit",
arch="pacman -S python-pyqt5 qt5-webkit<br />"
"or install the qutebrowser package from AUR",
windows="Use the installer by Riverbank computing " windows="Use the installer by Riverbank computing "
"or the standalone qutebrowser exe.<br />" "or the standalone qutebrowser exe.<br />"
"http://www.riverbankcomputing.co.uk/" "http://www.riverbankcomputing.co.uk/"
@ -216,41 +204,25 @@ def check_qt_version():
def check_libraries(): def check_libraries():
"""Check if all needed Python libraries are installed.""" """Check if all needed Python libraries are installed."""
modules = { modules = {
'PyQt5.QtWebKit': 'PyQt5.QtWebKit': _missing_str("PyQt5.QtWebKit"),
_missing_str("QtWebKit",
debian="apt-get install python3-pyqt5.qtwebkit",
arch="pacman -S qt5-webkit"),
'pkg_resources': 'pkg_resources':
_missing_str("pkg_resources", _missing_str("pkg_resources/setuptools",
debian="apt-get install python3-pkg-resources", windows="Run python -m ensurepip."),
arch="pacman -S python-setuptools",
windows="Run python -m ensurepip "
"(python >= 3.4) or scripts/ez_setup.py."),
'pypeg2': 'pypeg2':
_missing_str("pypeg2", _missing_str("pypeg2",
debian="No package available, do 'apt-get install "
"python3-pip' and then install via pip3.",
arch="Install python-pypeg2 from the AUR",
windows="Install via pip.",
pip="pypeg2"), pip="pypeg2"),
'jinja2': 'jinja2':
_missing_str("jinja2", _missing_str("jinja2",
debian="apt-get install python3-jinja2",
arch="Install python-jinja from community",
windows="Install from http://www.lfd.uci.edu/" windows="Install from http://www.lfd.uci.edu/"
"~gohlke/pythonlibs/#jinja2 or via pip.", "~gohlke/pythonlibs/#jinja2 or via pip.",
pip="jinja2"), pip="jinja2"),
'pygments': 'pygments':
_missing_str("pygments", _missing_str("pygments",
debian="apt-get install python3-pygments",
arch="Install python-pygments from community",
windows="Install from http://www.lfd.uci.edu/" windows="Install from http://www.lfd.uci.edu/"
"~gohlke/pythonlibs/#pygments or via pip.", "~gohlke/pythonlibs/#pygments or via pip.",
pip="pygments"), pip="pygments"),
'yaml': 'yaml':
_missing_str("PyYAML", _missing_str("PyYAML",
debian="apt-get install python3-yaml",
arch="pacman -S python-yaml",
windows="Use the installers at " windows="Use the installers at "
"http://pyyaml.org/download/pyyaml/ (py3.4) " "http://pyyaml.org/download/pyyaml/ (py3.4) "
"or Install via pip.", "or Install via pip.",