ez_setup is no longer needed/imported in the setup file
[jinja2.git] / setup.py
1 # -*- coding: utf-8 -*-
2 """
3 Jinja2
4 ~~~~~~
5
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.
9
10 Nutshell
11 --------
12
13 Here a small example of a Jinja template::
14
15     {% extends 'base.html' %}
16     {% block title %}Memberlist{% endblock %}
17     {% block content %}
18       <ul>
19       {% for user in users %}
20         <li><a href="{{ user.url }}">{{ user.username }}</a></li>
21       {% endfor %}
22       </ul>
23     {% endblock %}
24
25 Philosophy
26 ----------
27
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.
30
31 For more informations visit the new `Jinja2 webpage`_ and `documentation`_.
32
33 The `Jinja2 tip`_ is installable via `easy_install` with ``easy_install
34 Jinja2==dev``.
35
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
41 """
42 import os
43 import sys
44
45 from setuptools import setup, Extension, Feature
46 from distutils.command.build_ext import build_ext
47 from distutils.errors import CCompilerError, DistutilsPlatformError
48
49
50 data_files = []
51 documentation_path = 'docs/_build/html'
52 if os.path.exists(documentation_path):
53     documentation_files = []
54     for fn in os.listdir(documentation_path):
55         if not fn.startswith('.'):
56             fn = os.path.join(documentation_path, fn)
57             if os.path.isfile(fn):
58                 documentation_files.append(fn)
59     data_files.append(('docs', documentation_files))
60
61
62 def get_terminal_width():
63     """Return the current terminal dimensions."""
64     try:
65         from struct import pack, unpack
66         from fcntl import ioctl
67         from termios import TIOCGWINSZ
68         s = pack('HHHH', 0, 0, 0, 0)
69         return unpack('HHHH', ioctl(sys.stdout.fileno(), TIOCGWINSZ, s))[1]
70     except:
71         return 80
72
73
74 class 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         width = get_terminal_width()
91         print '*' * width
92         print """WARNING:
93 An optional C extension could not be compiled, speedups will not be
94 available."""
95
96
97 setup(
98     name='Jinja2',
99     version='2.0rc1',
100     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.',
106     long_description=__doc__,
107     # 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
109     zip_safe=False,
110     classifiers=[
111         'Development Status :: 4 - Beta',
112         'Environment :: Web Environment',
113         'Intended Audience :: Developers',
114         'License :: OSI Approved :: BSD License',
115         'Operating System :: OS Independent',
116         'Programming Language :: Python',
117         'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
118         'Topic :: Software Development :: Libraries :: Python Modules',
119         'Topic :: Text Processing :: Markup :: HTML'
120     ],
121     packages=['jinja2'],
122     data_files=data_files,
123     features={
124         'speedups': Feature("optional C speed-enhancements",
125             standard=True,
126             ext_modules=[
127                 Extension('jinja2._speedups', ['jinja2/_speedups.c'])
128             ]
129         )
130     },
131     extras_require={'i18n': ['Babel>=0.8']},
132     entry_points="""
133     [babel.extractors]
134     jinja2 = jinja2.ext:babel_extract[i18n]
135     """
136 )