-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·171 lines (147 loc) · 5.4 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/python
import os, errno
from distutils.core import setup
from distutils import sysconfig, cmd
from distutils.command.build import build as _build
from distutils.command.clean import clean as _clean
from distutils.command.install import install as _install
from distutils.util import change_root
from distutils.dir_util import remove_tree, copy_tree, mkpath
# quick hack to support generating locale files
class build(_build):
def __init__(self, *a, **kw):
self.sub_commands = self.sub_commands + [
('build_locale', None),
]
_build.__init__(self, *a, **kw)
class build_locale(cmd.Command):
user_options = [
('build-dir=', 'd', "directory to build to"),
('po-dir=', 'd', "directory holding the domain dirs and in them PO-files"),
]
def initialize_options(self):
self.build_dir = 'locale'
self.build_base = None
self.po_dir = 'po'
def finalize_options (self):
self.set_undefined_options('build',
('build_base', 'build_base'))
self.build_dir = change_root(self.build_base, self.build_dir)
def run(self):
for domain in os.listdir(self.po_dir):
try:
l = os.listdir(os.path.join(self.po_dir, domain))
except OSError, e:
if e.errno == errno.ENOTDIR:
continue
else:
raise
for po in l:
if not po.endswith('.po'):
continue
locale = po[:-len('.po')]
path = os.path.join(self.build_dir,
locale,
'LC_MESSAGES')
mkpath(path)
self.spawn(['msgfmt', '-o',
os.path.join(path, '%s.mo' % domain),
os.path.join(self.po_dir,
domain,
po)])
class clean(_clean):
def run(self):
self.run_command('clean_locale')
_clean.run(self)
class clean_locale(cmd.Command):
user_options = [
('build-dir=', 'd', "directory to build to"),
]
def initialize_options(self):
self.build_dir = None
def finalize_options (self):
self.set_undefined_options('build_locale',
('build_dir', 'build_dir'))
def run(self):
if os.path.exists(self.build_dir):
remove_tree(self.build_dir, dry_run=self.dry_run)
class install(_install):
def __init__(self, *a, **kw):
self.sub_commands = self.sub_commands + [
('install_locale', None),
]
_install.__init__(self, *a, **kw)
class install_locale(cmd.Command):
user_options = [
('install-dir=', 'd', "directory to install locales to"),
('build-dir=','b', "build directory (where to install from)"),
('skip-build', None, "skip the build steps"),
]
boolean_options = ['skip-build']
def initialize_options(self):
self.build_dir = None
self.install_dir = None
self.root = None
self.prefix = None
self.skip_build = None
def finalize_options (self):
self.set_undefined_options('build_locale',
('build_dir', 'build_dir'))
self.set_undefined_options('install',
('skip_build', 'skip_build'))
if self.install_dir is None:
self.set_undefined_options('install',
('root', 'root'))
self.set_undefined_options('install',
('prefix', 'prefix'))
prefix = self.prefix
if self.root is not None:
prefix = change_root(self.root, prefix)
self.install_dir = os.path.join(prefix, 'share', 'locale')
def run(self):
if not self.skip_build:
self.run_command('build_locale')
copy_tree(src=self.build_dir,
dst=self.install_dir,
dry_run=self.dry_run)
if __name__=='__main__':
setup(name="eocmanage",
description="Web interface to the Enemies-of-Carlotta Mailing List Manager",
long_description="""
Eocmanage provides a simple WWW interface to managing multiple EoC
mailing lists.
It is designed to enable ISPs to provide their clients with easily
administratable mailing lists, to create a virtual domain
lists.example.com with mailing lists in it, etc.
""".strip(),
author="Tommi Virtanen",
author_email="tv@inoi.fi",
url="http://www.inoi.fi/open/trac/eocmanage",
license="GNU GPL",
cmdclass={'build': build,
'build_locale': build_locale,
'clean': clean,
'clean_locale': clean_locale,
'install': install,
'install_locale': install_locale,
},
packages=[
"eocmanage",
"eocmanage.test",
"eocmanage.test.util",
],
scripts=[
"bin/eocmanage-config",
"bin/eocmanage-deliver",
],
data_files=[
(os.path.join(sysconfig.get_python_lib(), 'eocmanage'),
[
'eocmanage/main.html',
'eocmanage/list.html',
]),
(os.path.join(sysconfig.get_python_lib(), 'eocmanage', 'style'),
[
'eocmanage/style/eocmanage.css',
]),
])