/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
83 by Jelmer Vernooij
Merge Olive code.
2
"""GTK+ Frontends for various Bazaar commands."""
0.8.10 by Szilveszter Farkas (Phanatic)
2006-07-16 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
3
696 by Jelmer Vernooij
Start on 0.100.0.
4
from info import *
5
288 by Jelmer Vernooij
Add check command to setup.py.
6
from distutils.core import setup, Command
0.9.1 by Stéphane Raimbault
Work on translation.
7
from distutils.command.install_data import install_data
608 by Jelmer Vernooij
Merge create-credits into setup.py.
8
from distutils.command.build import build
715.1.2 by Jelmer Vernooij
Generate pickles file for './setup.py sdist'
9
from distutils.command.sdist import sdist
696.1.4 by David Planella
Added preliminary internationalization support. Merged from trunk.
10
try:
11
    from DistUtilsExtra.command import *
12
except ImportError:
13
   # Python distutils extra is not available.
14
    class cmd_build_i18n(Command):
15
        def run(self):
16
            print >> sys.stderr, "For internationalization support you'll need to install https://launchpad.net/python-distutils-extra"
17
else:
18
    # Use build_i18n from DistUtilsExtra
19
    cmd_build_i18n = build_i18n.build_i18n
20
0.9.1 by Stéphane Raimbault
Work on translation.
21
import os
0.8.74 by Szilveszter Farkas (Phanatic)
Fix the Win32 build/install issue.
22
import sys
0.9.1 by Stéphane Raimbault
Work on translation.
23
288 by Jelmer Vernooij
Add check command to setup.py.
24
class Check(Command):
25
    description = "Run unit tests"
26
27
    user_options = []
28
29
    def initialize_options(self):
30
        pass
31
32
    def finalize_options(self):
33
        pass
34
35
    def get_command_name(self):
36
        return 'test'
37
38
    def run(self):
39
        from bzrlib.tests import TestLoader, TestSuite, TextTestRunner
715.1.1 by Jelmer Vernooij
Fix setup.py check.
40
        from bzrlib.plugin import PluginImporter
41
        PluginImporter.specific_paths["bzrlib.plugins.gtk"] = os.path.dirname(__file__)
42
        from bzrlib.plugins.gtk.tests import load_tests
43
        suite = TestSuite()
44
        loader = TestLoader()
45
        load_tests(suite, None, loader)
288 by Jelmer Vernooij
Add check command to setup.py.
46
        runner = TextTestRunner()
47
        result = runner.run(suite)
48
        return result.wasSuccessful()
49
608 by Jelmer Vernooij
Merge create-credits into setup.py.
50
51
class CreateCredits(Command):
52
    description = "Create credits file"
53
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
54
    user_options = [("url=", None, "URL of branch")]
608 by Jelmer Vernooij
Merge create-credits into setup.py.
55
56
    def initialize_options(self):
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
57
        self.url = "."
608 by Jelmer Vernooij
Merge create-credits into setup.py.
58
59
    def finalize_options(self):
60
        pass
61
62
    def get_command_name(self):
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
63
        return 'build_credits'
608 by Jelmer Vernooij
Merge create-credits into setup.py.
64
65
    def run(self):
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
66
        from bzrlib.plugin import load_plugins; load_plugins()
608 by Jelmer Vernooij
Merge create-credits into setup.py.
67
        from bzrlib.branch import Branch
692 by Jelmer Vernooij
Cope with find_credits moving.
68
        from bzrlib.plugins.stats.cmds import find_credits
608 by Jelmer Vernooij
Merge create-credits into setup.py.
69
70
        import pickle
71
622 by Jelmer Vernooij
Allow --url option to ./setup.py build_credits
72
        branch = Branch.open(self.url)
608 by Jelmer Vernooij
Merge create-credits into setup.py.
73
        credits = find_credits(branch.repository, branch.last_revision())
74
75
        pickle.dump(credits, file("credits.pickle", 'w'))
76
        return True
77
78
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
79
def is_versioned(cmd):
611 by Jelmer Vernooij
Fix import.
80
    from bzrlib.errors import NotBranchError
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
81
    try:
82
        from bzrlib.branch import Branch
83
        Branch.open(".")
84
        return True
85
    except NotBranchError:
86
        return False
87
88
608 by Jelmer Vernooij
Merge create-credits into setup.py.
89
class BuildData(build):
609 by Jelmer Vernooij
Run build_credits subcommand as part of ./setup.py build.
90
    sub_commands = build.sub_commands[:]
91
    sub_commands.append(('build_credits', is_versioned))
608 by Jelmer Vernooij
Merge create-credits into setup.py.
92
93
715.1.2 by Jelmer Vernooij
Generate pickles file for './setup.py sdist'
94
class SourceDist(sdist):
95
    sub_commands = sdist.sub_commands[:]
96
    sub_commands.append(('build_credits', is_versioned))
97
98
0.9.1 by Stéphane Raimbault
Work on translation.
99
class InstallData(install_data):
676 by Jelmer Vernooij
Fix missing import.
100
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
101
    def run(self):
676 by Jelmer Vernooij
Fix missing import.
102
        import subprocess
463 by Martin Albisetti
Enable default nautilus integration
103
        self.data_files.extend(self._nautilus_plugin())
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
104
        install_data.run(self)
441 by Martin Albisetti
Added checking that the install enviroment is Linux before updating the icon cache
105
442 by Martin Albisetti
Check if command exists first before updating the cache to support all platforms
106
        try:
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
107
            subprocess.check_call('gtk-update-icon-cache '
108
                                  '-f -t /usr/share/icons/hicolor')
676 by Jelmer Vernooij
Fix missing import.
109
        except OSError:
442 by Martin Albisetti
Check if command exists first before updating the cache to support all platforms
110
            pass
440 by Martin Albisetti
Install new bzr icons (emblems) and update the icon cache
111
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
112
    def _nautilus_plugin(self):
113
        files = []
114
        if sys.platform[:5] == 'linux':
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
115
            cmd = os.popen('pkg-config --variable=pythondir nautilus-python',
116
                           'r')
560.7.1 by Daniel Schömer
Strip newline from nautilus-python pythondir read from pkg-config.
117
            res = cmd.readline().strip()
126.1.30 by Szilveszter Farkas (Phanatic)
Added the ability to install the Nautilus plugin (Fixed: #75603)
118
            ret = cmd.close()
119
            if ret is None:
120
                dest = res[5:]
121
                files.append((dest, ['nautilus-bzr.py']))
122
        return files
83 by Jelmer Vernooij
Merge Olive code.
123
124
682.1.1 by Robert Collins
Guard setup.py
125
if __name__ == '__main__':
696 by Jelmer Vernooij
Start on 0.100.0.
126
    version = bzr_plugin_version[:3]
127
    version_string = ".".join([str(x) for x in version])
682.1.1 by Robert Collins
Guard setup.py
128
    setup(
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
129
        name = "bzr-gtk",
696 by Jelmer Vernooij
Start on 0.100.0.
130
        version = version_string,
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
131
        maintainer = "Jelmer Vernooij",
132
        maintainer_email = "jelmer@samba.org",
133
        description = "GTK+ Frontends for various Bazaar commands",
134
        license = "GNU GPL v2 or later",
688.2.1 by Jelmer Vernooij
Split out olive into a separate directory.
135
        scripts = ['bzr-handle-patch', 'bzr-notify'],
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
136
        url = "http://bazaar-vcs.org/BzrGtk",
137
        package_dir = {
138
            "bzrlib.plugins.gtk": ".",
139
            "bzrlib.plugins.gtk.viz": "viz",
140
            "bzrlib.plugins.gtk.annotate": "annotate",
141
            "bzrlib.plugins.gtk.tests": "tests",
142
            "bzrlib.plugins.gtk.branchview": "branchview",
143
            "bzrlib.plugins.gtk.preferences": "preferences",
144
            },
145
        packages = [
146
            "bzrlib.plugins.gtk",
147
            "bzrlib.plugins.gtk.viz",
148
            "bzrlib.plugins.gtk.annotate",
149
            "bzrlib.plugins.gtk.tests",
150
            "bzrlib.plugins.gtk.branchview",
151
            "bzrlib.plugins.gtk.preferences",
83 by Jelmer Vernooij
Merge Olive code.
152
        ],
688.2.1 by Jelmer Vernooij
Split out olive into a separate directory.
153
        data_files=[ ('share/bzr-gtk', ['credits.pickle']),
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
154
                    ('share/bzr-gtk/icons', ['icons/commit.png',
155
                                             'icons/commit16.png',
156
                                             'icons/diff.png',
157
                                             'icons/diff16.png',
158
                                             'icons/log.png',
159
                                             'icons/log16.png',
160
                                             'icons/pull.png',
161
                                             'icons/pull16.png',
162
                                             'icons/push.png',
163
                                             'icons/push16.png',
164
                                             'icons/refresh.png',
165
                                             'icons/sign-bad.png',
166
                                             'icons/sign-ok.png',
167
                                             'icons/sign.png',
168
                                             'icons/sign-unknown.png',
169
                                             'icons/tag-16.png',
170
                                             'icons/bug.png',
171
                                             'icons/bzr-icon-64.png']),
696.1.4 by David Planella
Added preliminary internationalization support. Merged from trunk.
172
                    # In case Python distutils extra is not available,
173
                    # install the .desktop files
688.2.1 by Jelmer Vernooij
Split out olive into a separate directory.
174
                    ('share/applications', ['bazaar-properties.desktop',
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
175
                                            'bzr-handle-patch.desktop',
176
                                            'bzr-notify.desktop']),
734.1.1 by Curtis Hovey
Mechanical changes made by pygi.convert.sh.
177
                    ('share/application-registry', ['bzr-Gtk.applications']),
699.2.5 by Andrew Starr-Bochicchio
Install bzr-panel to share/icons/hicolor/scalable/apps
178
                    ('share/pixmaps', ['icons/bzr-icon-64.png']),
179
                    ('share/icons/hicolor/scalable/apps', ['icons/bzr-panel.svg']),
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
180
                    ('share/icons/hicolor/scalable/emblems',
181
                     ['icons/emblem-bzr-added.svg',
182
                      'icons/emblem-bzr-conflict.svg',
183
                      'icons/emblem-bzr-controlled.svg',
184
                      'icons/emblem-bzr-modified.svg',
185
                      'icons/emblem-bzr-removed.svg',
186
                      'icons/emblem-bzr-ignored.svg'])
187
                    ],
188
        cmdclass={'install_data': InstallData,
189
                  'build_credits': CreateCredits,
190
                  'build': BuildData,
696.1.4 by David Planella
Added preliminary internationalization support. Merged from trunk.
191
                  'build_i18n': cmd_build_i18n,
715.1.2 by Jelmer Vernooij
Generate pickles file for './setup.py sdist'
192
                  'sdist': SourceDist,
682.1.2 by Vincent Ladeuil
Split lines too long and get rid of spurious spaces.
193
                  'check': Check}
194
        )