/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: 2007-02-01 15:50:40 UTC
  • Revision ID: jelmer@samba.org-20070201155040-3hq4mfbxs99kzazy
add framework for tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
 
 
1
#!/usr/bin/env python2.4
3
2
"""GTK+ Frontends for various Bazaar commands."""
4
3
 
5
 
from distutils.core import setup, Command
 
4
from distutils.core import setup
6
5
from distutils.command.install_data import install_data
7
 
from distutils.command.build import build
 
6
from distutils.dep_util import newer
 
7
from distutils.log import info
 
8
import glob
8
9
import os
9
10
import sys
10
11
 
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
12
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",
 
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 = "bzr-gtk",
 
52
    version = "0.14.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
        "bzrlib.plugins.gtk.olive": "olive"
 
63
        },
 
64
    packages = [
 
65
                "olive",
 
66
        "bzrlib.plugins.gtk",
 
67
        "bzrlib.plugins.gtk.viz",
 
68
        "bzrlib.plugins.gtk.annotate",
 
69
        "bzrlib.plugins.gtk.olive"
130
70
        ],
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
 
        )
 
71
      data_files=[('share/olive', ['olive.glade',
 
72
                                   'oliveicon2.png',
 
73
                                   'cmenu.ui',
 
74
                                  ]),
 
75
                  ('share/olive/icons', [\
 
76
                                   'icons/commit.png',
 
77
                                   'icons/commit16.png',
 
78
                                   'icons/diff.png',
 
79
                                   'icons/diff16.png',
 
80
                                   'icons/log.png',
 
81
                                   'icons/log16.png',
 
82
                                   'icons/pull.png',
 
83
                                   'icons/pull16.png',
 
84
                                   'icons/push.png',
 
85
                                   'icons/push16.png',
 
86
                                   'icons/refresh.png']),
 
87
                  ('share/applications', ['olive-gtk.desktop']),
 
88
                  ('share/pixmaps', ['icons/olive-gtk.png'])
 
89
                 ],
 
90
        cmdclass={'install_data': InstallData}
 
91
)