20
20
MO_DIR = os.path.join('build', 'mo')
22
23
class TerminatorDist(Distribution):
23
24
global_options = Distribution.global_options + [
25
("with-documentation", None, "Build/install the documentation"),
24
26
("without-gettext", None, "Don't build/install gettext .mo files"),
25
27
("without-icon-cache", None, "Don't attempt to run gtk-update-icon-cache")]
27
29
def __init__ (self, *args):
30
self.with_documentation = False
28
31
self.without_gettext = False
29
32
self.without_icon_cache = False
30
33
Distribution.__init__(self, *args)
37
if self.distribution.without_gettext:
40
for po in glob.glob (os.path.join (PO_DIR, '*.po')):
41
lang = os.path.basename(po[:-3])
42
mo = os.path.join(MO_DIR, lang, 'terminator.mo')
44
directory = os.path.dirname(mo)
45
if not os.path.exists(directory):
46
info('creating %s' % directory)
47
os.makedirs(directory)
50
info('compiling %s -> %s' % (po, mo))
52
rc = subprocess.call(['msgfmt', '-o', mo, po])
54
raise Warning, "msgfmt returned %d" % rc
56
error("Building gettext files failed. Try setup.py --without-gettext [build|install]")
57
error("Error: %s" % str(e))
61
INTLTOOL_MERGE='intltool-merge'
62
desktop_in='data/terminator.desktop.in'
63
desktop_data='data/terminator.desktop'
64
os.system ("C_ALL=C " + INTLTOOL_MERGE + " -d -u -c " + TOP_BUILDDIR +
65
"/po/.intltool-merge-cache " + TOP_BUILDDIR + "/po " +
66
desktop_in + " " + desktop_data)
40
if not self.distribution.without_gettext:
41
# Build the translations
42
for po in glob.glob (os.path.join (PO_DIR, '*.po')):
43
lang = os.path.basename(po[:-3])
44
mo = os.path.join(MO_DIR, lang, 'terminator.mo')
46
directory = os.path.dirname(mo)
47
if not os.path.exists(directory):
48
info('creating %s' % directory)
49
os.makedirs(directory)
52
info('compiling %s -> %s' % (po, mo))
54
rc = subprocess.call(['msgfmt', '-o', mo, po])
56
raise Warning, "msgfmt returned %d" % rc
58
error("Building gettext files failed. Try setup.py --without-gettext [build|install]")
59
error("Error: %s" % str(e))
63
INTLTOOL_MERGE='intltool-merge'
64
desktop_in='data/terminator.desktop.in'
65
desktop_data='data/terminator.desktop'
66
os.system ("C_ALL=C " + INTLTOOL_MERGE + " -d -u -c " + TOP_BUILDDIR +
67
"/po/.intltool-merge-cache " + TOP_BUILDDIR + "/po " +
68
desktop_in + " " + desktop_data)
70
if self.distribution.with_documentation:
71
# Build the documentation
72
for doc_folder in (glob.glob (os.path.join (DOC_DIR, 'manual*')) + [os.path.join (DOC_DIR, 'apidoc')]):
73
if os.path.isfile(os.path.join(doc_folder, 'Makefile')):
76
os.system("make clean")
77
os.system("make html")
68
80
class Uninstall(Command):
69
81
description = "Attempt an uninstall from an install --record file"
150
163
return data_files
165
def _find_doc_files (self):
168
if self.distribution.with_documentation:
169
for doc_folder in (glob.glob (os.path.join (DOC_DIR, 'manual*')) + [os.path.join (DOC_DIR, 'apidoc')]):
171
src = os.path.join(doc_folder, '_build', 'html')
172
dest_sub = os.path.split(doc_folder[:])[1]
173
if dest_sub[:6] == 'manual':
174
dest_sub = 'html'+dest_sub[6:]
175
dest = os.path.join('share', 'doc', 'terminator', dest_sub)
176
if os.path.isdir(src):
177
for dirpath, dirnames, filenames in os.walk(src):
178
cut_elem_count = len(doc_folder.split(os.sep)) + 2
179
dest_sub = os.path.join(dirpath.split(os.sep)[cut_elem_count:])
180
full_dest_folder = os.path.join(dest, *dest_sub)
181
full_src_filenames = [os.path.join(dirpath, filename) for filename in filenames]
182
data_files.append((full_dest_folder, full_src_filenames))
152
186
class Test(Command):
153
187
user_options = []
154
188
def initialize_options(self):