File: setup.py

package info (click to toggle)
bzr-gtk 0.94.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,528 kB
  • ctags: 902
  • sloc: python: 9,783; sh: 32; makefile: 8
file content (154 lines) | stat: -rwxr-xr-x 5,645 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/usr/bin/python
"""GTK+ Frontends for various Bazaar commands."""

from distutils.core import setup, Command
from distutils.command.install_data import install_data
from distutils.dep_util import newer
from distutils.log import info
import glob
import os
import sys

class Check(Command):
    description = "Run unit tests"

    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def get_command_name(self):
        return 'test'

    def run(self):
        from bzrlib.tests import TestLoader, TestSuite, TextTestRunner
        import __init__ as bzrgtk
        runner = TextTestRunner()
        loader = TestLoader()
        suite = TestSuite()
        suite.addTest(bzrgtk.test_suite())
        result = runner.run(suite)
        return result.wasSuccessful()

class InstallData(install_data):
    def run(self):
        self.data_files.extend(self._compile_po_files())
        self.data_files.extend(self._nautilus_plugin())
        install_data.run(self)

        try:
            subprocess.check_call('gtk-update-icon-cache -f -t /usr/share/icons/hicolor')
        except:
            pass

    def _compile_po_files(self):
        data_files = []
        
        # Don't install language files on Win32
        if sys.platform == 'win32':
            return data_files
        
        PO_DIR = 'po'
        for po in glob.glob(os.path.join(PO_DIR,'*.po')):
            lang = os.path.basename(po[:-3])
            # It's necessary to compile in this directory (not in po_dir)
            # because install_data can't rename file
            mo = os.path.join('build', 'mo', lang, 'olive-gtk.mo')
            
            directory = os.path.dirname(mo)
            if not os.path.exists(directory):
                info('creating %s' % directory)
                os.makedirs(directory)
            
            if newer(po, mo):
                # True if mo doesn't exist
                cmd = 'msgfmt -o %s %s' % (mo, po)
                info('compiling %s -> %s' % (po, mo))
                if os.system(cmd) != 0:
                    raise SystemExit('Error while running msgfmt')
                
                dest = os.path.dirname(os.path.join('share', 'locale', lang, 'LC_MESSAGES', 'olive-gtk.mo'))
                data_files.append((dest, [mo]))
        
        return data_files
    
    def _nautilus_plugin(self):
        files = []
        if sys.platform[:5] == 'linux':
            cmd = os.popen('pkg-config --variable=pythondir nautilus-python', 'r')
            res = cmd.readline()
            ret = cmd.close()
            
            if ret is None:
                dest = res[5:]
                files.append((dest, ['nautilus-bzr.py']))
        
        return files


setup(
    name = "bzr-gtk",
    version = "0.94.0",
    maintainer = "Jelmer Vernooij",
    maintainer_email = "jelmer@samba.org",
    description = "GTK+ Frontends for various Bazaar commands",
    license = "GNU GPL v2 or later",
    scripts=['olive-gtk'],
    package_dir = {
        "bzrlib.plugins.gtk": ".",
        "bzrlib.plugins.gtk.viz": "viz", 
        "bzrlib.plugins.gtk.annotate": "annotate",
        "bzrlib.plugins.gtk.olive": "olive",
        "bzrlib.plugins.gtk.tests": "tests",
        "bzrlib.plugins.gtk.branchview": "branchview",
        "bzrlib.plugins.gtk.preferences": "preferences",
        },
    packages = [
        "bzrlib.plugins.gtk",
        "bzrlib.plugins.gtk.viz",
        "bzrlib.plugins.gtk.annotate",
        "bzrlib.plugins.gtk.olive",
        "bzrlib.plugins.gtk.tests",
        "bzrlib.plugins.gtk.branchview",
        "bzrlib.plugins.gtk.preferences",
        ],
    data_files=[('share/olive', ['olive.glade',
                                 'cmenu.ui',
                                ]),
                ('share/olive/icons', ['icons/commit.png',
                                 'icons/commit16.png',
                                 'icons/diff.png',
                                 'icons/diff16.png',
                                 'icons/log.png',
                                 'icons/log16.png',
                                 'icons/pull.png',
                                 'icons/pull16.png',
                                 'icons/push.png',
                                 'icons/push16.png',
                                 'icons/refresh.png',
                                 'icons/oliveicon2.png']),
                ('share/bzr-gtk/icons', ['icons/sign-bad.png',
                                 'icons/sign-ok.png',
                                 'icons/sign.png',
                                 'icons/sign-unknown.png',
                                 'icons/bug.png',
                                 'icons/bzr-icon-64.png']),
                ('share/applications', ['olive-gtk.desktop',
                                        'bazaar-properties.desktop',
                                        'bzr-handle-patch.desktop',
                                        'bzr-notify.desktop']),
                ('share/application-registry', ['bzr-gtk.applications']),
                ('share/pixmaps', ['icons/olive-gtk.png', 'icons/bzr-icon-64.png']),
                ('share/icons/hicolor/scalable/emblems', 
                    ['icons/emblem-bzr-added.svg', 
                        'icons/emblem-bzr-conflict.svg', 
                        'icons/emblem-bzr-controlled.svg', 
                        'icons/emblem-bzr-modified.svg',
                        'icons/emblem-bzr-removed.svg'])
               ],
    cmdclass={'install_data': InstallData,
              'check': Check}
)