2
"""GTK+ Frontends for various Bazaar commands."""
3
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
from distutils.core import setup
20
from distutils.command.install_data import install_data
21
from distutils.dep_util import newer
22
from distutils.log import info
7
from info import bzr_plugin_version
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
14
from DistUtilsExtra.command import build_i18n
16
# Python distutils extra is not available.
17
class cmd_build_i18n(build):
20
def initialize_options(self):
22
self.desktop_files = None
24
def finalize_options(self):
28
print >> sys.stderr, (
29
"For internationalization support you'll need to install "
30
"https://launchpad.net/python-distutils-extra")
32
# Use build_i18n from DistUtilsExtra
33
cmd_build_i18n = build_i18n.build_i18n
37
description = "Run unit tests"
40
('module=', 'm', 'The test module to run'),
43
def initialize_options(self):
46
def finalize_options(self):
49
def get_command_name(self):
53
from bzrlib.tests import TestLoader, TestSuite, TextTestRunner
54
from bzrlib.plugin import PluginImporter
55
PluginImporter.specific_paths["bzrlib.plugins.gtk"] = os.path.dirname(
57
from bzrlib.plugins.gtk.tests import load_tests
60
load_tests(suite, self.module, loader)
61
runner = TextTestRunner()
62
result = runner.run(suite)
63
return result.wasSuccessful()
66
class CreateCredits(Command):
67
description = "Create credits file"
69
user_options = [("url=", None, "URL of branch")]
71
def initialize_options(self):
74
def finalize_options(self):
77
def get_command_name(self):
78
return 'build_credits'
81
from bzrlib.plugin import load_plugins
83
from bzrlib.branch import Branch
84
from bzrlib.plugins.stats.cmds import find_credits
88
branch = Branch.open(self.url)
89
credits = find_credits(branch.repository, branch.last_revision())
91
pickle.dump(credits, file("credits.pickle", 'w'))
95
def is_versioned(cmd):
96
from bzrlib.errors import NotBranchError
98
from bzrlib.branch import Branch
101
except NotBranchError:
105
class BuildData(build):
106
sub_commands = build.sub_commands[:]
107
sub_commands.append(('build_credits', is_versioned))
110
class SourceDist(sdist):
111
sub_commands = sdist.sub_commands[:]
112
sub_commands.append(('build_credits', is_versioned))
115
27
class InstallData(install_data):
119
self.data_files.extend(self._nautilus_plugin())
120
install_data.run(self)
123
subprocess.check_call('gtk-update-icon-cache '
124
'-f -t /usr/share/icons/hicolor')
128
def _nautilus_plugin(self):
130
if sys.platform[:5] == 'linux':
131
cmd = os.popen('pkg-config --variable=pythondir nautilus-python',
133
res = cmd.readline().strip()
137
files.append((dest, ['nautilus-bzr.py']))
141
if __name__ == '__main__':
142
version = bzr_plugin_version[:3]
143
version_string = ".".join([str(x) for x in version])
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",
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",
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",
169
data_files=[('share/bzr-gtk', ['credits.pickle']),
170
('share/bzr-gtk/icons', ['icons/commit.png',
171
'icons/commit16.png',
181
'icons/sign-bad.png',
184
'icons/sign-unknown.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'])
204
cmdclass={'install_data': InstallData,
205
'build_credits': CreateCredits,
207
'build_i18n': cmd_build_i18n,
29
self.data_files.extend(self._compile_po_files())
30
install_data.run(self)
32
def _compile_po_files(self):
35
# Don't install language files on Win32
36
if sys.platform == 'win32':
40
for po in glob.glob(os.path.join(PO_DIR,'*.po')):
41
lang = os.path.basename(po[:-3])
42
# It's necessary to compile in this directory (not in po_dir)
43
# because install_data can't rename file
44
mo = os.path.join('build', 'mo', lang, 'olive-gtk.mo')
46
directory = os.path.dirname(mo)
47
if not os.path.exists(directory):
48
info('creating %s' % directory)
49
os.makedirs(directory)
52
# True if mo doesn't exist
53
cmd = 'msgfmt -o %s %s' % (mo, po)
54
info('compiling %s -> %s' % (po, mo))
55
if os.system(cmd) != 0:
56
raise SystemExit('Error while running msgfmt')
58
dest = os.path.dirname(os.path.join('share', 'locale', lang, 'LC_MESSAGES', 'olive-gtk.mo'))
59
data_files.append((dest, [mo]))
65
description='Olive - Graphical frontend for Bazaar',
66
author='Szilveszter Farkas (Phanatic)',
67
author_email='szilveszter.farkas@gmail.com',
68
url='http://bazaar-vcs.org/Olive',
70
scripts=['olive-gtk'],
71
data_files=[('share/olive', ['olive.glade',
84
'icons/refresh.png']),
85
('share/applications', ['olive-gtk.desktop']),
86
('share/pixmaps', ['icons/olive-gtk.png'])
88
cmdclass={'install_data': InstallData