Show More
@@ -7,6 +7,17 b'' | |||||
7 | # This software may be used and distributed according to the terms of the |
|
7 | # This software may be used and distributed according to the terms of the | |
8 | # GNU General Public License version 2 or any later version. |
|
8 | # GNU General Public License version 2 or any later version. | |
9 |
|
9 | |||
|
10 | import os | |||
|
11 | import sys | |||
|
12 | ||||
|
13 | libdir = '@LIBDIR@' | |||
|
14 | ||||
|
15 | if libdir != '@' 'LIBDIR' '@': | |||
|
16 | if not os.path.isabs(libdir): | |||
|
17 | libdir = os.path.join(os.path.dirname(__file__), libdir) | |||
|
18 | libdir = os.path.abspath(libdir) | |||
|
19 | sys.path.insert(0, libdir) | |||
|
20 | ||||
10 | # enable importing on demand to reduce startup time |
|
21 | # enable importing on demand to reduce startup time | |
11 | try: |
|
22 | try: | |
12 | from mercurial import demandimport; demandimport.enable() |
|
23 | from mercurial import demandimport; demandimport.enable() | |
@@ -17,7 +28,6 b' except ImportError:' | |||||
17 | sys.stderr.write("(check your install and PYTHONPATH)\n") |
|
28 | sys.stderr.write("(check your install and PYTHONPATH)\n") | |
18 | sys.exit(-1) |
|
29 | sys.exit(-1) | |
19 |
|
30 | |||
20 | import sys |
|
|||
21 | import mercurial.util |
|
31 | import mercurial.util | |
22 | import mercurial.dispatch |
|
32 | import mercurial.dispatch | |
23 |
|
33 |
@@ -52,6 +52,7 b' from distutils.dist import Distribution' | |||||
52 | from distutils.command.build import build |
|
52 | from distutils.command.build import build | |
53 | from distutils.command.build_ext import build_ext |
|
53 | from distutils.command.build_ext import build_ext | |
54 | from distutils.command.build_py import build_py |
|
54 | from distutils.command.build_py import build_py | |
|
55 | from distutils.command.install_scripts import install_scripts | |||
55 | from distutils.spawn import spawn, find_executable |
|
56 | from distutils.spawn import spawn, find_executable | |
56 | from distutils.ccompiler import new_compiler |
|
57 | from distutils.ccompiler import new_compiler | |
57 | from distutils.errors import CCompilerError |
|
58 | from distutils.errors import CCompilerError | |
@@ -216,6 +217,7 b' class hgbuildmo(build):' | |||||
216 | self.mkpath(join('mercurial', modir)) |
|
217 | self.mkpath(join('mercurial', modir)) | |
217 | self.make_file([pofile], mobuildfile, spawn, (cmd,)) |
|
218 | self.make_file([pofile], mobuildfile, spawn, (cmd,)) | |
218 |
|
219 | |||
|
220 | ||||
219 | # Insert hgbuildmo first so that files in mercurial/locale/ are found |
|
221 | # Insert hgbuildmo first so that files in mercurial/locale/ are found | |
220 | # when build_py is run next. |
|
222 | # when build_py is run next. | |
221 | build.sub_commands.insert(0, ('build_mo', None)) |
|
223 | build.sub_commands.insert(0, ('build_mo', None)) | |
@@ -260,9 +262,52 b' class hgbuildpy(build_py):' | |||||
260 | else: |
|
262 | else: | |
261 | yield module |
|
263 | yield module | |
262 |
|
264 | |||
|
265 | class hginstallscripts(install_scripts): | |||
|
266 | ''' | |||
|
267 | This is a specialization of install_scripts that replaces the @LIBDIR@ with | |||
|
268 | the configured directory for modules. If possible, the path is made relative | |||
|
269 | to the directory for scripts. | |||
|
270 | ''' | |||
|
271 | ||||
|
272 | def initialize_options(self): | |||
|
273 | install_scripts.initialize_options(self) | |||
|
274 | ||||
|
275 | self.install_lib = None | |||
|
276 | ||||
|
277 | def finalize_options(self): | |||
|
278 | install_scripts.finalize_options(self) | |||
|
279 | self.set_undefined_options('install', | |||
|
280 | ('install_lib', 'install_lib')) | |||
|
281 | ||||
|
282 | def run(self): | |||
|
283 | install_scripts.run(self) | |||
|
284 | ||||
|
285 | if (os.path.splitdrive(self.install_dir)[0] != | |||
|
286 | os.path.splitdrive(self.install_lib)[0]): | |||
|
287 | # can't make relative paths from one drive to another, so use an | |||
|
288 | # absolute path instead | |||
|
289 | libdir = self.install_lib | |||
|
290 | else: | |||
|
291 | common = os.path.commonprefix((self.install_dir, self.install_lib)) | |||
|
292 | rest = self.install_dir[len(common):] | |||
|
293 | uplevel = len([n for n in os.path.split(rest) if n]) | |||
|
294 | ||||
|
295 | libdir = uplevel * ('..' + os.sep) + self.install_lib[len(common):] | |||
|
296 | ||||
|
297 | for outfile in self.outfiles: | |||
|
298 | data = open(outfile, 'rb').read() | |||
|
299 | ||||
|
300 | # skip binary files | |||
|
301 | if '\0' in data: | |||
|
302 | continue | |||
|
303 | ||||
|
304 | data = data.replace('@LIBDIR@', libdir) | |||
|
305 | open(outfile, 'wb').write(data) | |||
|
306 | ||||
263 | cmdclass = {'build_mo': hgbuildmo, |
|
307 | cmdclass = {'build_mo': hgbuildmo, | |
264 | 'build_ext': hgbuildext, |
|
308 | 'build_ext': hgbuildext, | |
265 |
'build_py': hgbuildpy |
|
309 | 'build_py': hgbuildpy, | |
|
310 | 'install_scripts': hginstallscripts} | |||
266 |
|
311 | |||
267 | packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert', |
|
312 | packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert', | |
268 | 'hgext.highlight', 'hgext.zeroconf'] |
|
313 | 'hgext.highlight', 'hgext.zeroconf'] |
General Comments 0
You need to be logged in to leave comments.
Login now