|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
| 3 | +import contextlib |
3 | 4 | import subprocess
|
4 | 5 | import sys
|
5 | 6 | import textwrap
|
@@ -133,26 +134,33 @@ def check_all_python_exist(
|
133 | 134 | *, platform_configs: Iterable[PythonConfiguration], container: OCIContainer
|
134 | 135 | ) -> None:
|
135 | 136 | exist = True
|
136 |
| - has_manylinux_interpreters = True |
| 137 | + has_manylinux_interpreters = False |
137 | 138 | messages = []
|
138 | 139 |
|
139 |
| - try: |
| 140 | + with contextlib.suppress(subprocess.CalledProcessError): |
140 | 141 | # use capture_output to keep quiet
|
141 | 142 | container.call(["manylinux-interpreters", "--help"], capture_output=True)
|
142 |
| - except subprocess.CalledProcessError: |
143 |
| - has_manylinux_interpreters = False |
| 143 | + has_manylinux_interpreters = True |
144 | 144 |
|
145 | 145 | for config in platform_configs:
|
146 | 146 | python_path = config.path / "bin" / "python"
|
147 |
| - try: |
148 |
| - if has_manylinux_interpreters: |
| 147 | + if has_manylinux_interpreters: |
| 148 | + try: |
149 | 149 | container.call(["manylinux-interpreters", "ensure", config.path.name])
|
150 |
| - container.call(["test", "-x", python_path]) |
151 |
| - except subprocess.CalledProcessError: |
152 |
| - messages.append( |
153 |
| - f" '{python_path}' executable doesn't exist in image '{container.image}' to build '{config.identifier}'." |
154 |
| - ) |
155 |
| - exist = False |
| 150 | + except subprocess.CalledProcessError: |
| 151 | + messages.append( |
| 152 | + f" 'manylinux-interpreters ensure {config.path.name}' needed to build '{config.identifier}' failed in container running image '{container.image}'." |
| 153 | + " Either the installation failed or this interpreter is not available in that image. Please check the logs." |
| 154 | + ) |
| 155 | + exist = False |
| 156 | + else: |
| 157 | + try: |
| 158 | + container.call(["test", "-x", python_path]) |
| 159 | + except subprocess.CalledProcessError: |
| 160 | + messages.append( |
| 161 | + f" '{python_path}' executable doesn't exist in image '{container.image}' to build '{config.identifier}'." |
| 162 | + ) |
| 163 | + exist = False |
156 | 164 | if not exist:
|
157 | 165 | message = "\n".join(messages)
|
158 | 166 | raise errors.FatalError(message)
|
|
0 commit comments