/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: Jelmer Vernooij
  • Date: 2006-05-19 16:37:13 UTC
  • Revision ID: jelmer@samba.org-20060519163713-be77b31c72cbc7e8
Move visualisation code to a separate directory, preparing for bundling 
the GTK+ plugins for bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
 
3
 
"""GTK+ Frontends for various Bazaar commands."""
4
 
 
5
 
from distutils.core import setup, Command
6
 
from distutils.command.install_data import install_data
7
 
from distutils.command.build import build
8
 
import os
9
 
import sys
10
 
 
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
 
 
35
 
 
36
 
class CreateCredits(Command):
37
 
    description = "Create credits file"
38
 
 
39
 
    user_options = [("url=", None, "URL of branch")]
40
 
 
41
 
    def initialize_options(self):
42
 
        self.url = "."
43
 
 
44
 
    def finalize_options(self):
45
 
        pass
46
 
 
47
 
    def get_command_name(self):
48
 
        return 'build_credits'
49
 
 
50
 
    def run(self):
51
 
        from bzrlib.plugin import load_plugins; load_plugins()
52
 
        from bzrlib.branch import Branch
53
 
        from bzrlib.plugins.stats import find_credits
54
 
 
55
 
        import pickle
56
 
 
57
 
        branch = Branch.open(self.url)
58
 
        credits = find_credits(branch.repository, branch.last_revision())
59
 
 
60
 
        pickle.dump(credits, file("credits.pickle", 'w'))
61
 
        return True
62
 
 
63
 
 
64
 
def is_versioned(cmd):
65
 
    from bzrlib.errors import NotBranchError
66
 
    try:
67
 
        from bzrlib.branch import Branch
68
 
        Branch.open(".")
69
 
        return True
70
 
    except NotBranchError:
71
 
        return False
72
 
 
73
 
 
74
 
class BuildData(build):
75
 
    sub_commands = build.sub_commands[:]
76
 
    sub_commands.append(('build_credits', is_versioned))
77
 
 
78
 
 
79
 
class InstallData(install_data):
80
 
 
81
 
    def run(self):
82
 
        import subprocess
83
 
        self.data_files.extend(self._nautilus_plugin())
84
 
        install_data.run(self)
85
 
 
86
 
        try:
87
 
            subprocess.check_call('gtk-update-icon-cache '
88
 
                                  '-f -t /usr/share/icons/hicolor')
89
 
        except OSError:
90
 
            pass
91
 
 
92
 
    def _nautilus_plugin(self):
93
 
        files = []
94
 
        if sys.platform[:5] == 'linux':
95
 
            cmd = os.popen('pkg-config --variable=pythondir nautilus-python',
96
 
                           'r')
97
 
            res = cmd.readline().strip()
98
 
            ret = cmd.close()
99
 
            if ret is None:
100
 
                dest = res[5:]
101
 
                files.append((dest, ['nautilus-bzr.py']))
102
 
        return files
103
 
 
104
 
 
105
 
if __name__ == '__main__':
106
 
    setup(
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",
113
 
        scripts = ['bzr-handle-patch', 'bzr-notify'],
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",
130
 
        ],
131
 
        data_files=[ ('share/bzr-gtk', ['credits.pickle']),
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']),
150
 
                    ('share/applications', ['bazaar-properties.desktop',
151
 
                                            'bzr-handle-patch.desktop',
152
 
                                            'bzr-notify.desktop']),
153
 
                    ('share/application-registry', ['bzr-gtk.applications']),
154
 
                    ('share/pixmaps', ['icons/bzr-icon-64.png']),
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
 
        )