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
|
from datetime import datetime
|
52
|
|
53
|
version = None
|
54
|
for d in glob.glob('*'):
|
55
|
if not os.path.isdir(d):
|
56
|
continue
|
57
|
module_file = os.path.join(d, '__init__.py')
|
58
|
if not os.path.exists(module_file):
|
59
|
continue
|
60
|
for v in re.findall("""__version__ *= *['"](.*)['"]""",
|
61
|
open(module_file).read()):
|
62
|
assert version is None
|
63
|
version = v
|
64
|
if version:
|
65
|
break
|
66
|
assert version is not None
|
67
|
if os.path.exists('.git'):
|
68
|
import subprocess
|
69
|
p = subprocess.Popen(['git','log','--oneline','HEAD~..'],
|
70
|
stdout=subprocess.PIPE)
|
71
|
result = p.communicate()[0]
|
72
|
version += '.%s.%s' % (datetime.today().strftime('%Y%m%d'), result.split()[0])
|
73
|
return version
|
74
|
|
75
|
|
76
|
setup(name="entrouvert",
|
77
|
version=get_version(),
|
78
|
license="AGPLv3 or later",
|
79
|
description="Entr'ouvert tools",
|
80
|
url="http://dev.entrouvert.org/projects/python-entrouvert/",
|
81
|
author="Entr'ouvert",
|
82
|
author_email="info@entrouvert.org",
|
83
|
maintainer="Benjamin Dauvergne",
|
84
|
maintainer_email="info@entrouvert.com",
|
85
|
include_package_data=True,
|
86
|
package_data={
|
87
|
'': [
|
88
|
]
|
89
|
},
|
90
|
packages=find_packages(),
|
91
|
scripts=('tools/check-git2python-packaging.sh',),
|
92
|
install_requires=[],
|
93
|
setup_requires=['nose>=0.11.4'],
|
94
|
dependency_links=[],
|
95
|
cmdclass={'build': build, 'install_lib': install_lib,
|
96
|
'compile_translations': compile_translations,
|
97
|
'sdist': sdist},
|
98
|
)
|