1 # -*- coding: utf-8 -*-
6 Jinja2 is a template engine written in pure Python. It provides a
7 `Django`_ inspired non-XML syntax but supports inline expressions and
8 an optional `sandboxed`_ environment.
13 Here a small example of a Jinja template::
15 {% extends 'base.html' %}
16 {% block title %}Memberlist{% endblock %}
19 {% for user in users %}
20 <li><a href="{{ user.url }}">{{ user.username }}</a></li>
28 Application logic is for the controller but don't try to make the life
29 for the template designer too hard by giving him too few functionality.
31 For more informations visit the new `Jinja2 webpage`_ and `documentation`_.
33 The `Jinja2 tip`_ is installable via `easy_install` with ``easy_install
36 .. _sandboxed: http://en.wikipedia.org/wiki/Sandbox_(computer_security)
37 .. _Django: http://www.djangoproject.com/
38 .. _Jinja2 webpage: http://jinja.pocoo.org/
39 .. _documentation: http://jinja.pocoo.org/2/documentation/
40 .. _Jinja2 tip: http://dev.pocoo.org/hg/jinja2-main/archive/tip.tar.gz#egg=Jinja2-dev
45 from setuptools import setup, Extension, Feature
46 from distutils.command.build_ext import build_ext
47 from distutils.errors import CCompilerError, DistutilsPlatformError
50 #: don't change the variable and assignment. the fabfile parses this
51 #: file to get the version for deployment from it.
56 documentation_path = 'docs/_build/html'
57 if os.path.exists(documentation_path):
58 documentation_files = []
59 for fn in os.listdir(documentation_path):
60 if not fn.startswith('.'):
61 fn = os.path.join(documentation_path, fn)
62 if os.path.isfile(fn):
63 documentation_files.append(fn)
64 data_files.append(('docs', documentation_files))
67 def get_terminal_width():
68 """Return the current terminal dimensions."""
70 from struct import pack, unpack
71 from fcntl import ioctl
72 from termios import TIOCGWINSZ
73 s = pack('HHHH', 0, 0, 0, 0)
74 return unpack('HHHH', ioctl(sys.stdout.fileno(), TIOCGWINSZ, s))[1]
79 class optional_build_ext(build_ext):
80 """This class allows C extension building to fail."""
85 except DistutilsPlatformError:
88 def build_extension(self, ext):
90 build_ext.build_extension(self, ext)
91 except CCompilerError, x:
94 def _unavailable(self):
95 width = get_terminal_width()
98 An optional C extension could not be compiled, speedups will not be
105 url='http://jinja.pocoo.org/',
107 author='Armin Ronacher',
108 author_email='armin.ronacher@active-4.com',
109 description='A small but fast and easy to use stand-alone template '
110 'engine written in pure python.',
111 long_description=__doc__,
112 # jinja is egg safe. But because we distribute the documentation
113 # in form of html and txt files it's a better idea to extract the files
116 'Development Status :: 5 - Production/Stable',
117 'Environment :: Web Environment',
118 'Intended Audience :: Developers',
119 'License :: OSI Approved :: BSD License',
120 'Operating System :: OS Independent',
121 'Programming Language :: Python',
122 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
123 'Topic :: Software Development :: Libraries :: Python Modules',
124 'Topic :: Text Processing :: Markup :: HTML'
127 data_files=data_files,
129 'speedups': Feature("optional C speed-enhancements",
132 Extension('jinja2._speedups', ['jinja2/_speedups.c'])
136 extras_require={'i18n': ['Babel>=0.8']},
139 jinja2 = jinja2.ext:babel_extract[i18n]