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
|
#!/usr/bin/env python
# Boots Client Project
# www.launchpad.net/boots
#
# ##### BEGIN LICENSE BLOCK #####
#
# Copyright (C) 2009-2010 Clark Boylan, Ken Brotherton, Max Goodman,
# Victoria Lewis, David Rosenbaum, and Andreas Turriff
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# ##### END LICENSE BLOCK #####
import os.path
import glob
import subprocess
import distutils
import distutils.command.build
setup = distutils.core.setup
import boots.app.info
# Yanked from https://launchpad.net/python-distutils-extra and simplified
class build_i18n(distutils.cmd.Command):
description = "integrate the gettext framework"
user_options = [('domain=', 'd', 'gettext domain'),
('merge-po', 'm', 'merge po files against template'),
('po-dir=', 'p', 'directory that holds the i18n files'),
('bug-contact=', None, 'contact address for msgid bugs')]
boolean_options = ['merge-po']
def initialize_options(self):
self.domain = None
self.merge_po = False
self.bug_contact = None
self.po_dir = None
def finalize_options(self):
if self.domain is None:
self.domain = self.distribution.metadata.name
if self.po_dir is None:
self.po_dir = "po"
def run(self):
"""
Update the language files, generate mo files and add them
to the to be installed files
"""
if not os.path.isdir(self.po_dir):
return
data_files = self.distribution.data_files
if data_files is None:
# in case not data_files are defined in setup.py
self.distribution.data_files = data_files = []
if self.bug_contact is not None:
os.environ["XGETTEXT_ARGS"] = "--msgid-bugs-address=%s " % \
self.bug_contact
max_po_mtime = 0
for po_file in glob.glob("%s/*.po" % self.po_dir):
lang = os.path.basename(po_file[:-3])
mo_dir = os.path.join("build", "mo", lang, "LC_MESSAGES")
mo_file = os.path.join(mo_dir, "%s.mo" % self.domain)
if not os.path.exists(mo_dir):
os.makedirs(mo_dir)
cmd = ["msgfmt", po_file, "-o", mo_file]
po_mtime = os.path.getmtime(po_file)
mo_mtime = os.path.exists(mo_file) and os.path.getmtime(mo_file) or 0
if po_mtime > max_po_mtime:
max_po_mtime = po_mtime
if po_mtime > mo_mtime:
self.spawn(cmd)
targetpath = os.path.join("share/locale", lang, "LC_MESSAGES")
data_files.append((targetpath, (mo_file,)))
class build_with_i18n(distutils.command.build.build):
sub_commands = [("build_i18n", None)]
authors = ["Clark Boylan", "Ken Brotherton", "Max Goodman",
"Victoria Lewis", "David Rosenbaum", "Andreas Turriff"]
# Split out all packages making it easy to add new ones to the config.
# Specify the scripts that should go in /usr/local/bin.
boots_scripts = ["bin/boots"]
# List the packages that we want to install.
boots_api_packages = ["boots.api", "boots.api.nodes"]
boots_app_packages = ["boots.app"]
boots_lib_packages = ["boots.lib", "boots.lib.ui", "boots.lib.ui.components",
"boots.lib.lingos", "boots.lib.lingos.lisp"]
boots_packages = ["boots"] + boots_api_packages + boots_app_packages + boots_lib_packages
# Specify a prefix which will be appended to /usr/share/ and the files to
# go in that dir.
boots_data_files = [("share/man/man1", ["doc/man/boots.1"]),
("share/man/man5", ["doc/man/bootsrc.5"])]
setup(name=boots.app.info.NAME,
version=boots.app.info.VERSION,
description="Drizzle CLI Client",
author= ", ".join(authors),
author_email="boots-discuss@lists.launchpad.net",
license="GPLv3",
url="http://www.launchpad.net/boots/",
requires=["drizzle", "ply"],
scripts=boots_scripts,
packages=boots_packages,
provides=boots_packages,
data_files = boots_data_files,
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 2.6",
"Topic :: Database",
"Topic :: Database :: Front-Ends",
],
cmdclass={"build" : build_with_i18n,
"build_i18n": build_i18n},
options={"build_i18n": {"domain": "boots"}}
)
|