Use LANG and correct locale dir to load translations
[mussorgsky] / setup.py
1 #!/usr/bin/env python2.5
2  
3 from distutils.core import setup
4 from distutils.core import setup
5 from distutils import cmd
6 #from distutils.command.install import install as _install
7 from distutils.command.install_data import install_data as _install_data
8 from distutils.command.build import build as _build
9
10 import msgfmt
11 import os
12
13 class build_trans(cmd.Command):
14     description = 'Compile .po files into .mo files'
15     def initialize_options(self):
16         pass
17
18     def finalize_options(self):
19         pass
20
21     def run(self):
22         po_dir = os.path.join(os.path.dirname(os.curdir), 'po')
23         for path, names, filenames in os.walk(po_dir):
24             for f in filenames:
25                 if f.endswith('.po'):
26                     lang = f[:len(f) - 3]
27                     src = os.path.join(path, f)
28                     dest_path = os.path.join('build', 'locale', lang, 'LC_MESSAGES')
29                     dest = os.path.join(dest_path, 'mussorgsky.mo')
30                     if not os.path.exists(dest_path):
31                         os.makedirs(dest_path)
32                     if not os.path.exists(dest):
33                         print 'Compiling %s' % src
34                         msgfmt.make(src, dest)
35                     else:
36                         src_mtime = os.stat(src)[8]
37                         dest_mtime = os.stat(dest)[8]
38                         if src_mtime > dest_mtime:
39                             print 'Compiling %s' % src
40                             msgfmt.make(src, dest)
41
42 class build(_build):
43     sub_commands = _build.sub_commands + [('build_trans', None)]
44     def run(self):
45         _build.run(self)
46
47 class install_data(_install_data):
48
49     def run(self):
50         for lang in os.listdir('build/locale/'):
51             lang_dir = os.path.join('share', 'locale', lang, 'LC_MESSAGES')
52             lang_file = os.path.join('build', 'locale', lang, 'LC_MESSAGES', 'mussorgsky.mo')
53             self.data_files.append( (lang_dir, [lang_file]) )
54         _install_data.run(self)
55
56 cmdclass = {
57     'build': build,
58     'build_trans': build_trans,
59     'install_data': install_data,
60 }
61
62 SCRIPTS=  ['data/mussorgsky']
63
64 DATA = [('share/applications/hildon', ['data/mussorgsky.desktop']),
65         ('share/dbus-1/services', ['data/mussorgsky.service']),
66         ('share/pixmaps',['data/mussorgsky-icon.png']),
67         ('lib/mussorgsky', ['src/aa_selection_dialog.py',
68                             'src/album_art_panel.py',
69                             'src/album_art_spec.py',
70                             'src/album_art_thread.py',
71                             'src/browse_panel.py',
72                             'src/download_dialog.py',
73                             'src/edit_panel_tm.py',
74                             'src/fancy_button.py',
75                             'src/mussorgsky.py',
76                             'src/mutagen_backend.py',                            
77                             'src/player_backend.py',
78                             'src/tracker_backend.py',
79                             'src/utils.py',
80                             'src/i18n.py'])]
81  
82 setup(name         = 'mussorgsky',
83       version      = '0.4',
84       description  = 'Music Organizer: metadata editor, album art downloader',
85       author       = 'Ivan Frade',
86       author_email = '<ivan.frade@gmail.com>',
87       url          = 'http://mussorgsky.garage.maemo.org',
88       license      = 'GPL v2 or later',
89       data_files   = DATA,
90       scripts      = SCRIPTS,
91       cmdclass     = cmdclass
92       )