-
Notifications
You must be signed in to change notification settings - Fork 34
/
setup.py
executable file
·113 lines (98 loc) · 4.27 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python
"""The distutils setup script.
To install vmchecker run
$ ./setup.py install --home=~
which install vmchecker to ~/lib/python.
Probably, you'll need to setup PYTHONPATH for python
to see your library
$ export PYTHONPATH=~/lib/python/
You can run tests using
$ ./tests/run-all.sh
"""
from distutils.core import setup
from distutils import cmd
from distutils.command.install_data import install_data as _install_data
from distutils.command.build import build as _build
import os
class build_trans(cmd.Command):
description = 'Compile .po files into .mo files'
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
name = self.distribution.get_name()
po_dir = os.path.join(os.path.dirname(os.curdir), os.path.join(self.distribution.package_dir[name], 'po'))
for path, names, filenames in os.walk(po_dir):
for f in filenames:
if f.endswith('.po'):
lang = f[:-3]
src = os.path.join(path, f)
dest_path = os.path.join('build', 'locale', lang, 'LC_MESSAGES')
dest = os.path.join(dest_path, name + '.mo')
if not os.path.exists(dest_path):
os.makedirs(dest_path)
if not os.path.exists(dest):
print 'Compiling %s' % src
os.system("msgfmt -c " + src + " -o " + dest)
# msgfmt.make(src, dest)
else:
src_mtime = os.stat(src)[8]
dest_mtime = os.stat(dest)[8]
if src_mtime > dest_mtime:
print 'Compiling %s' % src
# msgfmt.make(src, dest)
os.system("msgfmt -c " + src + " -o " + dest)
class build(_build):
sub_commands = _build.sub_commands + [('build_trans', None)]
def run(self):
_build.run(self)
class install_data(_install_data):
def run(self):
name = self.distribution.get_name()
for lang in os.listdir('build/locale/'):
lang_dir = os.path.join('share', 'locale', lang, 'LC_MESSAGES')
lang_file = os.path.join('build', 'locale', lang, 'LC_MESSAGES', name + '.mo')
self.data_files.append( (lang_dir, [lang_file]) )
_install_data.run(self)
cmdclass = {
'build': build,
'build_trans': build_trans,
'install_data': install_data,
}
setup(name = 'vmchecker',
version = '0.5',
author = 'vmchecker',
author_email = '[email protected]',
url = 'http://github.com/vmchecker/vmchecker/tree/master',
description = 'An online homework evaluator',
license = 'MIT',
platforms = 'Linux',
packages = ['vmchecker'],
package_dir = {'vmchecker': 'vmchecker'},
package_data = {'vmchecker': ['examples/storer-config-template',
'examples/tester-config-template',
'examples/so-linux_vmchecker_build.sh',
'examples/so-linux_vmchecker_run.sh',
'examples/so-win_vmchecker_build.sh',
'examples/so-win_vmchecker_run.sh',
'examples/one_reboot_runner.py',
'examples/auth_file.json',
]},
scripts = ['bin/vmchecker-init-course',
'bin/vmchecker-queue-manager',
'bin/vmchecker-submit',
'bin/vmchecker-resubmit',
'bin/vmchecker-reset-db',
'bin/vmchecker-update-db',
'bin/vmchecker-vm-executor',
'bin/vmchecker-view-grades',
'bin/vmchecker-team-manager',
'bin/vmchecker-download-external-files',
],
data_files = [('/etc/init.d/', ['etc/init.d/vmchecker']),
('/etc/vmchecker/', ['etc/vmchecker/config.list',
'etc/vmchecker/ldap.config',
'etc/vmchecker/acl.config',
])],
cmdclass = cmdclass)