fix: error message when manylinux-interpreters ensure ... failed (#2066)
* review: address review comments from #1630 * fix: error message when `manylinux-interpreters ensure ...` failed * fix: error message when `manylinux-interpreters ensure ...` failed (option b)
This commit is contained in:
+20
-12
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import contextlib
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
@@ -133,26 +134,33 @@ def check_all_python_exist(
|
|||||||
*, platform_configs: Iterable[PythonConfiguration], container: OCIContainer
|
*, platform_configs: Iterable[PythonConfiguration], container: OCIContainer
|
||||||
) -> None:
|
) -> None:
|
||||||
exist = True
|
exist = True
|
||||||
has_manylinux_interpreters = True
|
has_manylinux_interpreters = False
|
||||||
messages = []
|
messages = []
|
||||||
|
|
||||||
try:
|
with contextlib.suppress(subprocess.CalledProcessError):
|
||||||
# use capture_output to keep quiet
|
# use capture_output to keep quiet
|
||||||
container.call(["manylinux-interpreters", "--help"], capture_output=True)
|
container.call(["manylinux-interpreters", "--help"], capture_output=True)
|
||||||
except subprocess.CalledProcessError:
|
has_manylinux_interpreters = True
|
||||||
has_manylinux_interpreters = False
|
|
||||||
|
|
||||||
for config in platform_configs:
|
for config in platform_configs:
|
||||||
python_path = config.path / "bin" / "python"
|
python_path = config.path / "bin" / "python"
|
||||||
try:
|
if has_manylinux_interpreters:
|
||||||
if has_manylinux_interpreters:
|
try:
|
||||||
container.call(["manylinux-interpreters", "ensure", config.path.name])
|
container.call(["manylinux-interpreters", "ensure", config.path.name])
|
||||||
container.call(["test", "-x", python_path])
|
except subprocess.CalledProcessError:
|
||||||
except subprocess.CalledProcessError:
|
messages.append(
|
||||||
messages.append(
|
f" 'manylinux-interpreters ensure {config.path.name}' needed to build '{config.identifier}' failed in container running image '{container.image}'."
|
||||||
f" '{python_path}' executable doesn't exist in image '{container.image}' to build '{config.identifier}'."
|
" Either the installation failed or this interpreter is not available in that image. Please check the logs."
|
||||||
)
|
)
|
||||||
exist = False
|
exist = False
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
container.call(["test", "-x", python_path])
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
messages.append(
|
||||||
|
f" '{python_path}' executable doesn't exist in image '{container.image}' to build '{config.identifier}'."
|
||||||
|
)
|
||||||
|
exist = False
|
||||||
if not exist:
|
if not exist:
|
||||||
message = "\n".join(messages)
|
message = "\n".join(messages)
|
||||||
raise errors.FatalError(message)
|
raise errors.FatalError(message)
|
||||||
|
|||||||
Reference in New Issue
Block a user