/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Jasper Groenewegen
  • Date: 2008-07-20 13:23:29 UTC
  • mto: This revision was merged to the branch mainline in revision 560.
  • Revision ID: colbrac@xs4all.nl-20080720132329-srxnl5lf1k3z43jz
Better way to return response

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
 
 
3
2
"""GTK+ Frontends for various Bazaar commands."""
4
3
 
5
4
from distutils.core import setup, Command
6
5
from distutils.command.install_data import install_data
7
 
from distutils.command.build import build
8
6
from distutils.dep_util import newer
9
7
from distutils.log import info
10
8
import glob
35
33
        result = runner.run(suite)
36
34
        return result.wasSuccessful()
37
35
 
38
 
 
39
 
class CreateCredits(Command):
40
 
    description = "Create credits file"
41
 
 
42
 
    user_options = [("url=", None, "URL of branch")]
43
 
 
44
 
    def initialize_options(self):
45
 
        self.url = "."
46
 
 
47
 
    def finalize_options(self):
48
 
        pass
49
 
 
50
 
    def get_command_name(self):
51
 
        return 'build_credits'
52
 
 
53
 
    def run(self):
54
 
        from bzrlib.plugin import load_plugins; load_plugins()
55
 
        from bzrlib.branch import Branch
56
 
        from bzrlib.plugins.stats import find_credits
57
 
 
58
 
        import pickle
59
 
 
60
 
        branch = Branch.open(self.url)
61
 
        credits = find_credits(branch.repository, branch.last_revision())
62
 
 
63
 
        pickle.dump(credits, file("credits.pickle", 'w'))
64
 
        return True
65
 
 
66
 
 
67
 
def is_versioned(cmd):
68
 
    from bzrlib.errors import NotBranchError
69
 
    try:
70
 
        from bzrlib.branch import Branch
71
 
        Branch.open(".")
72
 
        return True
73
 
    except NotBranchError:
74
 
        return False
75
 
 
76
 
 
77
 
class BuildData(build):
78
 
    sub_commands = build.sub_commands[:]
79
 
    sub_commands.append(('build_credits', is_versioned))
80
 
 
81
 
 
82
36
class InstallData(install_data):
83
 
 
84
37
    def run(self):
85
 
        import subprocess
86
38
        self.data_files.extend(self._compile_po_files())
87
39
        self.data_files.extend(self._nautilus_plugin())
88
40
        install_data.run(self)
89
41
 
90
42
        try:
91
 
            subprocess.check_call('gtk-update-icon-cache '
92
 
                                  '-f -t /usr/share/icons/hicolor')
93
 
        except OSError:
 
43
            subprocess.check_call('gtk-update-icon-cache -f -t /usr/share/icons/hicolor')
 
44
        except:
94
45
            pass
95
46
 
96
47
    def _compile_po_files(self):
97
48
        data_files = []
98
 
 
 
49
        
99
50
        # Don't install language files on Win32
100
51
        if sys.platform == 'win32':
101
52
            return data_files
102
 
 
 
53
        
103
54
        PO_DIR = 'po'
104
55
        for po in glob.glob(os.path.join(PO_DIR,'*.po')):
105
56
            lang = os.path.basename(po[:-3])
106
57
            # It's necessary to compile in this directory (not in po_dir)
107
58
            # because install_data can't rename file
108
59
            mo = os.path.join('build', 'mo', lang, 'olive-gtk.mo')
109
 
 
 
60
            
110
61
            directory = os.path.dirname(mo)
111
62
            if not os.path.exists(directory):
112
63
                info('creating %s' % directory)
113
64
                os.makedirs(directory)
 
65
            
114
66
            if newer(po, mo):
115
67
                # True if mo doesn't exist
116
68
                cmd = 'msgfmt -o %s %s' % (mo, po)
117
69
                info('compiling %s -> %s' % (po, mo))
118
70
                if os.system(cmd) != 0:
119
71
                    raise SystemExit('Error while running msgfmt')
120
 
                dest = os.path.dirname(
121
 
                    os.path.join('share', 'locale', lang,
122
 
                                 'LC_MESSAGES', 'olive-gtk.mo'))
 
72
                
 
73
                dest = os.path.dirname(os.path.join('share', 'locale', lang, 'LC_MESSAGES', 'olive-gtk.mo'))
123
74
                data_files.append((dest, [mo]))
 
75
        
124
76
        return data_files
125
 
 
 
77
    
126
78
    def _nautilus_plugin(self):
127
79
        files = []
128
80
        if sys.platform[:5] == 'linux':
129
 
            cmd = os.popen('pkg-config --variable=pythondir nautilus-python',
130
 
                           'r')
131
 
            res = cmd.readline().strip()
 
81
            cmd = os.popen('pkg-config --variable=pythondir nautilus-python', 'r')
 
82
            res = cmd.readline()
132
83
            ret = cmd.close()
 
84
            
133
85
            if ret is None:
134
86
                dest = res[5:]
135
87
                files.append((dest, ['nautilus-bzr.py']))
 
88
        
136
89
        return files
137
90
 
138
91
 
139
 
if __name__ == '__main__':
140
 
    setup(
141
 
        name = "bzr-gtk",
142
 
        version = "0.99.0",
143
 
        maintainer = "Jelmer Vernooij",
144
 
        maintainer_email = "jelmer@samba.org",
145
 
        description = "GTK+ Frontends for various Bazaar commands",
146
 
        license = "GNU GPL v2 or later",
147
 
        scripts = ['olive-gtk', 'bzr-handle-patch', 'bzr-notify'],
148
 
        url = "http://bazaar-vcs.org/BzrGtk",
149
 
        package_dir = {
150
 
            "bzrlib.plugins.gtk": ".",
151
 
            "bzrlib.plugins.gtk.viz": "viz",
152
 
            "bzrlib.plugins.gtk.annotate": "annotate",
153
 
            "bzrlib.plugins.gtk.olive": "olive",
154
 
            "bzrlib.plugins.gtk.tests": "tests",
155
 
            "bzrlib.plugins.gtk.branchview": "branchview",
156
 
            "bzrlib.plugins.gtk.preferences": "preferences",
157
 
            },
158
 
        packages = [
159
 
            "bzrlib.plugins.gtk",
160
 
            "bzrlib.plugins.gtk.viz",
161
 
            "bzrlib.plugins.gtk.annotate",
162
 
            "bzrlib.plugins.gtk.olive",
163
 
            "bzrlib.plugins.gtk.tests",
164
 
            "bzrlib.plugins.gtk.branchview",
165
 
            "bzrlib.plugins.gtk.preferences",
 
92
setup(
 
93
    name = "bzr-gtk",
 
94
    version = "0.95.0",
 
95
    maintainer = "Jelmer Vernooij",
 
96
    maintainer_email = "jelmer@samba.org",
 
97
    description = "GTK+ Frontends for various Bazaar commands",
 
98
    license = "GNU GPL v2 or later",
 
99
    scripts=['olive-gtk', 'bzr-handle-patch', 'bzr-notify'],
 
100
    package_dir = {
 
101
        "bzrlib.plugins.gtk": ".",
 
102
        "bzrlib.plugins.gtk.viz": "viz", 
 
103
        "bzrlib.plugins.gtk.annotate": "annotate",
 
104
        "bzrlib.plugins.gtk.olive": "olive",
 
105
        "bzrlib.plugins.gtk.tests": "tests",
 
106
        "bzrlib.plugins.gtk.branchview": "branchview",
 
107
        "bzrlib.plugins.gtk.preferences": "preferences",
 
108
        },
 
109
    packages = [
 
110
        "bzrlib.plugins.gtk",
 
111
        "bzrlib.plugins.gtk.viz",
 
112
        "bzrlib.plugins.gtk.annotate",
 
113
        "bzrlib.plugins.gtk.olive",
 
114
        "bzrlib.plugins.gtk.tests",
 
115
        "bzrlib.plugins.gtk.branchview",
 
116
        "bzrlib.plugins.gtk.preferences",
166
117
        ],
167
 
        data_files=[('share/olive', ['cmenu.ui',
168
 
                                     ]),
169
 
                    ('share/bzr-gtk', ['credits.pickle']),
170
 
                    ('share/bzr-gtk/icons', ['icons/commit.png',
171
 
                                             'icons/commit16.png',
172
 
                                             'icons/diff.png',
173
 
                                             'icons/diff16.png',
174
 
                                             'icons/log.png',
175
 
                                             'icons/log16.png',
176
 
                                             'icons/pull.png',
177
 
                                             'icons/pull16.png',
178
 
                                             'icons/push.png',
179
 
                                             'icons/push16.png',
180
 
                                             'icons/refresh.png',
181
 
                                             'icons/olive-gtk.png',
182
 
                                             'icons/oliveicon2.png',
183
 
                                             'icons/sign-bad.png',
184
 
                                             'icons/sign-ok.png',
185
 
                                             'icons/sign.png',
186
 
                                             'icons/sign-unknown.png',
187
 
                                             'icons/tag-16.png',
188
 
                                             'icons/bug.png',
189
 
                                             'icons/bzr-icon-64.png']),
190
 
                    ('share/applications', ['olive-gtk.desktop',
191
 
                                            'bazaar-properties.desktop',
192
 
                                            'bzr-handle-patch.desktop',
193
 
                                            'bzr-notify.desktop']),
194
 
                    ('share/application-registry', ['bzr-gtk.applications']),
195
 
                    ('share/pixmaps', ['icons/olive-gtk.png',
196
 
                                       'icons/bzr-icon-64.png']),
197
 
                    ('share/icons/hicolor/scalable/emblems',
198
 
                     ['icons/emblem-bzr-added.svg',
199
 
                      'icons/emblem-bzr-conflict.svg',
200
 
                      'icons/emblem-bzr-controlled.svg',
201
 
                      'icons/emblem-bzr-modified.svg',
202
 
                      'icons/emblem-bzr-removed.svg',
203
 
                      'icons/emblem-bzr-ignored.svg'])
204
 
                    ],
205
 
        cmdclass={'install_data': InstallData,
206
 
                  'build_credits': CreateCredits,
207
 
                  'build': BuildData,
208
 
                  'check': Check}
209
 
        )
 
118
    data_files=[('share/olive', ['olive.glade',
 
119
                                 'cmenu.ui',
 
120
                                ]),
 
121
                ('share/olive/icons', ['icons/commit.png',
 
122
                                 'icons/commit16.png',
 
123
                                 'icons/diff.png',
 
124
                                 'icons/diff16.png',
 
125
                                 'icons/log.png',
 
126
                                 'icons/log16.png',
 
127
                                 'icons/pull.png',
 
128
                                 'icons/pull16.png',
 
129
                                 'icons/push.png',
 
130
                                 'icons/push16.png',
 
131
                                 'icons/refresh.png',
 
132
                                 'icons/oliveicon2.png']),
 
133
                ('share/bzr-gtk/icons', ['icons/sign-bad.png',
 
134
                                 'icons/sign-ok.png',
 
135
                                 'icons/sign.png',
 
136
                                 'icons/sign-unknown.png',
 
137
                                 'icons/bug.png',
 
138
                                 'icons/bzr-icon-64.png']),
 
139
                ('share/applications', ['olive-gtk.desktop',
 
140
                                        'bazaar-properties.desktop',
 
141
                                        'bzr-handle-patch.desktop',
 
142
                                        'bzr-notify.desktop']),
 
143
                ('share/application-registry', ['bzr-gtk.applications']),
 
144
                ('share/pixmaps', ['icons/olive-gtk.png', 'icons/bzr-icon-64.png']),
 
145
                ('share/icons/hicolor/scalable/emblems', 
 
146
                    ['icons/emblem-bzr-added.svg', 
 
147
                        'icons/emblem-bzr-conflict.svg', 
 
148
                        'icons/emblem-bzr-controlled.svg', 
 
149
                        'icons/emblem-bzr-modified.svg',
 
150
                        'icons/emblem-bzr-removed.svg'])
 
151
               ],
 
152
    cmdclass={'install_data': InstallData,
 
153
              'check': Check}
 
154
)