/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: 2012-07-09 15:23:26 UTC
  • mto: This revision was merged to the branch mainline in revision 794.
  • Revision ID: jelmer@samba.org-20120709152326-dzxb8zoz0btull7n
Remove bzr-notify.

Show diffs side-by-side

added added

removed removed

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