Skip to content

Commit cec95d7

Browse files
committed
Add deprecation warning for python <3.6 in x.py
Soft deprecate old python versions to give users a warning that eventually it may not be supported.
1 parent 397641f commit cec95d7

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

x.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
if __name__ == '__main__':
1010
import os
1111
import sys
12+
import warnings
13+
from inspect import cleandoc
14+
15+
major = sys.version_info.major
16+
minor = sys.version_info.minor
1217

1318
# If this is python2, check if python3 is available and re-execute with that
1419
# interpreter. Only python3 allows downloading CI LLVM.
1520
#
1621
# This matters if someone's system `python` is python2.
17-
if sys.version_info.major < 3:
22+
if major < 3:
1823
try:
1924
os.execvp("py", ["py", "-3"] + sys.argv)
2025
except OSError:
@@ -24,6 +29,19 @@
2429
# Python 3 isn't available, fall back to python 2
2530
pass
2631

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+
2745
rust_dir = os.path.dirname(os.path.abspath(__file__))
2846
# For the import below, have Python search in src/bootstrap first.
2947
sys.path.insert(0, os.path.join(rust_dir, "src", "bootstrap"))

0 commit comments

Comments
 (0)