/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-05 05:14:11 UTC
  • mto: This revision was merged to the branch mainline in revision 775.
  • Revision ID: sinzui.is@verizon.net-20120205051411-y9ra08wae1wsfv52
Remove unneeded gtksourceview1 support.

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