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