blob: 837de51e4c022b33838cfa5d34b2fd53bf7e97c3 [file] [log] [blame]
Armin Ronacherde478f62007-02-28 22:35:04 +01001# -*- coding: utf-8 -*-
Armin Ronacher58293062008-02-11 15:36:22 +01002"""
3jinja
4~~~~~
5
6Jinja is a `sandboxed`_ template engine written in pure Python. It
7provides a `Django`_ like non-XML syntax and compiles templates into
8executable python code. It's basically a combination of Django templates
9and python code.
10
11Nutshell
12--------
13
14Here a small example of a Jinja template::
15
16 {% extends 'base.html' %}
17 {% block title %}Memberlist{% endblock %}
18 {% block content %}
19 <ul>
20 {% for user in users %}
21 <li><a href="{{ user.url|e }}">{{ user.username|e }}</a></li>
22 {% endfor %}
23 </ul>
24 {% endblock %}
25
26Philosophy
27----------
28
29Application logic is for the controller but don't try to make the life
30for the template designer too hard by giving him too few functionality.
31
32For more informations visit the new `jinja webpage`_ and `documentation`_.
33
34Note
35----
36
37This is the Jinja 1.0 release which is completely incompatible with the
38old "pre 1.0" branch. The old branch will still receive security updates
39and bugfixes but the 1.0 branch will be the only version that receives
40support.
41
42If you have an application that uses Jinja 0.9 and won't be updated in
43the near future the best idea is to ship a Jinja 0.9 checkout together
44with the application.
45
46The `Jinja tip`_ is installable via `easy_install` with ``easy_install
47Jinja==dev``.
48
49.. _sandboxed: http://en.wikipedia.org/wiki/Sandbox_(computer_security)
50.. _Django: http://www.djangoproject.com/
51.. _jinja webpage: http://jinja.pocoo.org/
52.. _documentation: http://jinja.pocoo.org/documentation/index.html
53.. _Jinja tip: http://dev.pocoo.org/hg/jinja-main/archive/tip.tar.gz#egg=Jinja-dev
54"""
Armin Ronacher0830e252007-03-22 23:45:30 +010055import os
Armin Ronacherd15a4dc2007-05-28 18:16:16 +020056import sys
Armin Ronacher0830e252007-03-22 23:45:30 +010057import ez_setup
58ez_setup.use_setuptools()
Armin Ronacheree2c18e2007-04-20 22:39:04 +020059
Armin Ronacherbd33f112008-04-18 09:17:32 +020060from setuptools import setup, Extension, Feature
61from distutils.command.build_ext import build_ext
62from distutils.errors import CCompilerError, DistutilsPlatformError
Armin Ronacherde478f62007-02-28 22:35:04 +010063
Armin Ronacher0830e252007-03-22 23:45:30 +010064
Armin Ronachere21ced22007-03-22 23:57:10 +010065def list_files(path):
66 for fn in os.listdir(path):
67 if fn.startswith('.'):
68 continue
69 fn = os.path.join(path, fn)
70 if os.path.isfile(fn):
71 yield fn
72
73
Armin Ronacherbd33f112008-04-18 09:17:32 +020074class optional_build_ext(build_ext):
75 """This class allows C extension building to fail."""
76
77 def run(self):
78 try:
79 build_ext.run(self)
80 except DistutilsPlatformError:
81 self._unavailable()
82
83 def build_extension(self, ext):
84 try:
85 build_ext.build_extension(self, ext)
86 except CCompilerError, x:
87 self._unavailable()
88
89 def _unavailable(self):
90 print '*' * 70
91 print """WARNING:
92An optional C extension could not be compiled, speedups will not be
93available."""
94 print '*' * 70
95
96
Armin Ronacherde478f62007-02-28 22:35:04 +010097setup(
Armin Ronacher4a3038d2008-04-07 18:46:27 +020098 name='Jinja 2',
99 version='2.0dev',
Armin Ronacher015b0c92007-11-11 00:10:17 +0100100 url='http://jinja.pocoo.org/',
101 license='BSD',
102 author='Armin Ronacher',
103 author_email='armin.ronacher@active-4.com',
104 description='A small but fast and easy to use stand-alone template '
105 'engine written in pure python.',
Armin Ronacherbd33f112008-04-18 09:17:32 +0200106 long_description=__doc__,
Armin Ronachere21ced22007-03-22 23:57:10 +0100107 # jinja is egg safe. But because we distribute the documentation
108 # in form of html and txt files it's a better idea to extract the files
Armin Ronacher015b0c92007-11-11 00:10:17 +0100109 zip_safe=False,
110 classifiers=[
Armin Ronacherf59bac22008-04-20 13:11:43 +0200111 'Development Status :: 4 Beta',
Armin Ronacherde478f62007-02-28 22:35:04 +0100112 'Environment :: Web Environment',
113 'Intended Audience :: Developers',
114 'License :: OSI Approved :: BSD License',
115 'Operating System :: OS Independent',
116 'Programming Language :: Python',
Armin Ronacher8ebf1f92007-03-03 11:22:18 +0100117 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
118 'Topic :: Software Development :: Libraries :: Python Modules',
119 'Topic :: Text Processing :: Markup :: HTML'
120 ],
Armin Ronacher4a3038d2008-04-07 18:46:27 +0200121 packages=['jinja2'],
Armin Ronacher015b0c92007-11-11 00:10:17 +0100122 data_files=[
Armin Ronacher99e5baa2007-11-17 21:56:19 +0100123 ('docs/html', list(list_files('docs/html'))),
Armin Ronacher72bb2572007-03-23 17:24:48 +0100124 ('docs/txt', list(list_files('docs/src')))
Armin Ronacher0830e252007-03-22 23:45:30 +0100125 ],
Armin Ronacherbd33f112008-04-18 09:17:32 +0200126 features={
127 'speedups': Feature("optional C speed-enhancements",
128 standard=True,
129 ext_modules=[
130 Extension('jinja2._speedups', ['jinja2/_speedups.c'])
131 ]
132 )
133 },
Armin Ronacher2b60fe52008-04-21 08:23:59 +0200134 extras_require={'i18n': ['Babel>=0.8']},
Armin Ronacherf59bac22008-04-20 13:11:43 +0200135 entry_points="""
136 [babel.extractors]
137 jinja2 = jinja.i18n:babel_extract[i18n]
138 """
Armin Ronacherde478f62007-02-28 22:35:04 +0100139)