Project

General

Profile

Download (2.46 KB) Statistics
| Branch: | Tag: | Revision:

root / setup.py @ 64438aee

1
#! /usr/bin/env python
2
# -*- coding: utf-8 -*-
3

    
4
from distutils.command.sdist import sdist
5
from setuptools import setup, find_packages
6
import os
7
import glob
8
import re
9

    
10

    
11
class eo_sdist(sdist):
12

    
13
    def run(self):
14
        print "creating VERSION file"
15
        if os.path.exists('VERSION'):
16
            os.remove('VERSION')
17
        version = get_version()
18
        version_file = open('VERSION', 'w')
19
        version_file.write(version)
20
        version_file.close()
21
        sdist.run(self)
22
        print "removing VERSION file"
23
        if os.path.exists('VERSION'):
24
            os.remove('VERSION')
25

    
26

    
27
def get_version():
28

    
29
    version = None
30
    for d in glob.glob('*'):
31
        if not os.path.isdir(d):
32
            continue
33
        module_file = os.path.join(d, '__init__.py')
34
        if not os.path.exists(module_file):
35
            continue
36
        for v in re.findall("""__version__ *= *['"](.*)['"]""",
37
                open(module_file).read()):
38
            assert version is None
39
            version = v
40
        if version:
41
            break
42
    assert version is not None
43
    if os.path.exists('.git'):
44
        import subprocess
45
        p = subprocess.Popen(['git','describe','--dirty','--match=v*'],
46
                stdout=subprocess.PIPE)
47
        result = p.communicate()[0]
48
        assert p.returncode == 0, 'git returned non-zero'
49
        new_version = result.split()[0][1:]
50
        assert new_version.split('-')[0] == version, '__version__ must match the last git annotated tag'
51
        version = new_version.replace('-', '.')
52
    return version
53

    
54

    
55
setup(
56
    name='uauth',
57
    version=get_version(),
58
    description='Captive portal in the Cloud',
59
    author='Serghei Mihai',
60
    author_email='smihai@entrouvert.com',
61
    packages=find_packages(),
62
    include_package_data=True,
63
    scripts=('manage.py',),
64
    classifiers=[
65
        'Development Status :: 4 - Beta',
66
        'Environment :: Web Environment',
67
        'Framework :: Django',
68
        'Intended Audience :: Developers',
69
        'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
70
        'Operating System :: OS Independent',
71
        'Programming Language :: Python',
72
        'Programming Language :: Python :: 2',
73
    ],
74
    install_requires=['django>=1.7, <1.8',
75
                      'django-mellon',
76
                      'python-ldap',
77
                      'gadjo',
78
                      'requests',
79
                      'django-tables2',
80
    ],
81
    zip_safe=False,
82
    cmdclass={
83
        'sdist': eo_sdist
84
    },
85
)
(6-6/6)