/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
import os
0.8.74 by Szilveszter Farkas (Phanatic)
Fix the Win32 build/install issue.
9
import sys
0.9.1 by Stéphane Raimbault
Work on translation.
10
288 by Jelmer Vernooij
Add check command to setup.py.
11
class Check(Command):
12
    description = "Run unit tests"
13
14
    user_options = []
15
16
    def initialize_options(self):
17
        pass
18
19
    def finalize_options(self):
20
        pass
21
22
    def get_command_name(self):
23
        return 'test'
24
25
    def run(self):
26
        from bzrlib.tests import TestLoader, TestSuite, TextTestRunner
27
        import __init__ as bzrgtk
28
        runner = TextTestRunner()
29
        loader = TestLoader()
30
        suite = TestSuite()
31
        suite.addTest(bzrgtk.test_suite())
32
        result = runner.run(suite)
33
        return result.wasSuccessful()
34
608 by Jelmer Vernooij
Merge create-credits into setup.py.
35
36
class CreateCredits(Command):
37
    description = "Create credits file"
38
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
39
    user_options = [("url=", None, "URL of branch")]
608 by Jelmer Vernooij
Merge create-credits into setup.py.
40
41
    def initialize_options(self):
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
42
        self.url = "."
608 by Jelmer Vernooij
Merge create-credits into setup.py.
43
44
    def finalize_options(self):
45
        pass
46
47
    def get_command_name(self):
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
48
        return 'build_credits'
608 by Jelmer Vernooij
Merge create-credits into setup.py.
49
50
    def run(self):
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
51
        from bzrlib.plugin import load_plugins; load_plugins()
608 by Jelmer Vernooij
Merge create-credits into setup.py.
52
        from bzrlib.branch import Branch
53
        from bzrlib.plugins.stats import find_credits
54
55
        import pickle
56
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
57
        branch = Branch.open(self.url)
608 by Jelmer Vernooij
Merge create-credits into setup.py.
58
        credits = find_credits(branch.repository, branch.last_revision())
59
60
        pickle.dump(credits, file("credits.pickle", 'w'))
61
        return True
62
63
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
64
def is_versioned(cmd):
611 by Jelmer Vernooij
Fix import.
65
    from bzrlib.errors import NotBranchError
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
66
    try:
67
        from bzrlib.branch import Branch
68
        Branch.open(".")
69
        return True
70
    except NotBranchError:
71
        return False
72
73
608 by Jelmer Vernooij
Merge create-credits into setup.py.
74
class BuildData(build):
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
75
    sub_commands = build.sub_commands[:]
76
    sub_commands.append(('build_credits', is_versioned))
608 by Jelmer Vernooij
Merge create-credits into setup.py.
77
78
0.9.1 by Stéphane Raimbault
Work on translation.
79
class InstallData(install_data):
676 by Jelmer Vernooij
Fix missing import.
80
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
81
    def run(self):
676 by Jelmer Vernooij
Fix missing import.
82
        import subprocess
463 by Martin Albisetti
Enable default nautilus integration
83
        self.data_files.extend(self._nautilus_plugin())
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
84
        install_data.run(self)
441 by Martin Albisetti
Added checking that the install enviroment is Linux before updating the icon cache
85
442 by Martin Albisetti
Check if command exists first before updating the cache to support all platforms
86
        try:
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
87
            subprocess.check_call('gtk-update-icon-cache '
88
                                  '-f -t /usr/share/icons/hicolor')
676 by Jelmer Vernooij
Fix missing import.
89
        except OSError:
442 by Martin Albisetti
Check if command exists first before updating the cache to support all platforms
90
            pass
440 by Martin Albisetti
Install new bzr icons (emblems) and update the icon cache
91
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
92
    def _nautilus_plugin(self):
93
        files = []
94
        if sys.platform[:5] == 'linux':
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
95
            cmd = os.popen('pkg-config --variable=pythondir nautilus-python',
96
                           'r')
560.7.1 by Daniel Schömer
Strip newline from nautilus-python pythondir read from pkg-config.
97
            res = cmd.readline().strip()
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
98
            ret = cmd.close()
99
            if ret is None:
100
                dest = res[5:]
101
                files.append((dest, ['nautilus-bzr.py']))
102
        return files
83 by Jelmer Vernooij
Merge Olive code.
103
104
682.1.1 by Robert Collins
Guard setup.py
105
if __name__ == '__main__':
106
    setup(
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
107
        name = "bzr-gtk",
108
        version = "0.99.0",
109
        maintainer = "Jelmer Vernooij",
110
        maintainer_email = "jelmer@samba.org",
111
        description = "GTK+ Frontends for various Bazaar commands",
112
        license = "GNU GPL v2 or later",
688.2.1 by Jelmer Vernooij
Split out olive into a separate directory.
113
        scripts = ['bzr-handle-patch', 'bzr-notify'],
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
114
        url = "http://bazaar-vcs.org/BzrGtk",
115
        package_dir = {
116
            "bzrlib.plugins.gtk": ".",
117
            "bzrlib.plugins.gtk.viz": "viz",
118
            "bzrlib.plugins.gtk.annotate": "annotate",
119
            "bzrlib.plugins.gtk.tests": "tests",
120
            "bzrlib.plugins.gtk.branchview": "branchview",
121
            "bzrlib.plugins.gtk.preferences": "preferences",
122
            },
123
        packages = [
124
            "bzrlib.plugins.gtk",
125
            "bzrlib.plugins.gtk.viz",
126
            "bzrlib.plugins.gtk.annotate",
127
            "bzrlib.plugins.gtk.tests",
128
            "bzrlib.plugins.gtk.branchview",
129
            "bzrlib.plugins.gtk.preferences",
83 by Jelmer Vernooij
Merge Olive code.
130
        ],
688.2.1 by Jelmer Vernooij
Split out olive into a separate directory.
131
        data_files=[ ('share/bzr-gtk', ['credits.pickle']),
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
132
                    ('share/bzr-gtk/icons', ['icons/commit.png',
133
                                             'icons/commit16.png',
134
                                             'icons/diff.png',
135
                                             'icons/diff16.png',
136
                                             'icons/log.png',
137
                                             'icons/log16.png',
138
                                             'icons/pull.png',
139
                                             'icons/pull16.png',
140
                                             'icons/push.png',
141
                                             'icons/push16.png',
142
                                             'icons/refresh.png',
143
                                             'icons/sign-bad.png',
144
                                             'icons/sign-ok.png',
145
                                             'icons/sign.png',
146
                                             'icons/sign-unknown.png',
147
                                             'icons/tag-16.png',
148
                                             'icons/bug.png',
149
                                             'icons/bzr-icon-64.png']),
688.2.1 by Jelmer Vernooij
Split out olive into a separate directory.
150
                    ('share/applications', ['bazaar-properties.desktop',
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
151
                                            'bzr-handle-patch.desktop',
152
                                            'bzr-notify.desktop']),
153
                    ('share/application-registry', ['bzr-gtk.applications']),
688.2.1 by Jelmer Vernooij
Split out olive into a separate directory.
154
                    ('share/pixmaps', ['icons/bzr-icon-64.png']),
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
155
                    ('share/icons/hicolor/scalable/emblems',
156
                     ['icons/emblem-bzr-added.svg',
157
                      'icons/emblem-bzr-conflict.svg',
158
                      'icons/emblem-bzr-controlled.svg',
159
                      'icons/emblem-bzr-modified.svg',
160
                      'icons/emblem-bzr-removed.svg',
161
                      'icons/emblem-bzr-ignored.svg'])
162
                    ],
163
        cmdclass={'install_data': InstallData,
164
                  'build_credits': CreateCredits,
165
                  'build': BuildData,
166
                  'check': Check}
167
        )