Skip to content
This repository has been archived by the owner on May 31, 2019. It is now read-only.

Commit

Permalink
Remove jinja2 from install_requires
Browse files Browse the repository at this point in the history
  • Loading branch information
c-bata committed Dec 4, 2016
1 parent 5b38e0b commit f805dfe
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
CHANGES
=======

0.1.0 (2016-12-??)
0.0.7 (2016-12-??)
------------------

* headers property in Request object.
* raw_body property in Request object.
* Remove jinja2 from install_requires.
* Update docs.

0.0.6 (2016-12-04)
Expand Down
2 changes: 1 addition & 1 deletion example/template_and_static_files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Please run with wsgicli.

```console
$ pip install kobin wsgicli
$ pip install kobin wsgicli jinja2
$ wsgicli app.py app --reload --static --static-root /static/ --static-dirs ./static/
```

Expand Down
8 changes: 6 additions & 2 deletions kobin/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def index() -> Response:
"""
from importlib.machinery import SourceFileLoader
from jinja2 import Environment, FileSystemLoader
import os
import traceback

Expand Down Expand Up @@ -81,6 +80,7 @@ def __init__(self, root_path, *args, **kwargs):
super().__init__(*args, **kwargs)
self.root_path = root_path
self.update(self.default_config)

self.update_jinja2_environment()

def load_from_pyfile(self, file_name):
Expand All @@ -94,7 +94,11 @@ def load_from_module(self, module):
self.update_jinja2_environment()

def update_jinja2_environment(self):
self['JINJA2_ENV'] = Environment(loader=FileSystemLoader(self['TEMPLATE_DIRS']))
try:
from jinja2 import Environment, FileSystemLoader
self['JINJA2_ENV'] = Environment(loader=FileSystemLoader(self['TEMPLATE_DIRS']))
except ImportError:
pass


def current_app():
Expand Down
5 changes: 4 additions & 1 deletion kobin/environs.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ class TemplateResponse(Response):

def __init__(self, filename, status=200, headers=None, charset='utf-8', **tpl_args):
from . import current_config
self.template = current_config()['JINJA2_ENV'].get_template(filename)
jinja2_env = current_config().get('JINJA2_ENV')
if jinja2_env is None:
raise ImportError('Please install jinja2!')
self.template = jinja2_env.get_template(filename)
self.tpl_args = tpl_args
super().__init__(body='', status=status, headers=headers, charset=charset)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def run_tests(self):
long_description=README + '\n\n' + CHANGES,
classifiers=__classifiers__,
packages=find_packages(exclude=['test*']),
install_requires=['jinja2'],
install_requires=[],
keywords='web framework wsgi',
license=__license__,
include_package_data=True,
Expand Down

0 comments on commit f805dfe

Please sign in to comment.