Merge lp:~gz/bzr/install_mo_command_941835 into lp:bzr/2.5

Proposed by Martin Packman
Status: Work in progress
Proposed branch: lp:~gz/bzr/install_mo_command_941835
Merge into: lp:bzr/2.5
Prerequisite: lp:~gz/bzr/run_test_setup_in_tempdir_140874
Diff against target: 136 lines (+55/-13)
2 files modified
setup.py (+9/-13)
tools/bzr_distutils.py (+46/-0)
To merge this branch: bzr merge lp:~gz/bzr/install_mo_command_941835
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) Approve
Review via email: mp+99521@code.launchpad.net

Description of the change

Adds an install_mo distutils command, and removes the current setup.py hacks related to .mo files. At the moment, .mo files will only be installed if they were built in a previous run of the script, because the code to locate them runs when setup.py loads, rather than after build_mo completes.

In addition, the bzr_distutils module is moved to tools/ as it's only needed during the setup process and isn't used by bzrlib otherwise. The idea presumably was so qbzr could share the code for it's setup.py (as it's the origin), but that's yet to happen and likely needs some more thought before it does.

The default install location is left as "share/locale" for now, but that could be changed (perhaps to something platform specific) as needed.

To post a comment you must log in.
lp:~gz/bzr/install_mo_command_941835 updated
6497. By Martin Packman

Reinstate line needed for windows installers

Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
Martin Packman (gz) wrote :

This doesn't seem sufficient to get the .mo files somewhere usable. An added complication is that if the translations should be included with the python-based installers, they probably need a different mechanism from the all-in-one installer.

...buildout makes me cry.

Revision history for this message
Martin Packman (gz) wrote :

I need to revisit this when I have time to futz with installers.

Unmerged revisions

6497. By Martin Packman

Reinstate line needed for windows installers

6496. By Martin Packman

Move distutils commands module to tools/ from bzrlib/

6495. By Martin Packman

Add install_mo distutils command so setup works when .mo files don't exist yes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2012-02-29 12:35:23 +0000
3+++ setup.py 2012-03-27 21:04:19 +0000
4@@ -73,11 +73,6 @@
5 'tests/ssl_certs/server.crt',
6 ]},
7 }
8-I18N_FILES = []
9-for filepath in glob.glob("bzrlib/locale/*/LC_MESSAGES/*.mo"):
10- langfile = filepath[len("bzrlib/locale/"):]
11- targetpath = os.path.dirname(os.path.join("share/locale", langfile))
12- I18N_FILES.append((targetpath, [filepath]))
13
14 def get_bzrlib_packages():
15 """Recurse through the bzrlib directory, and extract the package names"""
16@@ -105,6 +100,7 @@
17
18 from distutils import log
19 from distutils.core import setup
20+from distutils.command.install import install
21 from distutils.command.install_scripts import install_scripts
22 from distutils.command.install_data import install_data
23 from distutils.command.build import build
24@@ -157,10 +153,6 @@
25 Generate bzr.1.
26 """
27
28- sub_commands = build.sub_commands + [
29- ('build_mo', lambda _: True),
30- ]
31-
32 def run(self):
33 build.run(self)
34
35@@ -168,15 +160,21 @@
36 generate_docs.main(argv=["bzr", "man"])
37
38
39+# Add the .mo related subcommands before the *_scripts commands
40+bzr_build.sub_commands.insert(3, ('build_mo', lambda _: True))
41+install.sub_commands.insert(2, ('install_mo', lambda _: True))
42+
43+
44 ########################
45 ## Setup
46 ########################
47
48-from bzrlib.bzr_distutils import build_mo
49+from tools.bzr_distutils import build_mo, install_mo
50
51 command_classes = {'install_scripts': my_install_scripts,
52 'build': bzr_build,
53 'build_mo': build_mo,
54+ 'install_mo': install_mo,
55 }
56 from distutils import log
57 from distutils.errors import CCompilerError, DistutilsPlatformError
58@@ -522,7 +520,6 @@
59
60 ARGS.update(META_INFO)
61 ARGS.update(BZRLIB)
62- PKG_DATA['package_data']['bzrlib'].append('locale/*/LC_MESSAGES/*.mo')
63 ARGS.update(PKG_DATA)
64
65 setup(**ARGS)
66@@ -677,7 +674,7 @@
67 'tools/win32/bzr_postinstall.py',
68 ]
69 gui_targets = [gui_target]
70- data_files = topics_files + plugins_files + I18N_FILES
71+ data_files = topics_files + plugins_files
72
73 if 'qbzr' in plugins:
74 get_qbzr_py2exe_info(includes, excludes, packages, data_files)
75@@ -764,7 +761,6 @@
76 # easy_install one
77 DATA_FILES = [('man/man1', ['bzr.1'])]
78
79- DATA_FILES = DATA_FILES + I18N_FILES
80 # std setup
81 ARGS = {'scripts': ['bzr'],
82 'data_files': DATA_FILES,
83
84=== renamed file 'bzrlib/bzr_distutils.py' => 'tools/bzr_distutils.py'
85--- bzrlib/bzr_distutils.py 2011-12-19 13:23:58 +0000
86+++ tools/bzr_distutils.py 2012-03-27 21:04:19 +0000
87@@ -116,3 +116,49 @@
88 self.spawn(['msgfmt', '-o', mo, po])
89
90
91+class install_mo(Command):
92+
93+ description = "install mo files"
94+
95+ user_options = [
96+ ('install-dir=', 'd', "directory to install mo files to"),
97+ ('build-dir=','b', "build directory (where to install from)"),
98+ ('force', 'f', "force installation (overwrite existing files)"),
99+ ('skip-build', None, "skip the build steps"),
100+ ]
101+
102+ boolean_options = ['force', 'skip-build']
103+
104+ def initialize_options(self):
105+ self.install_data = None
106+ self.install_dir = None
107+ self.build_dir = None
108+ self.force = False
109+ self.skip_build = False
110+
111+ def finalize_options(self):
112+ self.set_undefined_options('install',
113+ ('install_data', 'install_data'),
114+ ('force', 'force'),
115+ ('skip_build', 'skip_build'),
116+ )
117+ self.set_undefined_options('build_mo',
118+ ('build_dir', 'build_dir'),
119+ )
120+ if self.install_dir is None:
121+ # TODO: platform specific tweaks
122+ self.install_dir = os.path.join(self.install_data, "share/locale")
123+
124+ def run(self):
125+ self.build()
126+ self.install()
127+
128+ def build(self):
129+ if not self.skip_build:
130+ self.run_command('build_mo')
131+
132+ def install(self):
133+ if os.path.isdir(self.build_dir):
134+ return self.copy_tree(self.build_dir, self.install_dir)
135+ self.warn("'%s' does not exist -- no .mo files to install" %
136+ self.build_dir)

Subscribers

People subscribed via source and target branches