1
|
#! /usr/bin/env python
|
2
|
|
3
|
''' Setup script for python-entrouvert
|
4
|
'''
|
5
|
|
6
|
import sys
|
7
|
|
8
|
from setuptools import setup, find_packages
|
9
|
from setuptools.command.install_lib import install_lib as _install_lib
|
10
|
from distutils.command.build import build as _build
|
11
|
from distutils.command.sdist import sdist as _sdist
|
12
|
from distutils.cmd import Command
|
13
|
|
14
|
class compile_translations(Command):
|
15
|
description = 'compile message catalogs to MO files via django compilemessages'
|
16
|
user_options = []
|
17
|
|
18
|
def initialize_options(self):
|
19
|
pass
|
20
|
|
21
|
def finalize_options(self):
|
22
|
pass
|
23
|
|
24
|
def run(self):
|
25
|
import os
|
26
|
import sys
|
27
|
try:
|
28
|
from django.core.management.commands.compilemessages import \
|
29
|
compile_messages
|
30
|
for path in ['entrouvert/djommon/']:
|
31
|
if path.endswith('.py'):
|
32
|
continue
|
33
|
curdir = os.getcwd()
|
34
|
os.chdir(os.path.realpath(path))
|
35
|
compile_messages(stderr=sys.stderr)
|
36
|
os.chdir(curdir)
|
37
|
except ImportError:
|
38
|
print
|
39
|
sys.stderr.write('!!! Please install Django >= 1.4 to build translations')
|
40
|
print
|
41
|
print
|
42
|
|
43
|
class build(_build):
|
44
|
sub_commands = [('compile_translations', None)] + _build.sub_commands
|
45
|
|
46
|
class install_lib(_install_lib):
|
47
|
def run(self):
|
48
|
self.run_command('compile_translations')
|
49
|
_install_lib.run(self)
|
50
|
|
51
|
def get_version():
|
52
|
import glob
|
53
|
import re
|
54
|
import os
|
55
|
|
56
|
version = None
|
57
|
for d in glob.glob('*'):
|
58
|
if not os.path.isdir(d):
|
59
|
continue
|
60
|
module_file = os.path.join(d, '__init__.py')
|
61
|
if not os.path.exists(module_file):
|
62
|
continue
|
63
|
for v in re.findall("""__version__ *= *['"](.*)['"]""",
|
64
|
open(module_file).read()):
|
65
|
assert version is None
|
66
|
version = v
|
67
|
if version:
|
68
|
break
|
69
|
assert version is not None
|
70
|
if os.path.exists('.git'):
|
71
|
import subprocess
|
72
|
p = subprocess.Popen(['git','describe','--dirty','--match=v*'],
|
73
|
stdout=subprocess.PIPE)
|
74
|
result = p.communicate()[0]
|
75
|
assert p.returncode == 0, 'git returned non-zero'
|
76
|
new_version = result.split()[0][1:]
|
77
|
assert new_version.split('-')[0] == version, '__version__ must match the last git annotated tag'
|
78
|
version = new_version.replace('-', '.')
|
79
|
return version
|
80
|
|
81
|
|
82
|
setup(name="python-entrouvert",
|
83
|
version=get_version(),
|
84
|
license="AGPLv3 or later",
|
85
|
description="Entr'ouvert tools",
|
86
|
url="http://dev.entrouvert.org/projects/python-entrouvert/",
|
87
|
author="Entr'ouvert",
|
88
|
author_email="info@entrouvert.org",
|
89
|
maintainer="Benjamin Dauvergne",
|
90
|
maintainer_email="info@entrouvert.com",
|
91
|
include_package_data=True,
|
92
|
packages=find_packages(),
|
93
|
scripts=('tools/check-git2python-packaging.sh',),
|
94
|
install_requires=[],
|
95
|
tests_require=[
|
96
|
'nose>=0.11.4',
|
97
|
],
|
98
|
dependency_links=[],
|
99
|
cmdclass={'build': build, 'install_lib': install_lib,
|
100
|
'compile_translations': compile_translations,},
|
101
|
)
|