From 48a7d699462aed4dbddde8151815fdf7d2f3ab9b Mon Sep 17 00:00:00 2001 From: "davidriazati@fb.com" Date: Wed, 14 Apr 2021 13:03:55 -0700 Subject: [PATCH] Catch and ignore tracebacks for compilation errors (#55986) Summary: The Python traceback on a cmake invocation is meaningless to most developers, so this PR wraps it in a `try..catch` so we can ignore it and save scrolling through the 20-or-so lines. Pull Request resolved: https://github.com/pytorch/pytorch/pull/55986 Pulled By: driazati Reviewed By: wanchaol Differential Revision: D27769304 fbshipit-source-id: 5889eea03db098d10576290abeeb4600029fb3f2 --- tools/setup_helpers/cmake.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/setup_helpers/cmake.py b/tools/setup_helpers/cmake.py index f1809552cd4..61d548149f5 100644 --- a/tools/setup_helpers/cmake.py +++ b/tools/setup_helpers/cmake.py @@ -5,7 +5,7 @@ import multiprocessing import os import re -from subprocess import check_call, check_output +from subprocess import check_call, check_output, CalledProcessError import sys import distutils.sysconfig from distutils.version import LooseVersion @@ -137,7 +137,13 @@ class CMake: command = [self._cmake_command] + args print(' '.join(command)) - check_call(command, cwd=self.build_dir, env=env) + try: + check_call(command, cwd=self.build_dir, env=env) + except (CalledProcessError, KeyboardInterrupt) as e: + # This error indicates that there was a problem with cmake, the + # Python backtrace adds no signal here so skip over it by catching + # the error and exiting manually + sys.exit(1) @staticmethod def defines(args, **kwargs):