Show More
@@ -7,6 +7,17 b'' | |||
|
7 | 7 | # This software may be used and distributed according to the terms of the |
|
8 | 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 | 21 | # enable importing on demand to reduce startup time |
|
11 | 22 | try: |
|
12 | 23 | from mercurial import demandimport; demandimport.enable() |
@@ -17,7 +28,6 b' except ImportError:' | |||
|
17 | 28 | sys.stderr.write("(check your install and PYTHONPATH)\n") |
|
18 | 29 | sys.exit(-1) |
|
19 | 30 | |
|
20 | import sys | |
|
21 | 31 | import mercurial.util |
|
22 | 32 | import mercurial.dispatch |
|
23 | 33 |
@@ -52,6 +52,7 b' from distutils.dist import Distribution' | |||
|
52 | 52 | from distutils.command.build import build |
|
53 | 53 | from distutils.command.build_ext import build_ext |
|
54 | 54 | from distutils.command.build_py import build_py |
|
55 | from distutils.command.install_scripts import install_scripts | |
|
55 | 56 | from distutils.spawn import spawn, find_executable |
|
56 | 57 | from distutils.ccompiler import new_compiler |
|
57 | 58 | from distutils.errors import CCompilerError |
@@ -216,6 +217,7 b' class hgbuildmo(build):' | |||
|
216 | 217 | self.mkpath(join('mercurial', modir)) |
|
217 | 218 | self.make_file([pofile], mobuildfile, spawn, (cmd,)) |
|
218 | 219 | |
|
220 | ||
|
219 | 221 | # Insert hgbuildmo first so that files in mercurial/locale/ are found |
|
220 | 222 | # when build_py is run next. |
|
221 | 223 | build.sub_commands.insert(0, ('build_mo', None)) |
@@ -260,9 +262,52 b' class hgbuildpy(build_py):' | |||
|
260 | 262 | else: |
|
261 | 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 | 307 | cmdclass = {'build_mo': hgbuildmo, |
|
264 | 308 | 'build_ext': hgbuildext, |
|
265 |
'build_py': hgbuildpy |
|
|
309 | 'build_py': hgbuildpy, | |
|
310 | 'install_scripts': hginstallscripts} | |
|
266 | 311 | |
|
267 | 312 | packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert', |
|
268 | 313 | 'hgext.highlight', 'hgext.zeroconf'] |
General Comments 0
You need to be logged in to leave comments.
Login now