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
=== modified file 'setup.py'
--- setup.py 2012-02-29 12:35:23 +0000
+++ setup.py 2012-03-27 21:04:19 +0000
@@ -73,11 +73,6 @@
73 'tests/ssl_certs/server.crt',73 'tests/ssl_certs/server.crt',
74 ]},74 ]},
75 }75 }
76I18N_FILES = []
77for filepath in glob.glob("bzrlib/locale/*/LC_MESSAGES/*.mo"):
78 langfile = filepath[len("bzrlib/locale/"):]
79 targetpath = os.path.dirname(os.path.join("share/locale", langfile))
80 I18N_FILES.append((targetpath, [filepath]))
8176
82def get_bzrlib_packages():77def get_bzrlib_packages():
83 """Recurse through the bzrlib directory, and extract the package names"""78 """Recurse through the bzrlib directory, and extract the package names"""
@@ -105,6 +100,7 @@
105100
106from distutils import log101from distutils import log
107from distutils.core import setup102from distutils.core import setup
103from distutils.command.install import install
108from distutils.command.install_scripts import install_scripts104from distutils.command.install_scripts import install_scripts
109from distutils.command.install_data import install_data105from distutils.command.install_data import install_data
110from distutils.command.build import build106from distutils.command.build import build
@@ -157,10 +153,6 @@
157 Generate bzr.1.153 Generate bzr.1.
158 """154 """
159155
160 sub_commands = build.sub_commands + [
161 ('build_mo', lambda _: True),
162 ]
163
164 def run(self):156 def run(self):
165 build.run(self)157 build.run(self)
166158
@@ -168,15 +160,21 @@
168 generate_docs.main(argv=["bzr", "man"])160 generate_docs.main(argv=["bzr", "man"])
169161
170162
163# Add the .mo related subcommands before the *_scripts commands
164bzr_build.sub_commands.insert(3, ('build_mo', lambda _: True))
165install.sub_commands.insert(2, ('install_mo', lambda _: True))
166
167
171########################168########################
172## Setup169## Setup
173########################170########################
174171
175from bzrlib.bzr_distutils import build_mo172from tools.bzr_distutils import build_mo, install_mo
176173
177command_classes = {'install_scripts': my_install_scripts,174command_classes = {'install_scripts': my_install_scripts,
178 'build': bzr_build,175 'build': bzr_build,
179 'build_mo': build_mo,176 'build_mo': build_mo,
177 'install_mo': install_mo,
180 }178 }
181from distutils import log179from distutils import log
182from distutils.errors import CCompilerError, DistutilsPlatformError180from distutils.errors import CCompilerError, DistutilsPlatformError
@@ -522,7 +520,6 @@
522520
523 ARGS.update(META_INFO)521 ARGS.update(META_INFO)
524 ARGS.update(BZRLIB)522 ARGS.update(BZRLIB)
525 PKG_DATA['package_data']['bzrlib'].append('locale/*/LC_MESSAGES/*.mo')
526 ARGS.update(PKG_DATA)523 ARGS.update(PKG_DATA)
527524
528 setup(**ARGS)525 setup(**ARGS)
@@ -677,7 +674,7 @@
677 'tools/win32/bzr_postinstall.py',674 'tools/win32/bzr_postinstall.py',
678 ]675 ]
679 gui_targets = [gui_target]676 gui_targets = [gui_target]
680 data_files = topics_files + plugins_files + I18N_FILES677 data_files = topics_files + plugins_files
681678
682 if 'qbzr' in plugins:679 if 'qbzr' in plugins:
683 get_qbzr_py2exe_info(includes, excludes, packages, data_files)680 get_qbzr_py2exe_info(includes, excludes, packages, data_files)
@@ -764,7 +761,6 @@
764 # easy_install one761 # easy_install one
765 DATA_FILES = [('man/man1', ['bzr.1'])]762 DATA_FILES = [('man/man1', ['bzr.1'])]
766763
767 DATA_FILES = DATA_FILES + I18N_FILES
768 # std setup764 # std setup
769 ARGS = {'scripts': ['bzr'],765 ARGS = {'scripts': ['bzr'],
770 'data_files': DATA_FILES,766 'data_files': DATA_FILES,
771767
=== renamed file 'bzrlib/bzr_distutils.py' => 'tools/bzr_distutils.py'
--- bzrlib/bzr_distutils.py 2011-12-19 13:23:58 +0000
+++ tools/bzr_distutils.py 2012-03-27 21:04:19 +0000
@@ -116,3 +116,49 @@
116 self.spawn(['msgfmt', '-o', mo, po])116 self.spawn(['msgfmt', '-o', mo, po])
117117
118118
119class install_mo(Command):
120
121 description = "install mo files"
122
123 user_options = [
124 ('install-dir=', 'd', "directory to install mo files to"),
125 ('build-dir=','b', "build directory (where to install from)"),
126 ('force', 'f', "force installation (overwrite existing files)"),
127 ('skip-build', None, "skip the build steps"),
128 ]
129
130 boolean_options = ['force', 'skip-build']
131
132 def initialize_options(self):
133 self.install_data = None
134 self.install_dir = None
135 self.build_dir = None
136 self.force = False
137 self.skip_build = False
138
139 def finalize_options(self):
140 self.set_undefined_options('install',
141 ('install_data', 'install_data'),
142 ('force', 'force'),
143 ('skip_build', 'skip_build'),
144 )
145 self.set_undefined_options('build_mo',
146 ('build_dir', 'build_dir'),
147 )
148 if self.install_dir is None:
149 # TODO: platform specific tweaks
150 self.install_dir = os.path.join(self.install_data, "share/locale")
151
152 def run(self):
153 self.build()
154 self.install()
155
156 def build(self):
157 if not self.skip_build:
158 self.run_command('build_mo')
159
160 def install(self):
161 if os.path.isdir(self.build_dir):
162 return self.copy_tree(self.build_dir, self.install_dir)
163 self.warn("'%s' does not exist -- no .mo files to install" %
164 self.build_dir)

Subscribers

People subscribed via source and target branches