1# eventlib - Smart/Async event logging library
2#
3# Copyright (c) 2012-2013  Lincoln Clarete <lincoln@comum.org>
4# Copyright (c) 2012-2013  Yipit, Inc <coders@yipit.com>
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19import os
20import re
21from setuptools import setup, find_packages
22
23
24def parse_requirements():
25    """Rudimentary parser for the `requirements.txt` file
26
27    We just want to separate regular packages from links to pass them to the
28    `install_requires` and `dependency_links` params of the `setup()`
29    function properly.
30    """
31    try:
32        requirements = \
33            map(str.strip, local_file('requirements.txt').split('\n'))
34    except IOError:
35        raise RuntimeError("Couldn't find the `requirements.txt' file :(")
36
37    links = []
38    pkgs = []
39    for req in requirements:
40        if not req:
41            continue
42        if 'http:' in req or 'https:' in req:
43            links.append(req)
44            name, version = re.findall("\#egg=([^\-]+)-(.+$)", req)[0]
45            pkgs.append('{0}=={1}'.format(name, version))
46        else:
47            pkgs.append(req)
48
49    return pkgs, links
50
51
52local_file = lambda f: \
53    open(os.path.join(os.path.dirname(__file__), f)).read()
54
55
56install_requires, dependency_links = parse_requirements()
57
58
59if __name__ == '__main__':
60    setup(
61        name="eventlib",
62        version='0.1.5',
63        description=(
64            u'Library to make it easy to track events in python/django apps'),
65        long_description=local_file('README.md'),
66        author=u'Lincoln de Sousa',
67        author_email=u'lincoln@yipit.com',
68        url='https://github.com/Yipit/eventlib',
69        packages=list(filter(lambda n: not n.startswith('tests'), find_packages())),
70        install_requires=install_requires,
71        dependency_links=dependency_links,
72        entry_points={
73            'console_scripts': [
74                'eventlib = eventlib.runner:main',
75            ],
76        },
77    )
78