##// END OF EJS Templates
hg: add user-site to `sys.path` on Windows to allow pip-installed extensions...
Matt Harbison -
r46672:7740d510 default
parent child Browse files
Show More
@@ -1,43 +1,59 b''
1 #!/usr/bin/env python3
1 #!/usr/bin/env python3
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 from __future__ import absolute_import
9 from __future__ import absolute_import
10
10
11 import os
11 import os
12 import sys
12 import sys
13
13
14 libdir = '@LIBDIR@'
14 libdir = '@LIBDIR@'
15
15
16 if libdir != '@' 'LIBDIR' '@':
16 if libdir != '@' 'LIBDIR' '@':
17 if not os.path.isabs(libdir):
17 if not os.path.isabs(libdir):
18 libdir = os.path.join(
18 libdir = os.path.join(
19 os.path.dirname(os.path.realpath(__file__)), libdir
19 os.path.dirname(os.path.realpath(__file__)), libdir
20 )
20 )
21 libdir = os.path.abspath(libdir)
21 libdir = os.path.abspath(libdir)
22 sys.path.insert(0, libdir)
22 sys.path.insert(0, libdir)
23
23
24 # Make `pip install --user ...` packages available to the official Windows
25 # build. Most py2 packaging installs directly into the system python
26 # environment, so no changes are necessary for other platforms. The Windows
27 # py2 package uses py2exe, which lacks a `site` module. Hardcode it according
28 # to the documentation.
29 if getattr(sys, 'frozen', None) == 'console_exe':
30 vi = sys.version_info
31 sys.path.append(
32 os.path.join(
33 os.environ['APPDATA'],
34 'Python',
35 'Python%d%d' % (vi[0], vi[1]),
36 'site-packages',
37 )
38 )
39
24 from hgdemandimport import tracing
40 from hgdemandimport import tracing
25
41
26 with tracing.log('hg script'):
42 with tracing.log('hg script'):
27 # enable importing on demand to reduce startup time
43 # enable importing on demand to reduce startup time
28 try:
44 try:
29 if sys.version_info[0] < 3 or sys.version_info >= (3, 6):
45 if sys.version_info[0] < 3 or sys.version_info >= (3, 6):
30 import hgdemandimport
46 import hgdemandimport
31
47
32 hgdemandimport.enable()
48 hgdemandimport.enable()
33 except ImportError:
49 except ImportError:
34 sys.stderr.write(
50 sys.stderr.write(
35 "abort: couldn't find mercurial libraries in [%s]\n"
51 "abort: couldn't find mercurial libraries in [%s]\n"
36 % ' '.join(sys.path)
52 % ' '.join(sys.path)
37 )
53 )
38 sys.stderr.write("(check your install and PYTHONPATH)\n")
54 sys.stderr.write("(check your install and PYTHONPATH)\n")
39 sys.exit(-1)
55 sys.exit(-1)
40
56
41 from mercurial import dispatch
57 from mercurial import dispatch
42
58
43 dispatch.run()
59 dispatch.run()
General Comments 0
You need to be logged in to leave comments. Login now