From e343c9445c745f416ca2d41ba5195408a4131043 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Mon, 19 Oct 2020 13:04:03 +0200 Subject: [PATCH] Creating a temporary directory is not actually required While developing the previous PR (https://github.com/kovidgoyal/kitty/pull/3043), I was using more compiler command line arguments, one of which was `-MMD`. This caused the .d file to be created. Without this argument, there is no need to create a temporary directory. --- setup.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/setup.py b/setup.py index fed74687a..d09cad07f 100755 --- a/setup.py +++ b/setup.py @@ -13,7 +13,6 @@ import shutil import subprocess import sys import sysconfig -import tempfile import time from contextlib import suppress from functools import partial @@ -214,19 +213,18 @@ def get_sanitize_args(cc: str, ccver: Tuple[int, int]) -> List[str]: def test_compile(cc: str, *cflags: str, src: Optional[str] = None, lang: str = 'c') -> bool: src = src or 'int main(void) { return 0; }' - with tempfile.TemporaryDirectory() as tdir: - p = subprocess.Popen( - [cc] + list(cflags) + ['-x', lang, '-o', os.devnull, '-'], cwd=tdir, - stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, stdin=subprocess.PIPE, - ) - stdin = p.stdin - assert stdin is not None - try: - stdin.write(src.encode('utf-8')) - stdin.close() - except BrokenPipeError: - return False - return p.wait() == 0 + p = subprocess.Popen( + [cc] + list(cflags) + ['-x', lang, '-o', os.devnull, '-'], + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, stdin=subprocess.PIPE, + ) + stdin = p.stdin + assert stdin is not None + try: + stdin.write(src.encode('utf-8')) + stdin.close() + except BrokenPipeError: + return False + return p.wait() == 0 def first_successful_compile(cc: str, *cflags: str, src: Optional[str] = None, lang: str = 'c') -> str: