/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: 2011-03-02 15:24:46 UTC
  • Revision ID: jelmer@samba.org-20110302152446-q8iogg8f2rweh25s
startĀ onĀ 0.101.0

Show diffs side-by-side

added added

removed removed

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