/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: Curtis Hovey
  • Date: 2012-02-27 21:07:38 UTC
  • mto: (776.3.1 gpush)
  • mto: This revision was merged to the branch mainline in revision 779.
  • Revision ID: sinzui.is@verizon.net-20120227210738-f5vb56xm2k2ii19j
Added show_user_warning implementation.

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
 
10
try:
 
11
    from DistUtilsExtra.command import *
 
12
except ImportError:
 
13
   # Python distutils extra is not available.
 
14
    class cmd_build_i18n(Command):
 
15
        def run(self):
 
16
            print >> sys.stderr, "For internationalization support you'll need to install https://launchpad.net/python-distutils-extra"
 
17
else:
 
18
    # Use build_i18n from DistUtilsExtra
 
19
    cmd_build_i18n = build_i18n.build_i18n
 
20
 
9
21
import os
10
22
import sys
11
23
 
12
24
class Check(Command):
13
25
    description = "Run unit tests"
14
26
 
15
 
    user_options = []
 
27
    user_options = [
 
28
        ('module=', 'm', 'The test module to run'),
 
29
        ]
16
30
 
17
31
    def initialize_options(self):
18
 
        pass
 
32
        self.module = 'discover'
19
33
 
20
34
    def finalize_options(self):
21
35
        pass
25
39
 
26
40
    def run(self):
27
41
        from bzrlib.tests import TestLoader, TestSuite, TextTestRunner
28
 
        import __init__ as bzrgtk
 
42
        from bzrlib.plugin import PluginImporter
 
43
        PluginImporter.specific_paths["bzrlib.plugins.gtk"] = os.path.dirname(__file__)
 
44
        from bzrlib.plugins.gtk.tests import load_tests
 
45
        suite = TestSuite()
 
46
        loader = TestLoader()
 
47
        load_tests(suite, self.module, loader)
29
48
        runner = TextTestRunner()
30
 
        loader = TestLoader()
31
 
        suite = TestSuite()
32
 
        suite.addTest(bzrgtk.test_suite())
33
49
        result = runner.run(suite)
34
50
        return result.wasSuccessful()
35
51
 
 
52
 
 
53
class CreateCredits(Command):
 
54
    description = "Create credits file"
 
55
 
 
56
    user_options = [("url=", None, "URL of branch")]
 
57
 
 
58
    def initialize_options(self):
 
59
        self.url = "."
 
60
 
 
61
    def finalize_options(self):
 
62
        pass
 
63
 
 
64
    def get_command_name(self):
 
65
        return 'build_credits'
 
66
 
 
67
    def run(self):
 
68
        from bzrlib.plugin import load_plugins; load_plugins()
 
69
        from bzrlib.branch import Branch
 
70
        from bzrlib.plugins.stats.cmds import find_credits
 
71
 
 
72
        import pickle
 
73
 
 
74
        branch = Branch.open(self.url)
 
75
        credits = find_credits(branch.repository, branch.last_revision())
 
76
 
 
77
        pickle.dump(credits, file("credits.pickle", 'w'))
 
78
        return True
 
79
 
 
80
 
 
81
def is_versioned(cmd):
 
82
    from bzrlib.errors import NotBranchError
 
83
    try:
 
84
        from bzrlib.branch import Branch
 
85
        Branch.open(".")
 
86
        return True
 
87
    except NotBranchError:
 
88
        return False
 
89
 
 
90
 
 
91
class BuildData(build):
 
92
    sub_commands = build.sub_commands[:]
 
93
    sub_commands.append(('build_credits', is_versioned))
 
94
 
 
95
 
 
96
class SourceDist(sdist):
 
97
    sub_commands = sdist.sub_commands[:]
 
98
    sub_commands.append(('build_credits', is_versioned))
 
99
 
 
100
 
36
101
class InstallData(install_data):
 
102
 
37
103
    def run(self):
38
 
        self.data_files.extend(self._compile_po_files())
 
104
        import subprocess
39
105
        self.data_files.extend(self._nautilus_plugin())
40
106
        install_data.run(self)
41
107
 
42
108
        try:
43
 
            subprocess.check_call('gtk-update-icon-cache -f -t /usr/share/icons/hicolor')
44
 
        except:
 
109
            subprocess.check_call('gtk-update-icon-cache '
 
110
                                  '-f -t /usr/share/icons/hicolor')
 
111
        except OSError:
45
112
            pass
46
113
 
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
114
    def _nautilus_plugin(self):
79
115
        files = []
80
116
        if sys.platform[:5] == 'linux':
81
 
            cmd = os.popen('pkg-config --variable=pythondir nautilus-python', 'r')
82
 
            res = cmd.readline()
 
117
            cmd = os.popen('pkg-config --variable=pythondir nautilus-python',
 
118
                           'r')
 
119
            res = cmd.readline().strip()
83
120
            ret = cmd.close()
84
 
            
85
121
            if ret is None:
86
122
                dest = res[5:]
87
123
                files.append((dest, ['nautilus-bzr.py']))
88
 
        
89
124
        return files
90
125
 
91
126
 
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",
 
127
if __name__ == '__main__':
 
128
    version = bzr_plugin_version[:3]
 
129
    version_string = ".".join([str(x) for x in version])
 
130
    setup(
 
131
        name = "bzr-gtk",
 
132
        version = version_string,
 
133
        maintainer = "Jelmer Vernooij",
 
134
        maintainer_email = "jelmer@samba.org",
 
135
        description = "GTK+ Frontends for various Bazaar commands",
 
136
        license = "GNU GPL v2 or later",
 
137
        scripts = ['bzr-handle-patch', 'bzr-notify'],
 
138
        url = "http://bazaar-vcs.org/BzrGtk",
 
139
        package_dir = {
 
140
            "bzrlib.plugins.gtk": ".",
 
141
            "bzrlib.plugins.gtk.viz": "viz",
 
142
            "bzrlib.plugins.gtk.annotate": "annotate",
 
143
            "bzrlib.plugins.gtk.tests": "tests",
 
144
            "bzrlib.plugins.gtk.branchview": "branchview",
 
145
            "bzrlib.plugins.gtk.preferences": "preferences",
 
146
            },
 
147
        packages = [
 
148
            "bzrlib.plugins.gtk",
 
149
            "bzrlib.plugins.gtk.viz",
 
150
            "bzrlib.plugins.gtk.annotate",
 
151
            "bzrlib.plugins.gtk.tests",
 
152
            "bzrlib.plugins.gtk.branchview",
 
153
            "bzrlib.plugins.gtk.preferences",
117
154
        ],
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
 
)
 
155
        data_files=[ ('share/bzr-gtk', ['credits.pickle']),
 
156
                    ('share/bzr-gtk/icons', ['icons/commit.png',
 
157
                                             'icons/commit16.png',
 
158
                                             'icons/diff.png',
 
159
                                             'icons/diff16.png',
 
160
                                             'icons/log.png',
 
161
                                             'icons/log16.png',
 
162
                                             'icons/pull.png',
 
163
                                             'icons/pull16.png',
 
164
                                             'icons/push.png',
 
165
                                             'icons/push16.png',
 
166
                                             'icons/refresh.png',
 
167
                                             'icons/sign-bad.png',
 
168
                                             'icons/sign-ok.png',
 
169
                                             'icons/sign.png',
 
170
                                             'icons/sign-unknown.png',
 
171
                                             'icons/tag-16.png',
 
172
                                             'icons/bug.png',
 
173
                                             'icons/bzr-icon-64.png']),
 
174
                    # In case Python distutils extra is not available,
 
175
                    # install the .desktop files
 
176
                    ('share/applications', ['bazaar-properties.desktop',
 
177
                                            'bzr-handle-patch.desktop',
 
178
                                            'bzr-notify.desktop']),
 
179
                    ('share/application-registry', ['bzr-gtk.applications']),
 
180
                    ('share/pixmaps', ['icons/bzr-icon-64.png']),
 
181
                    ('share/icons/hicolor/scalable/apps', ['icons/bzr-panel.svg']),
 
182
                    ('share/icons/hicolor/scalable/emblems',
 
183
                     ['icons/emblem-bzr-added.svg',
 
184
                      'icons/emblem-bzr-conflict.svg',
 
185
                      'icons/emblem-bzr-controlled.svg',
 
186
                      'icons/emblem-bzr-modified.svg',
 
187
                      'icons/emblem-bzr-removed.svg',
 
188
                      'icons/emblem-bzr-ignored.svg'])
 
189
                    ],
 
190
        cmdclass={'install_data': InstallData,
 
191
                  'build_credits': CreateCredits,
 
192
                  'build': BuildData,
 
193
                  'build_i18n': cmd_build_i18n,
 
194
                  'sdist': SourceDist,
 
195
                  'check': Check}
 
196
        )