1
#!/usr/bin/env python2.4
2
2
"""GTK+ Frontends for various Bazaar commands."""
6
from distutils.core import setup, Command
4
from distutils.core import setup
7
5
from distutils.command.install_data import install_data
8
from distutils.command.build import build
9
from distutils.command.sdist import sdist
11
from DistUtilsExtra.command import *
13
# Python distutils extra is not available.
14
class cmd_build_i18n(Command):
16
print >> sys.stderr, "For internationalization support you'll need to install https://launchpad.net/python-distutils-extra"
18
# Use build_i18n from DistUtilsExtra
19
cmd_build_i18n = build_i18n.build_i18n
6
from distutils.dep_util import newer
7
from distutils.log import info
25
description = "Run unit tests"
29
def initialize_options(self):
32
def finalize_options(self):
35
def get_command_name(self):
39
from bzrlib.tests import TestLoader, TestSuite, TextTestRunner
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
45
load_tests(suite, None, loader)
46
runner = TextTestRunner()
47
result = runner.run(suite)
48
return result.wasSuccessful()
51
class CreateCredits(Command):
52
description = "Create credits file"
54
user_options = [("url=", None, "URL of branch")]
56
def initialize_options(self):
59
def finalize_options(self):
62
def get_command_name(self):
63
return 'build_credits'
66
from bzrlib.plugin import load_plugins; load_plugins()
67
from bzrlib.branch import Branch
68
from bzrlib.plugins.stats.cmds import find_credits
72
branch = Branch.open(self.url)
73
credits = find_credits(branch.repository, branch.last_revision())
75
pickle.dump(credits, file("credits.pickle", 'w'))
79
def is_versioned(cmd):
80
from bzrlib.errors import NotBranchError
82
from bzrlib.branch import Branch
85
except NotBranchError:
89
class BuildData(build):
90
sub_commands = build.sub_commands[:]
91
sub_commands.append(('build_credits', is_versioned))
94
class SourceDist(sdist):
95
sub_commands = sdist.sub_commands[:]
96
sub_commands.append(('build_credits', is_versioned))
99
12
class InstallData(install_data):
103
self.data_files.extend(self._nautilus_plugin())
104
install_data.run(self)
107
subprocess.check_call('gtk-update-icon-cache '
108
'-f -t /usr/share/icons/hicolor')
112
def _nautilus_plugin(self):
114
if sys.platform[:5] == 'linux':
115
cmd = os.popen('pkg-config --variable=pythondir nautilus-python',
117
res = cmd.readline().strip()
121
files.append((dest, ['nautilus-bzr.py']))
125
if __name__ == '__main__':
126
version = bzr_plugin_version[:3]
127
version_string = ".".join([str(x) for x in version])
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",
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",
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",
14
self.data_files.extend(self._compile_po_files())
15
install_data.run(self)
17
def _compile_po_files(self):
20
# Don't install language files on Win32
21
if sys.platform == 'win32':
25
for po in glob.glob(os.path.join(PO_DIR,'*.po')):
26
lang = os.path.basename(po[:-3])
27
# It's necessary to compile in this directory (not in po_dir)
28
# because install_data can't rename file
29
mo = os.path.join('build', 'mo', lang, 'olive-gtk.mo')
31
directory = os.path.dirname(mo)
32
if not os.path.exists(directory):
33
info('creating %s' % directory)
34
os.makedirs(directory)
37
# True if mo doesn't exist
38
cmd = 'msgfmt -o %s %s' % (mo, po)
39
info('compiling %s -> %s' % (po, mo))
40
if os.system(cmd) != 0:
41
raise SystemExit('Error while running msgfmt')
43
dest = os.path.dirname(os.path.join('share', 'locale', lang, 'LC_MESSAGES', 'olive-gtk.mo'))
44
data_files.append((dest, [mo]))
53
maintainer = "Jelmer Vernooij",
54
maintainer_email = "jelmer@samba.org",
55
description = "GTK+ Frontends for various Bazaar commands",
56
license = "GNU GPL v2",
57
scripts=['olive-gtk'],
59
"bzrlib.plugins.gtk": ".",
60
"bzrlib.plugins.gtk.viz": "viz",
61
"bzrlib.plugins.gtk.annotate": "annotate"
66
"bzrlib.plugins.gtk.viz",
67
"bzrlib.plugins.gtk.annotate"
153
data_files=[ ('share/bzr-gtk', ['credits.pickle']),
154
('share/bzr-gtk/icons', ['icons/commit.png',
155
'icons/commit16.png',
165
'icons/sign-bad.png',
168
'icons/sign-unknown.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'])
188
cmdclass={'install_data': InstallData,
189
'build_credits': CreateCredits,
191
'build_i18n': cmd_build_i18n,
69
data_files=[('share/olive', ['olive.glade',
82
'icons/refresh.png']),
83
('share/applications', ['olive-gtk.desktop']),
84
('share/pixmaps', ['icons/olive-gtk.png'])
86
cmdclass={'install_data': InstallData}