3
"""GTK+ Frontends for various Bazaar commands."""
5
from distutils.core import setup, Command
6
from distutils.command.install_data import install_data
7
from distutils.command.build import build
8
from distutils.dep_util import newer
9
from distutils.log import info
15
description = "Run unit tests"
19
def initialize_options(self):
22
def finalize_options(self):
25
def get_command_name(self):
29
from bzrlib.tests import TestLoader, TestSuite, TextTestRunner
30
import __init__ as bzrgtk
31
runner = TextTestRunner()
34
suite.addTest(bzrgtk.test_suite())
35
result = runner.run(suite)
36
return result.wasSuccessful()
39
class CreateCredits(Command):
40
description = "Create credits file"
42
user_options = [("url=", None, "URL of branch")]
44
def initialize_options(self):
47
def finalize_options(self):
50
def get_command_name(self):
51
return 'build_credits'
54
from bzrlib.plugin import load_plugins; load_plugins()
55
from bzrlib.branch import Branch
56
from bzrlib.plugins.stats import find_credits
60
branch = Branch.open(self.url)
61
credits = find_credits(branch.repository, branch.last_revision())
63
pickle.dump(credits, file("credits.pickle", 'w'))
67
def is_versioned(cmd):
68
from bzrlib.errors import NotBranchError
70
from bzrlib.branch import Branch
73
except NotBranchError:
77
class BuildData(build):
78
sub_commands = build.sub_commands[:]
79
sub_commands.append(('build_credits', is_versioned))
82
class InstallData(install_data):
84
self.data_files.extend(self._compile_po_files())
85
self.data_files.extend(self._nautilus_plugin())
86
install_data.run(self)
89
subprocess.check_call('gtk-update-icon-cache -f -t /usr/share/icons/hicolor')
93
def _compile_po_files(self):
96
# Don't install language files on Win32
97
if sys.platform == 'win32':
101
for po in glob.glob(os.path.join(PO_DIR,'*.po')):
102
lang = os.path.basename(po[:-3])
103
# It's necessary to compile in this directory (not in po_dir)
104
# because install_data can't rename file
105
mo = os.path.join('build', 'mo', lang, 'olive-gtk.mo')
107
directory = os.path.dirname(mo)
108
if not os.path.exists(directory):
109
info('creating %s' % directory)
110
os.makedirs(directory)
113
# True if mo doesn't exist
114
cmd = 'msgfmt -o %s %s' % (mo, po)
115
info('compiling %s -> %s' % (po, mo))
116
if os.system(cmd) != 0:
117
raise SystemExit('Error while running msgfmt')
119
dest = os.path.dirname(os.path.join('share', 'locale', lang, 'LC_MESSAGES', 'olive-gtk.mo'))
120
data_files.append((dest, [mo]))
124
def _nautilus_plugin(self):
126
if sys.platform[:5] == 'linux':
127
cmd = os.popen('pkg-config --variable=pythondir nautilus-python', 'r')
128
res = cmd.readline().strip()
133
files.append((dest, ['nautilus-bzr.py']))
141
maintainer = "Jelmer Vernooij",
142
maintainer_email = "jelmer@samba.org",
143
description = "GTK+ Frontends for various Bazaar commands",
144
license = "GNU GPL v2 or later",
145
scripts = ['olive-gtk', 'bzr-handle-patch', 'bzr-notify'],
146
url = "http://bazaar-vcs.org/BzrGtk",
148
"bzrlib.plugins.gtk": ".",
149
"bzrlib.plugins.gtk.viz": "viz",
150
"bzrlib.plugins.gtk.annotate": "annotate",
151
"bzrlib.plugins.gtk.olive": "olive",
152
"bzrlib.plugins.gtk.tests": "tests",
153
"bzrlib.plugins.gtk.branchview": "branchview",
154
"bzrlib.plugins.gtk.preferences": "preferences",
157
"bzrlib.plugins.gtk",
158
"bzrlib.plugins.gtk.viz",
159
"bzrlib.plugins.gtk.annotate",
160
"bzrlib.plugins.gtk.olive",
161
"bzrlib.plugins.gtk.tests",
162
"bzrlib.plugins.gtk.branchview",
163
"bzrlib.plugins.gtk.preferences",
165
data_files=[('share/olive', ['cmenu.ui',
167
('share/bzr-gtk', ['credits.pickle']),
168
('share/bzr-gtk/icons', ['icons/commit.png',
169
'icons/commit16.png',
179
'icons/olive-gtk.png',
180
'icons/oliveicon2.png',
181
'icons/sign-bad.png',
184
'icons/sign-unknown.png',
187
'icons/bzr-icon-64.png']),
188
('share/applications', ['olive-gtk.desktop',
189
'bazaar-properties.desktop',
190
'bzr-handle-patch.desktop',
191
'bzr-notify.desktop']),
192
('share/application-registry', ['bzr-gtk.applications']),
193
('share/pixmaps', ['icons/olive-gtk.png', 'icons/bzr-icon-64.png']),
194
('share/icons/hicolor/scalable/emblems',
195
['icons/emblem-bzr-added.svg',
196
'icons/emblem-bzr-conflict.svg',
197
'icons/emblem-bzr-controlled.svg',
198
'icons/emblem-bzr-modified.svg',
199
'icons/emblem-bzr-removed.svg'])
201
cmdclass={'install_data': InstallData,
202
'build_credits': CreateCredits,