/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
126.1.31 by Szilveszter Farkas (Phanatic)
We also support other versions than 2.4.
1
#!/usr/bin/python
608 by Jelmer Vernooij
Merge create-credits into setup.py.
2
83 by Jelmer Vernooij
Merge Olive code.
3
"""GTK+ Frontends for various Bazaar commands."""
0.8.10 by Szilveszter Farkas (Phanatic)
2006-07-16 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
4
288 by Jelmer Vernooij
Add check command to setup.py.
5
from distutils.core import setup, Command
0.9.1 by Stéphane Raimbault
Work on translation.
6
from distutils.command.install_data import install_data
608 by Jelmer Vernooij
Merge create-credits into setup.py.
7
from distutils.command.build import build
0.9.1 by Stéphane Raimbault
Work on translation.
8
from distutils.dep_util import newer
9
from distutils.log import info
0.8.74 by Szilveszter Farkas (Phanatic)
Fix the Win32 build/install issue.
10
import glob
0.9.1 by Stéphane Raimbault
Work on translation.
11
import os
0.8.74 by Szilveszter Farkas (Phanatic)
Fix the Win32 build/install issue.
12
import sys
0.9.1 by Stéphane Raimbault
Work on translation.
13
288 by Jelmer Vernooij
Add check command to setup.py.
14
class Check(Command):
15
    description = "Run unit tests"
16
17
    user_options = []
18
19
    def initialize_options(self):
20
        pass
21
22
    def finalize_options(self):
23
        pass
24
25
    def get_command_name(self):
26
        return 'test'
27
28
    def run(self):
29
        from bzrlib.tests import TestLoader, TestSuite, TextTestRunner
30
        import __init__ as bzrgtk
31
        runner = TextTestRunner()
32
        loader = TestLoader()
33
        suite = TestSuite()
34
        suite.addTest(bzrgtk.test_suite())
35
        result = runner.run(suite)
36
        return result.wasSuccessful()
37
608 by Jelmer Vernooij
Merge create-credits into setup.py.
38
39
class CreateCredits(Command):
40
    description = "Create credits file"
41
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
42
    user_options = [("url=", None, "URL of branch")]
608 by Jelmer Vernooij
Merge create-credits into setup.py.
43
44
    def initialize_options(self):
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
45
        self.url = "."
608 by Jelmer Vernooij
Merge create-credits into setup.py.
46
47
    def finalize_options(self):
48
        pass
49
50
    def get_command_name(self):
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
51
        return 'build_credits'
608 by Jelmer Vernooij
Merge create-credits into setup.py.
52
53
    def run(self):
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
54
        from bzrlib.plugin import load_plugins; load_plugins()
608 by Jelmer Vernooij
Merge create-credits into setup.py.
55
        from bzrlib.branch import Branch
56
        from bzrlib.plugins.stats import find_credits
57
58
        import pickle
59
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
60
        branch = Branch.open(self.url)
608 by Jelmer Vernooij
Merge create-credits into setup.py.
61
        credits = find_credits(branch.repository, branch.last_revision())
62
63
        pickle.dump(credits, file("credits.pickle", 'w'))
64
        return True
65
66
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
67
def is_versioned(cmd):
611 by Jelmer Vernooij
Fix import.
68
    from bzrlib.errors import NotBranchError
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
69
    try:
70
        from bzrlib.branch import Branch
71
        Branch.open(".")
72
        return True
73
    except NotBranchError:
74
        return False
75
76
608 by Jelmer Vernooij
Merge create-credits into setup.py.
77
class BuildData(build):
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
78
    sub_commands = build.sub_commands[:]
79
    sub_commands.append(('build_credits', is_versioned))
608 by Jelmer Vernooij
Merge create-credits into setup.py.
80
81
0.9.1 by Stéphane Raimbault
Work on translation.
82
class InstallData(install_data):
676 by Jelmer Vernooij
Fix missing import.
83
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
84
    def run(self):
676 by Jelmer Vernooij
Fix missing import.
85
        import subprocess
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
86
        self.data_files.extend(self._compile_po_files())
463 by Martin Albisetti
Enable default nautilus integration
87
        self.data_files.extend(self._nautilus_plugin())
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
88
        install_data.run(self)
441 by Martin Albisetti
Added checking that the install enviroment is Linux before updating the icon cache
89
442 by Martin Albisetti
Check if command exists first before updating the cache to support all platforms
90
        try:
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
91
            subprocess.check_call('gtk-update-icon-cache '
92
                                  '-f -t /usr/share/icons/hicolor')
676 by Jelmer Vernooij
Fix missing import.
93
        except OSError:
442 by Martin Albisetti
Check if command exists first before updating the cache to support all platforms
94
            pass
440 by Martin Albisetti
Install new bzr icons (emblems) and update the icon cache
95
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
96
    def _compile_po_files(self):
97
        data_files = []
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
98
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
99
        # Don't install language files on Win32
100
        if sys.platform == 'win32':
101
            return data_files
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
102
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
103
        PO_DIR = 'po'
104
        for po in glob.glob(os.path.join(PO_DIR,'*.po')):
105
            lang = os.path.basename(po[:-3])
106
            # It's necessary to compile in this directory (not in po_dir)
107
            # because install_data can't rename file
108
            mo = os.path.join('build', 'mo', lang, 'olive-gtk.mo')
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
109
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
110
            directory = os.path.dirname(mo)
111
            if not os.path.exists(directory):
112
                info('creating %s' % directory)
113
                os.makedirs(directory)
114
            if newer(po, mo):
115
                # True if mo doesn't exist
116
                cmd = 'msgfmt -o %s %s' % (mo, po)
117
                info('compiling %s -> %s' % (po, mo))
118
                if os.system(cmd) != 0:
119
                    raise SystemExit('Error while running msgfmt')
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
120
                dest = os.path.dirname(
121
                    os.path.join('share', 'locale', lang,
122
                                 'LC_MESSAGES', 'olive-gtk.mo'))
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
123
                data_files.append((dest, [mo]))
124
        return data_files
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
125
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
126
    def _nautilus_plugin(self):
127
        files = []
128
        if sys.platform[:5] == 'linux':
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
129
            cmd = os.popen('pkg-config --variable=pythondir nautilus-python',
130
                           'r')
560.7.1 by Daniel Schömer
Strip newline from nautilus-python pythondir read from pkg-config.
131
            res = cmd.readline().strip()
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
132
            ret = cmd.close()
133
            if ret is None:
134
                dest = res[5:]
135
                files.append((dest, ['nautilus-bzr.py']))
136
        return files
83 by Jelmer Vernooij
Merge Olive code.
137
138
682.1.1 by Robert Collins
Guard setup.py
139
if __name__ == '__main__':
140
    setup(
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
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",
83 by Jelmer Vernooij
Merge Olive code.
166
        ],
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
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
        )