forked from muflone/gespeaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·87 lines (75 loc) · 2.89 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
#!/usr/bin/env python
##
# Project: Gespeaker
# Description: A GTK frontend for espeak
# Author: Fabio Castelli (Muflone) <[email protected]>
# Copyright: 2009-2015 Fabio Castelli
# License: GPL-2+
# 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 2 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, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
##
from distutils.core import setup
from distutils.command.install_data import install_data
from distutils.dep_util import newer
from distutils.log import info
from glob import glob
import os
import sys
class InstallData(install_data):
def run (self):
self.data_files.extend (self._compile_po_files ())
install_data.run (self)
def _compile_po_files (self):
data_files = []
# Don't install language files on win32
if sys.platform == 'win32':
return data_files
PO_DIR = 'po'
for lang in open(os.path.join(PO_DIR, 'availables'), 'r').readlines():
lang = lang.strip()
if lang:
po = os.path.join(PO_DIR, '%s.po' % lang)
mo = os.path.join('build', 'mo', lang, 'gespeaker.mo')
directory = os.path.dirname(mo)
if not os.path.exists(directory):
info('creating %s' % directory)
os.makedirs(directory)
if newer(po, mo):
# True if mo doesn't exist
cmd = 'msgfmt -o %s %s' % (mo, po)
info('compiling %s -> %s' % (po, mo))
if os.system(cmd) != 0:
raise SystemExit('Error while running msgfmt')
dest = os.path.dirname(os.path.join('share', 'locale', lang, 'LC_MESSAGES', 'gespeaker.mo'))
data_files.append((dest, [mo]))
return data_files
setup(
name='Gespeaker',
version='0.8.5',
description='A GTK+ frontend for eSpeak and mbrola',
author='Fabio Castelli',
author_email='[email protected]',
url='http://www.muflone.com/gespeaker/',
license='GPL v2',
scripts=['gespeaker'],
data_files=[
('share/applications', ['data/gespeaker.desktop']),
('share/gespeaker/data', ['data/testing.wav']),
('share/gespeaker/data/icons', glob('data/icons/*')),
('share/gespeaker/data/ui', glob('data/ui/*.glade')),
('share/doc/gespeaker', ['doc/README', 'doc/changelog', 'doc/translators']),
('share/man/man1', ['man/gespeaker.1']),
('share/gespeaker/src', glob('src/*.py'))
],
cmdclass={'install_data': InstallData}
)