/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: Curtis Hovey
  • Date: 2012-03-11 18:24:06 UTC
  • mto: This revision was merged to the branch mainline in revision 785.
  • Revision ID: sinzui.is@verizon.net-20120311182406-f4jqpff65b30g3al
Create the mnemonic for the button label.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python2.4
 
1
#!/usr/bin/python
2
2
"""GTK+ Frontends for various Bazaar commands."""
3
3
 
4
 
from distutils.core import setup
5
 
from distutils.command.install_data import install_data
6
 
from distutils.dep_util import newer
7
 
from distutils.log import info
8
 
import glob
9
4
import os
10
5
import sys
11
6
 
 
7
from info import bzr_plugin_version
 
8
 
 
9
from distutils.core import setup, Command
 
10
from distutils.command.install_data import install_data
 
11
from distutils.command.build import build
 
12
from distutils.command.sdist import sdist
 
13
try:
 
14
    from DistUtilsExtra.command import build_i18n
 
15
except ImportError:
 
16
    # Python distutils extra is not available.
 
17
    class cmd_build_i18n(build):
 
18
        user_options = []
 
19
 
 
20
        def initialize_options(self):
 
21
            self.domain = None
 
22
            self.desktop_files = None
 
23
 
 
24
        def finalize_options(self):
 
25
            pass
 
26
 
 
27
        def run(self):
 
28
            print >> sys.stderr, (
 
29
                "For internationalization support you'll need to install "
 
30
                "https://launchpad.net/python-distutils-extra")
 
31
else:
 
32
    # Use build_i18n from DistUtilsExtra
 
33
    cmd_build_i18n = build_i18n.build_i18n
 
34
 
 
35
 
 
36
class Check(Command):
 
37
    description = "Run unit tests"
 
38
 
 
39
    user_options = [
 
40
        ('module=', 'm', 'The test module to run'),
 
41
        ]
 
42
 
 
43
    def initialize_options(self):
 
44
        self.module = None
 
45
 
 
46
    def finalize_options(self):
 
47
        pass
 
48
 
 
49
    def get_command_name(self):
 
50
        return 'test'
 
51
 
 
52
    def run(self):
 
53
        from bzrlib.tests import TestLoader, TestSuite, TextTestRunner
 
54
        from bzrlib.plugin import PluginImporter
 
55
        PluginImporter.specific_paths["bzrlib.plugins.gtk"] = os.path.dirname(
 
56
            __file__)
 
57
        from bzrlib.plugins.gtk.tests import load_tests
 
58
        suite = TestSuite()
 
59
        loader = TestLoader()
 
60
        load_tests(suite, self.module, loader)
 
61
        runner = TextTestRunner()
 
62
        result = runner.run(suite)
 
63
        return result.wasSuccessful()
 
64
 
 
65
 
 
66
class CreateCredits(Command):
 
67
    description = "Create credits file"
 
68
 
 
69
    user_options = [("url=", None, "URL of branch")]
 
70
 
 
71
    def initialize_options(self):
 
72
        self.url = "."
 
73
 
 
74
    def finalize_options(self):
 
75
        pass
 
76
 
 
77
    def get_command_name(self):
 
78
        return 'build_credits'
 
79
 
 
80
    def run(self):
 
81
        from bzrlib.plugin import load_plugins
 
82
        load_plugins()
 
83
        from bzrlib.branch import Branch
 
84
        from bzrlib.plugins.stats.cmds import find_credits
 
85
 
 
86
        import pickle
 
87
 
 
88
        branch = Branch.open(self.url)
 
89
        credits = find_credits(branch.repository, branch.last_revision())
 
90
 
 
91
        pickle.dump(credits, file("credits.pickle", 'w'))
 
92
        return True
 
93
 
 
94
 
 
95
def is_versioned(cmd):
 
96
    from bzrlib.errors import NotBranchError
 
97
    try:
 
98
        from bzrlib.branch import Branch
 
99
        Branch.open(".")
 
100
        return True
 
101
    except NotBranchError:
 
102
        return False
 
103
 
 
104
 
 
105
class BuildData(build):
 
106
    sub_commands = build.sub_commands[:]
 
107
    sub_commands.append(('build_credits', is_versioned))
 
108
 
 
109
 
 
110
class SourceDist(sdist):
 
111
    sub_commands = sdist.sub_commands[:]
 
112
    sub_commands.append(('build_credits', is_versioned))
 
113
 
 
114
 
12
115
class InstallData(install_data):
13
 
        def run(self):
14
 
                self.data_files.extend(self._compile_po_files())
15
 
                install_data.run(self)
16
 
 
17
 
        def _compile_po_files(self):
18
 
                data_files = []
19
 
                
20
 
                # Don't install language files on Win32
21
 
                if sys.platform == 'win32':
22
 
                    return data_files
23
 
                
24
 
                PO_DIR = 'po'
25
 
                for po in glob.glob(os.path.join(PO_DIR,'*.po')):
26
 
                        lang = os.path.basename(po[:-3])
27
 
                        # It's necessary to compile in this directory (not in po_dir)
28
 
                        # because install_data can't rename file
29
 
                        mo = os.path.join('build', 'mo', lang, 'olive-gtk.mo')
30
 
                        
31
 
                        directory = os.path.dirname(mo)
32
 
                        if not os.path.exists(directory):
33
 
                                info('creating %s' % directory)
34
 
                                os.makedirs(directory)
35
 
                        
36
 
                        if newer(po, mo):
37
 
                                # True if mo doesn't exist
38
 
                                cmd = 'msgfmt -o %s %s' % (mo, po)
39
 
                                info('compiling %s -> %s' % (po, mo))
40
 
                                if os.system(cmd) != 0:
41
 
                                        raise SystemExit('Error while running msgfmt')
42
 
 
43
 
                                dest = os.path.dirname(os.path.join('share', 'locale', lang, 'LC_MESSAGES', 'olive-gtk.mo'))
44
 
                                data_files.append((dest, [mo]))
45
 
                
46
 
                return data_files
47
 
 
48
 
 
49
 
 
50
 
setup(
51
 
    name = "gtk",
52
 
    version = "0.11.0",
53
 
    maintainer = "Jelmer Vernooij",
54
 
    maintainer_email = "jelmer@samba.org",
55
 
    description = "GTK+ Frontends for various Bazaar commands",
56
 
    license = "GNU GPL v2",
57
 
    scripts=['olive-gtk'],
58
 
    package_dir = {
59
 
        "bzrlib.plugins.gtk": ".",
60
 
        "bzrlib.plugins.gtk.viz": "viz", 
61
 
        "bzrlib.plugins.gtk.annotate": "annotate"
62
 
        },
63
 
    packages = [
64
 
                "olive",
65
 
        "bzrlib.plugins.gtk",
66
 
        "bzrlib.plugins.gtk.viz",
67
 
        "bzrlib.plugins.gtk.annotate"
 
116
 
 
117
    def run(self):
 
118
        import subprocess
 
119
        self.data_files.extend(self._nautilus_plugin())
 
120
        install_data.run(self)
 
121
 
 
122
        try:
 
123
            subprocess.check_call('gtk-update-icon-cache '
 
124
                                  '-f -t /usr/share/icons/hicolor')
 
125
        except OSError:
 
126
            pass
 
127
 
 
128
    def _nautilus_plugin(self):
 
129
        files = []
 
130
        if sys.platform[:5] == 'linux':
 
131
            cmd = os.popen('pkg-config --variable=pythondir nautilus-python',
 
132
                           'r')
 
133
            res = cmd.readline().strip()
 
134
            ret = cmd.close()
 
135
            if ret is None:
 
136
                dest = res[5:]
 
137
                files.append((dest, ['nautilus-bzr.py']))
 
138
        return files
 
139
 
 
140
 
 
141
if __name__ == '__main__':
 
142
    version = bzr_plugin_version[:3]
 
143
    version_string = ".".join([str(x) for x in version])
 
144
    setup(
 
145
        name="bzr-gtk",
 
146
        version=version_string,
 
147
        maintainer="Jelmer Vernooij",
 
148
        maintainer_email="jelmer@samba.org",
 
149
        description="GTK+ Frontends for various Bazaar commands",
 
150
        license="GNU GPL v2 or later",
 
151
        scripts=['bzr-handle-patch', 'bzr-notify'],
 
152
        url="http://bazaar-vcs.org/BzrGtk",
 
153
        package_dir={
 
154
            "bzrlib.plugins.gtk": ".",
 
155
            "bzrlib.plugins.gtk.viz": "viz",
 
156
            "bzrlib.plugins.gtk.annotate": "annotate",
 
157
            "bzrlib.plugins.gtk.tests": "tests",
 
158
            "bzrlib.plugins.gtk.branchview": "branchview",
 
159
            "bzrlib.plugins.gtk.preferences": "preferences",
 
160
            },
 
161
        packages=[
 
162
            "bzrlib.plugins.gtk",
 
163
            "bzrlib.plugins.gtk.viz",
 
164
            "bzrlib.plugins.gtk.annotate",
 
165
            "bzrlib.plugins.gtk.tests",
 
166
            "bzrlib.plugins.gtk.branchview",
 
167
            "bzrlib.plugins.gtk.preferences",
68
168
        ],
69
 
      data_files=[('share/olive', ['olive.glade',
70
 
                                   'oliveicon2.png',
71
 
                                   'cmenu.ui',
72
 
                                   'icons/commit.png',
73
 
                                   'icons/commit16.png',
74
 
                                   'icons/diff.png',
75
 
                                   'icons/diff16.png',
76
 
                                   'icons/log.png',
77
 
                                   'icons/log16.png',
78
 
                                   'icons/pull.png',
79
 
                                   'icons/pull16.png',
80
 
                                   'icons/push.png',
81
 
                                   'icons/push16.png',
82
 
                                   'icons/refresh.png']),
83
 
                  ('share/applications', ['olive-gtk.desktop']),
84
 
                  ('share/pixmaps', ['icons/olive-gtk.png'])
85
 
                 ],
86
 
        cmdclass={'install_data': InstallData}
87
 
)
 
169
        data_files=[('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/sign-bad.png',
 
182
                                             'icons/sign-ok.png',
 
183
                                             'icons/sign.png',
 
184
                                             'icons/sign-unknown.png',
 
185
                                             'icons/tag-16.png',
 
186
                                             'icons/bug.png',
 
187
                                             'icons/bzr-icon-64.png']),
 
188
                    # In case Python distutils extra is not available,
 
189
                    # install the .desktop files
 
190
                    ('share/applications', ['bazaar-properties.desktop',
 
191
                                            'bzr-handle-patch.desktop',
 
192
                                            'bzr-notify.desktop']),
 
193
                    ('share/application-registry', ['bzr-gtk.applications']),
 
194
                    ('share/pixmaps', ['icons/bzr-icon-64.png']),
 
195
                    ('share/icons/hicolor/scalable/apps',
 
196
                        ['icons/bzr-panel.svg']),
 
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
                  'build_i18n': cmd_build_i18n,
 
209
                  'sdist': SourceDist,
 
210
                  'check': Check}
 
211
        )