Projet

Général

Profil

Télécharger (2,93 ko) Statistiques
| Branche: | Tag: | Révision:

root / setup.py @ da7fc3a1

1
#! /usr/bin/env python
2

    
3
''' Setup script for python-entrouvert
4
'''
5

    
6
from setuptools import setup, find_packages
7
from setuptools.command.install_lib import install_lib as _install_lib
8
from distutils.command.build import build as _build
9
from distutils.command.sdist import sdist  as _sdist
10
from distutils.cmd import Command
11

    
12
class compile_translations(Command):
13
    description = 'compile message catalogs to MO files via django compilemessages'
14
    user_options = []
15

    
16
    def initialize_options(self):
17
        pass
18

    
19
    def finalize_options(self):
20
        pass
21

    
22
    def run(self):
23
        import os
24
        import sys
25
        from django.core.management.commands.compilemessages import \
26
            compile_messages
27
        for path in ['entrouvert/djommon/']:
28
            if path.endswith('.py'):
29
                continue
30
            curdir = os.getcwd()
31
            os.chdir(os.path.realpath(path))
32
            compile_messages(stderr=sys.stderr)
33
            os.chdir(curdir)
34

    
35
class build(_build):
36
    sub_commands = [('compile_translations', None)] + _build.sub_commands
37

    
38
class install_lib(_install_lib):
39
    def run(self):
40
        self.run_command('compile_translations')
41
        _install_lib.run(self)
42

    
43
def get_version():
44
    import glob
45
    import re
46
    import os
47

    
48
    version = None
49
    for d in glob.glob('*'):
50
        if not os.path.isdir(d):
51
            continue
52
        module_file = os.path.join(d, '__init__.py')
53
        if not os.path.exists(module_file):
54
            continue
55
        for v in re.findall("""__version__ *= *['"](.*)['"]""",
56
                open(module_file).read()):
57
            assert version is None
58
            version = v
59
        if version:
60
            break
61
    assert version is not None
62
    if os.path.exists('.git'):
63
        import subprocess
64
        p = subprocess.Popen(['git','describe','--dirty','--match=v*'],
65
                stdout=subprocess.PIPE)
66
        result = p.communicate()[0]
67
        assert p.returncode == 0, 'git returned non-zero'
68
        new_version = result.split()[0][1:]
69
        assert new_version.split('-')[0] == version, '__version__ must match the last git annotated tag'
70
        version = new_version.replace('-', '.')
71
    return version
72

    
73

    
74
setup(name="python-entrouvert",
75
      version=get_version(),
76
      license="AGPLv3 or later",
77
      description="Entr'ouvert tools",
78
      url="http://dev.entrouvert.org/projects/python-entrouvert/",
79
      author="Entr'ouvert",
80
      author_email="info@entrouvert.org",
81
      maintainer="Benjamin Dauvergne",
82
      maintainer_email="info@entrouvert.com",
83
      include_package_data=True,
84
      packages=find_packages(),
85
      scripts=('tools/check-git2python-packaging.sh',),
86
      install_requires=[],
87
      setup_requires=[
88
          'django>=1.4',
89
      ],
90
      tests_require=[
91
          'nose>=0.11.4',
92
      ],
93
      dependency_links=[],
94
      cmdclass={'build': build, 'install_lib': install_lib,
95
          'compile_translations': compile_translations,
96
          'sdist': sdist},
97
)
(4-4/4)