1
|
#! /usr/bin/env python
|
2
|
# -*- coding: utf-8 -*-
|
3
|
|
4
|
import glob
|
5
|
import os
|
6
|
import re
|
7
|
import subprocess
|
8
|
import sys
|
9
|
|
10
|
from setuptools.command.install_lib import install_lib as _install_lib
|
11
|
from distutils.command.build import build as _build
|
12
|
from distutils.command.sdist import sdist
|
13
|
from setuptools import setup, find_packages
|
14
|
|
15
|
from distutils.cmd import Command
|
16
|
|
17
|
|
18
|
class eo_sdist(sdist):
|
19
|
def run(self):
|
20
|
if os.path.exists('VERSION'):
|
21
|
os.remove('VERSION')
|
22
|
version = get_version()
|
23
|
version_file = open('VERSION', 'w')
|
24
|
version_file.write(version)
|
25
|
version_file.close()
|
26
|
sdist.run(self)
|
27
|
if os.path.exists('VERSION'):
|
28
|
os.remove('VERSION')
|
29
|
|
30
|
def get_version():
|
31
|
if os.path.exists('VERSION'):
|
32
|
version_file = open('VERSION', 'r')
|
33
|
version = version_file.read()
|
34
|
version_file.close()
|
35
|
return version
|
36
|
if os.path.exists('.git'):
|
37
|
p = subprocess.Popen(['git', 'describe', '--dirty', '--match=v*'], stdout=subprocess.PIPE)
|
38
|
result = p.communicate()[0]
|
39
|
if p.returncode == 0:
|
40
|
version = result.split()[0][1:]
|
41
|
version = version.replace('-', '.')
|
42
|
return version
|
43
|
return '0'
|
44
|
|
45
|
class compile_translations(Command):
|
46
|
description = 'compile message catalogs to MO files via django compilemessages'
|
47
|
user_options = []
|
48
|
|
49
|
def initialize_options(self):
|
50
|
pass
|
51
|
|
52
|
def finalize_options(self):
|
53
|
pass
|
54
|
|
55
|
def run(self):
|
56
|
try:
|
57
|
from django.core.management import call_command
|
58
|
for path, dirs, files in os.walk('corbo'):
|
59
|
if 'locale' not in dirs:
|
60
|
continue
|
61
|
curdir = os.getcwd()
|
62
|
os.chdir(os.path.realpath(path))
|
63
|
call_command('compilemessages')
|
64
|
os.chdir(curdir)
|
65
|
except ImportError:
|
66
|
sys.stderr.write('!!! Please install Django >= 1.4 to build translations\n')
|
67
|
|
68
|
class build(_build):
|
69
|
sub_commands = [('compile_translations', None)] + _build.sub_commands
|
70
|
|
71
|
|
72
|
class install_lib(_install_lib):
|
73
|
def run(self):
|
74
|
self.run_command('compile_translations')
|
75
|
_install_lib.run(self)
|
76
|
|
77
|
setup(
|
78
|
name='corbo',
|
79
|
version=get_version(),
|
80
|
description='Announces Manager',
|
81
|
author='Serghei Mihai',
|
82
|
author_email='smihai@entrouvert.com',
|
83
|
packages=find_packages(),
|
84
|
include_package_data=True,
|
85
|
scripts=('manage.py',),
|
86
|
url='http://repos.entrouvert.org/corbo.git',
|
87
|
classifiers=[
|
88
|
'Environment :: Web Environment',
|
89
|
'Framework :: Django',
|
90
|
'Intended Audience :: Developers',
|
91
|
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
|
92
|
'Operating System :: OS Independent',
|
93
|
'Programming Language :: Python',
|
94
|
'Programming Language :: Python :: 2',
|
95
|
],
|
96
|
install_requires=['django>=1.7, <1.8',
|
97
|
'django-ckeditor<4.5.3',
|
98
|
'djangorestframework',
|
99
|
'gadjo'
|
100
|
],
|
101
|
zip_safe=False,
|
102
|
cmdclass={
|
103
|
'build': build,
|
104
|
'compile_translations': compile_translations,
|
105
|
'install_lib': install_lib,
|
106
|
'sdist': eo_sdist,
|
107
|
},
|
108
|
|
109
|
)
|