/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: rodney.dawes at canonical
  • Date: 2008-10-25 06:02:09 UTC
  • Revision ID: rodney.dawes@canonical.com-20081025060209-irlizouino63cs1m
        * preferences/__init__.py:
        Remove the dialog separator
        Remove useless extra call to self._create_pages()
        Make the default window size smaller
        Set the default border width on various widgets
        Set the current notebook page to the first one

        * preferences/identity.py:
        Set various border widths appropriately
        Align the labels to the left
        Remove the unneeded bold markup from the labels
        Change the "User Id" label to "E-Mail"
        Align the radio group labels to the top of the groups

        * preferences/plugins.py:
        Set various border widths appropriately
        Set the default paned position to something more sensible
        Set the shadow type on the treeview's scrolled window to in
        Align the Author and Version labels to the left

Show diffs side-by-side

added added

removed removed

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