29 import os, time |
29 import os, time |
30 import shutil |
30 import shutil |
31 import tempfile |
31 import tempfile |
32 from distutils.core import setup, Extension |
32 from distutils.core import setup, Extension |
33 from distutils.command.install_data import install_data |
33 from distutils.command.install_data import install_data |
|
34 from distutils.command.build import build |
|
35 from distutils.spawn import spawn, find_executable |
34 from distutils.ccompiler import new_compiler |
36 from distutils.ccompiler import new_compiler |
35 |
37 |
36 extra = {} |
38 extra = {} |
37 scripts = ['hg'] |
39 scripts = ['hg'] |
38 if os.name == 'nt': |
40 if os.name == 'nt': |
113 def finalize_options(self): |
115 def finalize_options(self): |
114 self.set_undefined_options('install', |
116 self.set_undefined_options('install', |
115 ('install_lib', 'install_dir')) |
117 ('install_lib', 'install_dir')) |
116 install_data.finalize_options(self) |
118 install_data.finalize_options(self) |
117 |
119 |
118 cmdclass = {'install_data': install_package_data} |
120 class build_mo(build): |
|
121 |
|
122 description = "build translations (.mo files)" |
|
123 |
|
124 def run(self): |
|
125 if not find_executable('msgfmt'): |
|
126 self.warn("could not find msgfmt executable, no translations " |
|
127 "will be built") |
|
128 return |
|
129 |
|
130 podir = 'i18n' |
|
131 if not os.path.isdir(podir): |
|
132 self.warn("could not find %s/ directory" % podir) |
|
133 return |
|
134 |
|
135 join = os.path.join |
|
136 for po in os.listdir(podir): |
|
137 if not po.endswith('.po'): |
|
138 continue |
|
139 pofile = join(podir, po) |
|
140 modir = join('locale', po[:-3], 'LC_MESSAGES') |
|
141 mofile = join(modir, 'hg.mo') |
|
142 self.mkpath(modir) |
|
143 self.make_file([pofile], mofile, spawn, |
|
144 (['msgfmt', '-o', mofile, pofile],)) |
|
145 self.distribution.data_files.append((join('mercurial', modir), |
|
146 [mofile])) |
|
147 |
|
148 build.sub_commands.append(('build_mo', None)) |
|
149 |
|
150 cmdclass = {'install_data': install_package_data, |
|
151 'build_mo': build_mo} |
119 |
152 |
120 ext_modules=[ |
153 ext_modules=[ |
121 Extension('mercurial.base85', ['mercurial/base85.c']), |
154 Extension('mercurial.base85', ['mercurial/base85.c']), |
122 Extension('mercurial.bdiff', ['mercurial/bdiff.c']), |
155 Extension('mercurial.bdiff', ['mercurial/bdiff.c']), |
123 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']), |
156 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']), |