Instead of raising an exception on a failure the compileall.compile_dir
returns a boolean indicating if all files compiled successfully or not.
Fail the build.py script if byte compiling fails as that usually
indicates some sort of syntax error.
Fixes: https://tracker.ceph.com/issues/72850
Signed-off-by: John Mulligan <jmulligan@redhat.com>
def _compile(dest, tempdir):
"""Compile the zipapp."""
log.info("Byte-compiling py to pyc")
- compileall.compile_dir(
+ ok = compileall.compile_dir(
tempdir,
maxlevels=16,
legacy=True,
quiet=1,
workers=0,
)
+ if not ok:
+ log.error("compileall.compile_dir failed (see output for details)")
+ raise ValueError("byte-compile failed")
# TODO we could explicitly pass a python version here
log.info("Constructing the zipapp file")
try: