|
9 | 9 | if __name__ == '__main__': |
10 | 10 | import os |
11 | 11 | import sys |
| 12 | + import warnings |
| 13 | + from inspect import cleandoc |
| 14 | + |
| 15 | + major = sys.version_info.major |
| 16 | + minor = sys.version_info.minor |
12 | 17 |
|
13 | 18 | # If this is python2, check if python3 is available and re-execute with that |
14 | 19 | # interpreter. Only python3 allows downloading CI LLVM. |
15 | 20 | # |
16 | 21 | # This matters if someone's system `python` is python2. |
17 | | - if sys.version_info.major < 3: |
| 22 | + if major < 3: |
18 | 23 | try: |
19 | 24 | os.execvp("py", ["py", "-3"] + sys.argv) |
20 | 25 | except OSError: |
|
24 | 29 | # Python 3 isn't available, fall back to python 2 |
25 | 30 | pass |
26 | 31 |
|
| 32 | + # soft deprecation of old python versions |
| 33 | + skip_check = os.environ.get("RUST_IGNORE_OLD_PYTHON") == "1" |
| 34 | + if major < 3 or (major == 3 and minor < 6): |
| 35 | + msg = cleandoc(""" |
| 36 | + Using python {}.{} but >= 3.6 is recommended. Your python version |
| 37 | + should continue to work for the near future, but this will |
| 38 | + eventually change. If python >= 3.6 is not available on your system, |
| 39 | + please file an issue to help us understand timelines. |
| 40 | +
|
| 41 | + This message can be suppressed by setting `RUST_IGNORE_OLD_PYTHON=1` |
| 42 | + """.format(major, minor)) |
| 43 | + warnings.warn(msg) |
| 44 | + |
27 | 45 | rust_dir = os.path.dirname(os.path.abspath(__file__)) |
28 | 46 | # For the import below, have Python search in src/bootstrap first. |
29 | 47 | sys.path.insert(0, os.path.join(rust_dir, "src", "bootstrap")) |
|
0 commit comments