22 '!=3.6.0', |
22 '!=3.6.0', |
23 '!=3.6.1', |
23 '!=3.6.1', |
24 ]) |
24 ]) |
25 |
25 |
26 import sys, platform |
26 import sys, platform |
27 if sys.version_info < (2, 7, 0, 'final'): |
|
28 raise SystemExit('Mercurial requires Python 2.7 or later.') |
|
29 |
|
30 if sys.version_info[0] >= 3: |
27 if sys.version_info[0] >= 3: |
31 printf = eval('print') |
28 printf = eval('print') |
32 libdir_escape = 'unicode_escape' |
29 libdir_escape = 'unicode_escape' |
33 else: |
30 else: |
34 libdir_escape = 'string_escape' |
31 libdir_escape = 'string_escape' |
35 def printf(*args, **kwargs): |
32 def printf(*args, **kwargs): |
36 f = kwargs.get('file', sys.stdout) |
33 f = kwargs.get('file', sys.stdout) |
37 end = kwargs.get('end', '\n') |
34 end = kwargs.get('end', '\n') |
38 f.write(b' '.join(args) + end) |
35 f.write(b' '.join(args) + end) |
|
36 |
|
37 # Attempt to guide users to a modern pip - this means that 2.6 users |
|
38 # should have a chance of getting a 4.2 release, and when we ratchet |
|
39 # the version requirement forward again hopefully everyone will get |
|
40 # something that works for them. |
|
41 if sys.version_info < (2, 7, 0, 'final'): |
|
42 pip_message = ('This may be due to an out of date pip. ' |
|
43 'Make sure you have pip >= 9.0.1.') |
|
44 try: |
|
45 import pip |
|
46 pip_version = tuple([int(x) for x in pip.__version__.split('.')[:3]]) |
|
47 if pip_version < (9, 0, 1) : |
|
48 pip_message = ( |
|
49 'Your pip version is out of date, please install ' |
|
50 'pip >= 9.0.1. pip {} detected.'.format(pip.__version__)) |
|
51 else: |
|
52 # pip is new enough - it must be something else |
|
53 pip_message = '' |
|
54 except Exception: |
|
55 pass |
|
56 error = """ |
|
57 Mercurial does not support Python older than 2.7. |
|
58 Python {py} detected. |
|
59 {pip} |
|
60 """.format(py=sys.version_info, pip=pip_message) |
|
61 printf(error, file=sys.stderr) |
|
62 sys.exit(1) |
39 |
63 |
40 # Solaris Python packaging brain damage |
64 # Solaris Python packaging brain damage |
41 try: |
65 try: |
42 import hashlib |
66 import hashlib |
43 sha = hashlib.sha1() |
67 sha = hashlib.sha1() |