##// END OF EJS Templates
setup/hg: handle hg being a symlink when appending relative libdir to sys.path...
L. David Baron -
r12805:cae1c187 stable
parent child Browse files
Show More
@@ -1,37 +1,38 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 #
2 #
3 # mercurial - scalable distributed SCM
3 # mercurial - scalable distributed SCM
4 #
4 #
5 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
5 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
6 #
6 #
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
10 import os
11 import sys
11 import sys
12
12
13 libdir = '@LIBDIR@'
13 libdir = '@LIBDIR@'
14
14
15 if libdir != '@' 'LIBDIR' '@':
15 if libdir != '@' 'LIBDIR' '@':
16 if not os.path.isabs(libdir):
16 if not os.path.isabs(libdir):
17 libdir = os.path.join(os.path.dirname(__file__), libdir)
17 libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
18 libdir)
18 libdir = os.path.abspath(libdir)
19 libdir = os.path.abspath(libdir)
19 sys.path.insert(0, libdir)
20 sys.path.insert(0, libdir)
20
21
21 # enable importing on demand to reduce startup time
22 # enable importing on demand to reduce startup time
22 try:
23 try:
23 from mercurial import demandimport; demandimport.enable()
24 from mercurial import demandimport; demandimport.enable()
24 except ImportError:
25 except ImportError:
25 import sys
26 import sys
26 sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
27 sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
27 ' '.join(sys.path))
28 ' '.join(sys.path))
28 sys.stderr.write("(check your install and PYTHONPATH)\n")
29 sys.stderr.write("(check your install and PYTHONPATH)\n")
29 sys.exit(-1)
30 sys.exit(-1)
30
31
31 import mercurial.util
32 import mercurial.util
32 import mercurial.dispatch
33 import mercurial.dispatch
33
34
34 for fp in (sys.stdin, sys.stdout, sys.stderr):
35 for fp in (sys.stdin, sys.stdout, sys.stderr):
35 mercurial.util.set_binary(fp)
36 mercurial.util.set_binary(fp)
36
37
37 mercurial.dispatch.run()
38 mercurial.dispatch.run()
General Comments 0
You need to be logged in to leave comments. Login now