]> git.proxmox.com Git - rustc.git/blame - x.py
Merge tag 'debian/1.72.1+dfsg1-1_exp1' into proxmox/bookworm
[rustc.git] / x.py
CommitLineData
f2b60f7d
FG
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.
32a655c1 4
7cac9316 5# This file is only a "symlink" to bootstrap.py, all logic should go there.
8bb4bdeb 6
49aad941
FG
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
fe692bf9
FG
12 import warnings
13 from inspect import cleandoc
14
15 major = sys.version_info.major
16 minor = sys.version_info.minor
5869c6ff 17
49aad941
FG
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.
fe692bf9 22 if major < 3:
5869c6ff 23 try:
49aad941 24 os.execvp("py", ["py", "-3"] + sys.argv)
5869c6ff 25 except OSError:
49aad941
FG
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
5869c6ff 31
fe692bf9
FG
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)
44
49aad941
FG
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"))
32a655c1 48
49aad941
FG
49 import bootstrap
50 bootstrap.main()