/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: David Planella
  • Date: 2010-08-21 09:32:13 UTC
  • mto: This revision was merged to the branch mainline in revision 719.
  • Revision ID: david.planella@ubuntu.com-20100821093213-njpqd5sploa8n71m
Adapted desktop entries for translation

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
"""GTK+ Frontends for various Bazaar commands."""
 
3
 
 
4
from info import *
 
5
 
 
6
from distutils.core import setup, Command
 
7
from distutils.command.install_data import install_data
 
8
from distutils.command.build import build
 
9
import os
 
10
import sys
 
11
 
 
12
class Check(Command):
 
13
    description = "Run unit tests"
 
14
 
 
15
    user_options = []
 
16
 
 
17
    def initialize_options(self):
 
18
        pass
 
19
 
 
20
    def finalize_options(self):
 
21
        pass
 
22
 
 
23
    def get_command_name(self):
 
24
        return 'test'
 
25
 
 
26
    def run(self):
 
27
        from bzrlib.tests import TestLoader, TestSuite, TextTestRunner
 
28
        import __init__ as bzrgtk
 
29
        runner = TextTestRunner()
 
30
        loader = TestLoader()
 
31
        suite = TestSuite()
 
32
        suite.addTest(bzrgtk.test_suite())
 
33
        result = runner.run(suite)
 
34
        return result.wasSuccessful()
 
35
 
 
36
 
 
37
class CreateCredits(Command):
 
38
    description = "Create credits file"
 
39
 
 
40
    user_options = [("url=", None, "URL of branch")]
 
41
 
 
42
    def initialize_options(self):
 
43
        self.url = "."
 
44
 
 
45
    def finalize_options(self):
 
46
        pass
 
47
 
 
48
    def get_command_name(self):
 
49
        return 'build_credits'
 
50
 
 
51
    def run(self):
 
52
        from bzrlib.plugin import load_plugins; load_plugins()
 
53
        from bzrlib.branch import Branch
 
54
        from bzrlib.plugins.stats.cmds import find_credits
 
55
 
 
56
        import pickle
 
57
 
 
58
        branch = Branch.open(self.url)
 
59
        credits = find_credits(branch.repository, branch.last_revision())
 
60
 
 
61
        pickle.dump(credits, file("credits.pickle", 'w'))
 
62
        return True
 
63
 
 
64
 
 
65
def is_versioned(cmd):
 
66
    from bzrlib.errors import NotBranchError
 
67
    try:
 
68
        from bzrlib.branch import Branch
 
69
        Branch.open(".")
 
70
        return True
 
71
    except NotBranchError:
 
72
        return False
 
73
 
 
74
 
 
75
class BuildData(build):
 
76
    sub_commands = build.sub_commands[:]
 
77
    sub_commands.append(('build_credits', is_versioned))
 
78
 
 
79
 
 
80
class InstallData(install_data):
 
81
 
 
82
    def run(self):
 
83
        import subprocess
 
84
        self.data_files.extend(self._nautilus_plugin())
 
85
        install_data.run(self)
 
86
 
 
87
        try:
 
88
            subprocess.check_call('gtk-update-icon-cache '
 
89
                                  '-f -t /usr/share/icons/hicolor')
 
90
        except OSError:
 
91
            pass
 
92
 
 
93
    def _nautilus_plugin(self):
 
94
        files = []
 
95
        if sys.platform[:5] == 'linux':
 
96
            cmd = os.popen('pkg-config --variable=pythondir nautilus-python',
 
97
                           'r')
 
98
            res = cmd.readline().strip()
 
99
            ret = cmd.close()
 
100
            if ret is None:
 
101
                dest = res[5:]
 
102
                files.append((dest, ['nautilus-bzr.py']))
 
103
        return files
 
104
 
 
105
 
 
106
if __name__ == '__main__':
 
107
    version = bzr_plugin_version[:3]
 
108
    version_string = ".".join([str(x) for x in version])
 
109
    setup(
 
110
        name = "bzr-gtk",
 
111
        version = version_string,
 
112
        maintainer = "Jelmer Vernooij",
 
113
        maintainer_email = "jelmer@samba.org",
 
114
        description = "GTK+ Frontends for various Bazaar commands",
 
115
        license = "GNU GPL v2 or later",
 
116
        scripts = ['bzr-handle-patch', 'bzr-notify'],
 
117
        url = "http://bazaar-vcs.org/BzrGtk",
 
118
        package_dir = {
 
119
            "bzrlib.plugins.gtk": ".",
 
120
            "bzrlib.plugins.gtk.viz": "viz",
 
121
            "bzrlib.plugins.gtk.annotate": "annotate",
 
122
            "bzrlib.plugins.gtk.tests": "tests",
 
123
            "bzrlib.plugins.gtk.branchview": "branchview",
 
124
            "bzrlib.plugins.gtk.preferences": "preferences",
 
125
            },
 
126
        packages = [
 
127
            "bzrlib.plugins.gtk",
 
128
            "bzrlib.plugins.gtk.viz",
 
129
            "bzrlib.plugins.gtk.annotate",
 
130
            "bzrlib.plugins.gtk.tests",
 
131
            "bzrlib.plugins.gtk.branchview",
 
132
            "bzrlib.plugins.gtk.preferences",
 
133
        ],
 
134
        data_files=[ ('share/bzr-gtk', ['credits.pickle']),
 
135
                    ('share/bzr-gtk/icons', ['icons/commit.png',
 
136
                                             'icons/commit16.png',
 
137
                                             'icons/diff.png',
 
138
                                             'icons/diff16.png',
 
139
                                             'icons/log.png',
 
140
                                             'icons/log16.png',
 
141
                                             'icons/pull.png',
 
142
                                             'icons/pull16.png',
 
143
                                             'icons/push.png',
 
144
                                             'icons/push16.png',
 
145
                                             'icons/refresh.png',
 
146
                                             'icons/sign-bad.png',
 
147
                                             'icons/sign-ok.png',
 
148
                                             'icons/sign.png',
 
149
                                             'icons/sign-unknown.png',
 
150
                                             'icons/tag-16.png',
 
151
                                             'icons/bug.png',
 
152
                                             'icons/bzr-icon-64.png']),
 
153
                    ('share/applications', ['bazaar-properties.desktop',
 
154
                                            'bzr-handle-patch.desktop',
 
155
                                            'bzr-notify.desktop']),
 
156
                    ('share/application-registry', ['bzr-gtk.applications']),
 
157
                    ('share/pixmaps', ['icons/bzr-icon-64.png']),
 
158
                    ('share/icons/hicolor/scalable/emblems',
 
159
                     ['icons/emblem-bzr-added.svg',
 
160
                      'icons/emblem-bzr-conflict.svg',
 
161
                      'icons/emblem-bzr-controlled.svg',
 
162
                      'icons/emblem-bzr-modified.svg',
 
163
                      'icons/emblem-bzr-removed.svg',
 
164
                      'icons/emblem-bzr-ignored.svg'])
 
165
                    ],
 
166
        cmdclass={'install_data': InstallData,
 
167
                  'build_credits': CreateCredits,
 
168
                  'build': BuildData,
 
169
                  'check': Check}
 
170
        )