Project

General

Profile

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

root / setup.py @ f9e8f623

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
import glob
12

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

    
17
    def initialize_options(self):
18
        pass
19

    
20
    def finalize_options(self):
21
        pass
22

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

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

    
39
class sdist(_sdist):
40
    sub_commands = [('compile_translations', None)] + _sdist.sub_commands
41

    
42
class install_lib(_install_lib):
43
    def run(self):
44
        self.run_command('compile_translations')
45
        _install_lib.run(self)
46

    
47
def get_version():
48
    import glob
49
    import re
50
    import os
51

    
52
    version = None
53
    for d in glob.glob('*'):
54
        if not os.path.isdir(d):
55
            continue
56
        module_file = os.path.join(d, '__init__.py')
57
        if not os.path.exists(module_file):
58
            continue
59
        for v in re.findall("""__version__ *= *['"](.*)['"]""",
60
                open(module_file).read()):
61
            assert version is None
62
            version = v
63
        if version:
64
            break
65
    assert version is not None
66
    if os.path.exists('.git'):
67
        import subprocess
68
        p = subprocess.Popen(['git','log','--oneline','HEAD~..'],
69
                stdout=subprocess.PIPE)
70
        result = p.communicate()[0]
71
        version += '-' + result.split()[0]
72
    return version
73

    
74

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