mirror of https://github.com/pyodide/pyodide.git
FIX on buildall fail, print info after exiting rich context (#4441)
Otherwise the rich Live context will sometimes overwrite part of the failure message.
This commit is contained in:
parent
5a3f10fa59
commit
5da4725830
|
@ -42,8 +42,9 @@ from .pywasmcross import BuildArgs
|
|||
|
||||
|
||||
class BuildError(Exception):
|
||||
def __init__(self, returncode: int) -> None:
|
||||
def __init__(self, returncode: int, msg: str) -> None:
|
||||
self.returncode = returncode
|
||||
self.msg = msg
|
||||
super().__init__()
|
||||
|
||||
|
||||
|
@ -164,14 +165,15 @@ class Package(BasePackage):
|
|||
)
|
||||
|
||||
if p.returncode != 0:
|
||||
logger.error(f"Error building {self.name}. Printing build logs.")
|
||||
msg = []
|
||||
msg.append(f"Error building {self.name}. Printing build logs.")
|
||||
logfile = self.pkgdir / "build.log"
|
||||
if logfile.is_file():
|
||||
logger.error(logfile.read_text(encoding="utf-8"))
|
||||
msg.append(logfile.read_text(encoding="utf-8") + "\n")
|
||||
else:
|
||||
logger.error("ERROR: No build log found.")
|
||||
logger.error("ERROR: cancelling buildall")
|
||||
raise BuildError(p.returncode)
|
||||
msg.append("ERROR: No build log found.")
|
||||
msg.append(f"ERROR: cancelling buildall due to error building {self.name}")
|
||||
raise BuildError(p.returncode, "\n".join(msg))
|
||||
|
||||
|
||||
class PackageStatus:
|
||||
|
@ -556,7 +558,7 @@ def build_from_graph(
|
|||
if len(pkg.unbuilt_host_dependencies) == 0:
|
||||
build_queue.put((job_priority(pkg), pkg))
|
||||
|
||||
built_queue: Queue[BasePackage | Exception] = Queue()
|
||||
built_queue: Queue[BasePackage | BaseException] = Queue()
|
||||
thread_lock = Lock()
|
||||
queue_idx = 1
|
||||
building_rust_pkg = False
|
||||
|
@ -618,27 +620,27 @@ def build_from_graph(
|
|||
Thread(target=builder, args=(n + 1,), daemon=True).start()
|
||||
|
||||
num_built = len(already_built)
|
||||
with Live(progress_formatter, console=console_stdout):
|
||||
while num_built < len(pkg_map):
|
||||
match built_queue.get():
|
||||
case BuildError() as err:
|
||||
raise SystemExit(err.returncode)
|
||||
case Exception() as err:
|
||||
raise err
|
||||
case a_package:
|
||||
# MyPy should understand that this is a BasePackage
|
||||
assert not isinstance(a_package, Exception)
|
||||
pkg = a_package
|
||||
try:
|
||||
with Live(progress_formatter, console=console_stdout):
|
||||
while num_built < len(pkg_map):
|
||||
match built_queue.get():
|
||||
case BaseException() as err:
|
||||
raise err
|
||||
case BasePackage() as pkg:
|
||||
pass
|
||||
|
||||
num_built += 1
|
||||
num_built += 1
|
||||
|
||||
progress_formatter.update_progress_bar()
|
||||
progress_formatter.update_progress_bar()
|
||||
|
||||
for _dependent in pkg.host_dependents:
|
||||
dependent = pkg_map[_dependent]
|
||||
dependent.unbuilt_host_dependencies.remove(pkg.name)
|
||||
if len(dependent.unbuilt_host_dependencies) == 0:
|
||||
build_queue.put((job_priority(dependent), dependent))
|
||||
for _dependent in pkg.host_dependents:
|
||||
dependent = pkg_map[_dependent]
|
||||
dependent.unbuilt_host_dependencies.remove(pkg.name)
|
||||
if len(dependent.unbuilt_host_dependencies) == 0:
|
||||
build_queue.put((job_priority(dependent), dependent))
|
||||
except BuildError as err:
|
||||
logger.error(err.msg)
|
||||
sys.exit(err.returncode)
|
||||
|
||||
|
||||
def generate_packagedata(
|
||||
|
|
Loading…
Reference in New Issue