diff --git a/python/setup.py.in b/python/setup.py.in index c28aaa1ee38a6216c701f3d279bdf6baabec4f55..4d3fd6a16b48b991a361a534ff50c86e7272dc18 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -370,11 +370,13 @@ class InstallHeaders(Command): if sys.platform != 'win32': @contextmanager def redirect_stdout(): - with open('${SETUP_LOG_FILE}', 'w') as f: - origin_stdout = sys.stdout - sys.stdout = f - yield - sys.stdout = origin_stdout + f_log = open('${SETUP_LOG_FILE}', 'w') + origin_stdout = sys.stdout + sys.stdout = f_log + yield + f_log = sys.stdout + sys.stdout = origin_stdout + f_log.close() else: @contextmanager def redirect_stdout():