From 14cc77ff429048d38231e90baf7b1fcf84d8f319 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 15 Sep 2014 17:59:33 +0200 Subject: [PATCH] Add pygments as dependency. --- README.asciidoc | 4 +++- pkg/PKGBUILD.qutebrowser-git | 3 ++- qutebrowser/qutebrowser.py | 1 + qutebrowser/utils/earlyinit.py | 14 ++++++++++++++ qutebrowser/utils/version.py | 7 +++++++ scripts/setupcommon.py | 2 +- setup.py | 2 +- 7 files changed, 29 insertions(+), 4 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index 90e7e6e34..d69e43b67 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -75,6 +75,7 @@ The following software and libraries are required to run qutebrowser: * https://pypi.python.org/pypi/setuptools/[pkg_resources/setuptools] * http://fdik.org/pyPEG/[pyPEG2] * http://jinja.pocoo.org/[jinja2] +* http://pygments.org/[pygments] The following libraries are optional and provide colored logging in the console: @@ -87,7 +88,7 @@ On Debian ---- # apt-get install python3-pyqt5 python3-pyqt5.qtwebkit python3-pkg-resources -python3-pip python3-jinja2 +python3-pip python3-jinja2 python3-pygments # pip3 install pypeg2 --allow-external pypeg2 --allow-unverified pypeg2 ---- @@ -132,6 +133,7 @@ to get Qt and PyQt5. * Run +pip install --allow-external pypeg2 --allow-unverified pypeg2 pypeg2+ to install pypeg2. * Run +pip install jinja2+ to install jinja2. +* Run +pip install pygments+ to install pygments. As soon as v0.1 is out, a standalone .exe (built with http://cx-freeze.sourceforge.net/[cx_Freeze]) will be provided. In the diff --git a/pkg/PKGBUILD.qutebrowser-git b/pkg/PKGBUILD.qutebrowser-git index d84e1ee5c..f695bf432 100644 --- a/pkg/PKGBUILD.qutebrowser-git +++ b/pkg/PKGBUILD.qutebrowser-git @@ -9,7 +9,8 @@ arch=(any) url="http://www.qutebrowser.org/" license=('GPL') depends=('python>=3.4' 'python-setuptools' 'python-pyqt5>=5.2' 'qt5-base>=5.2' - 'qt5-webkit>=5.2' 'libxkbcommon-x11' 'python-pypeg2' 'python-jinja') + 'qt5-webkit>=5.2' 'libxkbcommon-x11' 'python-pypeg2' 'python-jinja' + 'python-pygments') makedepends=('python' 'python-setuptools') optdepends=('python-colorlog: colored logging output') options=(!emptydirs) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index 83ccc0610..bd8a71137 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -113,6 +113,7 @@ def main(): earlyinit.check_pkg_resources() earlyinit.check_pypeg2() earlyinit.check_jinja2() + earlyinit.check_pygments() # We do this import late as we need to fix harfbuzz first. from qutebrowser import app from qutebrowser.utils import debug diff --git a/qutebrowser/utils/earlyinit.py b/qutebrowser/utils/earlyinit.py index 4bf251f59..5f591b0e4 100644 --- a/qutebrowser/utils/earlyinit.py +++ b/qutebrowser/utils/earlyinit.py @@ -264,3 +264,17 @@ def check_jinja2(): "~gohlke/pythonlibs/#jinja2 or via pip.", pip="jinja2") _die(text) + + +def check_pygments(): + """Check if pygments is installed.""" + try: + import pygments # pylint: disable=unused-variable + except ImportError: + text = _missing_str("pygments", + debian="apt-get install python3-pygments", + arch="Install python-jinja from the AUR", + windows="Install from http://www.lfd.uci.edu/" + "~gohlke/pythonlibs/#pygments or via pip.", + pip="pygments") + _die(text) diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index 2eb2a9579..56a92b0fb 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -167,6 +167,13 @@ def _module_versions(): else: ver = getattr(jinja2, '__version__', 'yes') lines.append('jinja2: {}'.format(ver)) + try: + import pygments + except ImportError: + pass + else: + ver = getattr(pygments, '__version__', 'yes') + lines.append('pygments: {}'.format(ver)) return lines diff --git a/scripts/setupcommon.py b/scripts/setupcommon.py index 89ab8e81c..204437a99 100644 --- a/scripts/setupcommon.py +++ b/scripts/setupcommon.py @@ -98,7 +98,7 @@ setupdata = { 'description': _get_constant('description'), 'long_description': read_file('README.asciidoc'), 'url': 'http://www.qutebrowser.org/', - 'requires': ['pypeg2', 'jinja2'], + 'requires': ['pypeg2', 'jinja2', 'pygments'], 'author': _get_constant('author'), 'author_email': _get_constant('email'), 'license': _get_constant('license'), diff --git a/setup.py b/setup.py index 857fb5a32..942b0a410 100755 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ try: ['qutebrowser = qutebrowser.qutebrowser:main']}, test_suite='qutebrowser.test', zip_safe=True, - install_requires=['pypeg2', 'jinja2'], + install_requires=['pypeg2', 'jinja2', 'pygments'], extras_require={'nice-debugging': ['colorlog', 'colorama'], 'checks': ['flake8', 'pylint', 'check-manifest', 'pyroma']},