{{ banner }}

from setuptools import setup, find_packages
from codecs import open
from os import path

here = path.abspath(path.dirname(__file__))

# Py3 compatibility hacks, borrowed from IPython.
try:
    execfile
except NameError:
    def execfile(fname, globs, locs=None):
        locs = locs or globs
        exec(compile(open(fname).read(), fname, "exec"), globs, locs)

# Get the long description from the README file
try:
    with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
        long_description = f.read()
except:
    long_description = ''

# Get the classifiers from the classifiers file
tolines = lambda c: list(filter(None, map(lambda s: s.strip(), c.split('\n'))))
try:
    with open(path.join(here, 'classifiers.txt'), encoding='utf-8') as f:
        classifiers = tolines(f.read())
except:
    classifiers = []

version_ns = {}
try:
    execfile(path.join(here, '{{ python.version_file }}'), version_ns)
except EnvironmentError:
    version = 'dev'
else:
    version = version_ns.get('__version__', 'dev')

setup(
    {% for k, v in setup.items()|sort -%}
        {{ k }} = {{ v | pprint }},{{ '\n    ' }}
    {%- endfor -%}
    version = version,
    long_description = long_description,
    classifiers = classifiers,
    packages = find_packages(exclude=['ez_setup', 'example', 'test']),
    include_package_data = True,
    {% if install_requires -%}
        install_requires = {{ install_requires | pprint }},{{ '\n    ' }}
    {%- endif -%}
    {% if extras_require -%}
        extras_require = {{ extras_require | pprint }},{{ '\n    ' }}
    {%- endif -%}
    {% if entry_points -%}
        entry_points = {{ entry_points | pprint }},{{ '\n    ' }}
    {%- endif -%}
    url = {{ url | pprint }},
    download_url = {{ download_url | pprint }}.format(version=version),
)
