/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: Vincent Ladeuil
  • Date: 2008-05-05 18:16:46 UTC
  • mto: (487.1.1 gtk)
  • mto: This revision was merged to the branch mainline in revision 490.
  • Revision ID: v.ladeuil+lp@free.fr-20080505181646-n95l8ltw2u6jtr26
Fix bug #187283 fix replacing _() by _i18n().

* genpot.sh 
Remove duplication. Add the ability to specify the genrated pot
file on command-line for debugging purposes.

* po/olive-gtk.pot:
Regenerated.

* __init__.py, branch.py, branchview/treeview.py, checkout.py,
commit.py, conflicts.py, diff.py, errors.py, initialize.py,
merge.py, nautilus-bzr.py, olive/__init__.py, olive/add.py,
olive/bookmark.py, olive/guifiles.py, olive/info.py,
olive/menu.py, olive/mkdir.py, olive/move.py, olive/remove.py,
olive/rename.py, push.py, revbrowser.py, status.py, tags.py:
Replace all calls to _() by calls to _i18n(), the latter being
defined in __init__.py and imported in the other modules from
there. This fix the problem encountered countless times when
running bzr selftest and getting silly error messages about
boolean not being callables.

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