.desktop using absolute paths. Install the icon in the right location.
[mussorgsky] / setup.py
1 #!/usr/bin/env python
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 #  ('share/dbus-1/services', ['data/mussorgsky.service']),
64
65 DATA = [('share/applications', ['data/mussorgsky.desktop']),
66         ('share/icons/hicolor/64x64/apps',['data/mussorgsky-icon.png']),
67         ('lib/mussorgsky', ['src/aa_search.py',
68                             'src/albumArt.py',
69                             'src/albumItem.py',
70                             'src/albumModel.py',
71                             'src/controller.py',
72                             'src/coverItem.py',
73                             'src/coverModel.py',
74                             'src/mussorgsky-qml.py',
75                             'src/mutagen_backend.py', 
76                             'src/player_backend.py',
77                             'src/tracker_backend_dbus.py',
78                             'src/utils.py']),
79         ('lib/mussorgsky/qml', ["ui/AlbumsPage.qml",
80                                 "ui/Alternatives.qml",
81                                 "ui/main.qml",
82                                 "ui/Mussorgsky.qml",
83                                 "ui/SongsPage.qml",
84                                 "ui/UIConstants.js"])]
85  
86 setup(name         = 'mussorgsky',
87       version      = '1.0.0',
88       description  = 'Music Organizer: metadata editor, album art downloader',
89       author       = 'Ivan Frade',
90       author_email = '<ivan.frade@gmail.com>',
91       url          = 'http://mussorgsky.garage.maemo.org',
92       license      = 'GPL v2 or later',
93       data_files   = DATA,
94       scripts      = SCRIPTS,
95 #      cmdclass     = cmdclass
96       )