fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
1.9 KiB50 linesraw
1#!/usr/bin/env python3
2# Some systems don't have `python3` in their PATH. This isn't supported by x.py directly;
3# they should use `x` or `x.ps1` instead.
4
5# This file is only a "symlink" to bootstrap.py, all logic should go there.
6
7# Parts of `bootstrap.py` use the `multiprocessing` module, so this entry point
8# must use the normal `if __name__ == '__main__':` convention to avoid problems.
9if __name__ == '__main__':
10    import os
11    import sys
12    import warnings
13    from inspect import cleandoc
14
15    major = sys.version_info.major
16    minor = sys.version_info.minor
17
18    # If this is python2, check if python3 is available and re-execute with that
19    # interpreter. Only python3 allows downloading CI LLVM.
20    #
21    # This matters if someone's system `python` is python2.
22    if major < 3:
23        try:
24            os.execvp("py", ["py", "-3"] + sys.argv)
25        except OSError:
26            try:
27                os.execvp("python3", ["python3"] + sys.argv)
28            except OSError:
29                # Python 3 isn't available, fall back to python 2
30                pass
31
32    # soft deprecation of old python versions
33    skip_check = os.environ.get("RUST_IGNORE_OLD_PYTHON") == "1"
34    if not skip_check and (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, stacklevel=1)
44
45    rust_dir = os.path.dirname(os.path.abspath(__file__))
46    # For the import below, have Python search in src/bootstrap first.
47    sys.path.insert(0, os.path.join(rust_dir, "src", "bootstrap"))
48
49    import bootstrap
50    bootstrap.main()