diff options
-rwxr-xr-x | repo | 30 |
1 files changed, 2 insertions, 28 deletions
@@ -79,7 +79,7 @@ def check_python_version(): | |||
79 | major = ver.major | 79 | major = ver.major |
80 | minor = ver.minor | 80 | minor = ver.minor |
81 | 81 | ||
82 | # Try to re-exec the version specific Python 3 if needed. | 82 | # Try to re-exec the version specific Python if needed. |
83 | if (major, minor) < MIN_PYTHON_VERSION_SOFT: | 83 | if (major, minor) < MIN_PYTHON_VERSION_SOFT: |
84 | # Python makes releases ~once a year, so try our min version +10 to help | 84 | # Python makes releases ~once a year, so try our min version +10 to help |
85 | # bridge the gap. This is the fallback anyways so perf isn't critical. | 85 | # bridge the gap. This is the fallback anyways so perf isn't critical. |
@@ -96,36 +96,10 @@ def check_python_version(): | |||
96 | break | 96 | break |
97 | reexec(f"python{min_major}.{min_minor - inc}") | 97 | reexec(f"python{min_major}.{min_minor - inc}") |
98 | 98 | ||
99 | # Try the generic Python 3 wrapper, but only if it's new enough. If it | ||
100 | # isn't, we want to just give up below and make the user resolve things. | ||
101 | try: | ||
102 | proc = subprocess.Popen( | ||
103 | [ | ||
104 | "python3", | ||
105 | "-c", | ||
106 | "import sys; " | ||
107 | "print(sys.version_info.major, sys.version_info.minor)", | ||
108 | ], | ||
109 | stdout=subprocess.PIPE, | ||
110 | stderr=subprocess.PIPE, | ||
111 | ) | ||
112 | (output, _) = proc.communicate() | ||
113 | python3_ver = tuple(int(x) for x in output.decode("utf-8").split()) | ||
114 | except (OSError, subprocess.CalledProcessError): | ||
115 | python3_ver = None | ||
116 | |||
117 | # If the python3 version looks like it's new enough, give it a try. | ||
118 | if ( | ||
119 | python3_ver | ||
120 | and python3_ver >= MIN_PYTHON_VERSION_HARD | ||
121 | and python3_ver != (major, minor) | ||
122 | ): | ||
123 | reexec("python3") | ||
124 | |||
125 | # We're still here, so diagnose things for the user. | 99 | # We're still here, so diagnose things for the user. |
126 | if (major, minor) < MIN_PYTHON_VERSION_HARD: | 100 | if (major, minor) < MIN_PYTHON_VERSION_HARD: |
127 | print( | 101 | print( |
128 | "repo: error: Python 3 version is too old; " | 102 | "repo: error: Python version is too old; " |
129 | "Please use Python {}.{} or newer.".format( | 103 | "Please use Python {}.{} or newer.".format( |
130 | *MIN_PYTHON_VERSION_HARD | 104 | *MIN_PYTHON_VERSION_HARD |
131 | ), | 105 | ), |