From 2fdf241da2144695f960ae7e5064c28f90e959f1 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 28 Aug 2014 17:45:55 +0200 Subject: [PATCH] Add dependency on jinja2. --- README.asciidoc | 5 ++++- pkg/PKGBUILD.qutebrowser-git | 2 +- 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 ea55874d8..90e7e6e34 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -74,6 +74,7 @@ The following software and libraries are required to run qutebrowser: (5.3.1 recommended) for Python 3 * https://pypi.python.org/pypi/setuptools/[pkg_resources/setuptools] * http://fdik.org/pyPEG/[pyPEG2] +* http://jinja.pocoo.org/[jinja2] The following libraries are optional and provide colored logging in the console: @@ -85,7 +86,8 @@ On Debian ~~~~~~~~~ ---- -# apt-get install python3-pyqt5 python3-pyqt5.qtwebkit python3-pkg-resources python3-pip +# apt-get install python3-pyqt5 python3-pyqt5.qtwebkit python3-pkg-resources +python3-pip python3-jinja2 # pip3 install pypeg2 --allow-external pypeg2 --allow-unverified pypeg2 ---- @@ -129,6 +131,7 @@ to get Qt and PyQt5. * Get pip as described http://stackoverflow.com/a/12476379[on Stack Overflow]. * Run +pip install --allow-external pypeg2 --allow-unverified pypeg2 pypeg2+ to install pypeg2. +* Run +pip install jinja2+ to install jinja2. 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 a071d140d..d84e1ee5c 100644 --- a/pkg/PKGBUILD.qutebrowser-git +++ b/pkg/PKGBUILD.qutebrowser-git @@ -9,7 +9,7 @@ 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') + 'qt5-webkit>=5.2' 'libxkbcommon-x11' 'python-pypeg2' 'python-jinja') makedepends=('python' 'python-setuptools') optdepends=('python-colorlog: colored logging output') options=(!emptydirs) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index dfb2059c1..3a51255ae 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -112,6 +112,7 @@ def main(): earlyinit.check_pyqt_webkit() earlyinit.check_pkg_resources() earlyinit.check_pypeg2() + earlyinit.check_jinja2() # 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 ffdaa8e71..c78c01b43 100644 --- a/qutebrowser/utils/earlyinit.py +++ b/qutebrowser/utils/earlyinit.py @@ -248,3 +248,17 @@ def check_pypeg2(): pip="pypeg2 --allow-external pypeg2 " "--allow-unverified pypeg2") _die(text) + + +def check_jinja2(): + """Check if jinja2 is installed.""" + try: + import jinja2 # pylint: disable=unused-variable + except ImportError: + text = _missing_str("jinja2", + debian="apt-get install python3-jinja2", + arch="Install python-jinja from the AUR", + windows="Install from http://www.lfd.uci.edu/" + "~gohlke/pythonlibs/#jinja2 or via pip.", + pip="jinja2") + _die(text) diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index 6d65b27ad..ea38b0488 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -179,6 +179,13 @@ def _module_versions(): else: ver = getattr(pypeg2, '__version__', 'yes') lines.append('pypeg2: {}'.format(ver)) + try: + import jinja2 + except ImportError: + pass + else: + ver = getattr(jinja2, '__version__', 'yes') + lines.append('jinja2: {}'.format(ver)) return lines diff --git a/scripts/setupcommon.py b/scripts/setupcommon.py index 65179dc15..89ab8e81c 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'], + 'requires': ['pypeg2', 'jinja2'], 'author': _get_constant('author'), 'author_email': _get_constant('email'), 'license': _get_constant('license'), diff --git a/setup.py b/setup.py index ff6efbaff..857fb5a32 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'], + install_requires=['pypeg2', 'jinja2'], extras_require={'nice-debugging': ['colorlog', 'colorama'], 'checks': ['flake8', 'pylint', 'check-manifest', 'pyroma']},