3 |
3 |
''' Setup script for python-entrouvert
|
4 |
4 |
'''
|
5 |
5 |
|
|
6 |
import glob
|
|
7 |
import re
|
6 |
8 |
import sys
|
|
9 |
import os
|
7 |
10 |
|
8 |
11 |
from setuptools import setup, find_packages
|
9 |
12 |
from setuptools.command.install_lib import install_lib as _install_lib
|
10 |
13 |
from distutils.command.build import build as _build
|
11 |
|
from distutils.command.sdist import sdist as _sdist
|
|
14 |
from distutils.command.sdist import sdist
|
12 |
15 |
from distutils.cmd import Command
|
13 |
16 |
|
14 |
17 |
class compile_translations(Command):
|
... | ... | |
22 |
25 |
pass
|
23 |
26 |
|
24 |
27 |
def run(self):
|
25 |
|
import os
|
26 |
|
import sys
|
27 |
28 |
try:
|
28 |
29 |
from django.core.management.commands.compilemessages import \
|
29 |
30 |
compile_messages
|
... | ... | |
43 |
44 |
class build(_build):
|
44 |
45 |
sub_commands = [('compile_translations', None)] + _build.sub_commands
|
45 |
46 |
|
|
47 |
class eo_sdist(sdist):
|
|
48 |
|
|
49 |
def run(self):
|
|
50 |
print "creating VERSION file"
|
|
51 |
if os.path.exists('VERSION'):
|
|
52 |
os.remove('VERSION')
|
|
53 |
version = get_version()
|
|
54 |
version_file = open('VERSION', 'w')
|
|
55 |
version_file.write(version)
|
|
56 |
version_file.close()
|
|
57 |
sdist.run(self)
|
|
58 |
print "removing VERSION file"
|
|
59 |
if os.path.exists('VERSION'):
|
|
60 |
os.remove('VERSION')
|
|
61 |
|
46 |
62 |
class install_lib(_install_lib):
|
47 |
63 |
def run(self):
|
48 |
64 |
self.run_command('compile_translations')
|
49 |
65 |
_install_lib.run(self)
|
50 |
66 |
|
51 |
67 |
def get_version():
|
52 |
|
import glob
|
53 |
|
import re
|
54 |
|
import os
|
55 |
68 |
|
56 |
69 |
version = None
|
|
70 |
if os.path.exists('VERSION'):
|
|
71 |
version_file = open('VERSION', 'r')
|
|
72 |
version = version_file.read()
|
|
73 |
version.close()
|
|
74 |
return version
|
57 |
75 |
for d in glob.glob('*'):
|
58 |
76 |
if not os.path.isdir(d):
|
59 |
77 |
continue
|
... | ... | |
97 |
115 |
],
|
98 |
116 |
dependency_links=[],
|
99 |
117 |
cmdclass={'build': build, 'install_lib': install_lib,
|
100 |
|
'compile_translations': compile_translations,},
|
|
118 |
'compile_translations': compile_translations,
|
|
119 |
'sdist': eo_sdist},
|
101 |
120 |
)
|
setup.py sdist: store version into the archive