From 17139ce439c0c8bf2541f310c0fc5a6e9c3309e0 Mon Sep 17 00:00:00 2001 From: Toby Harradine Date: Tue, 18 Sep 2018 14:07:50 +1000 Subject: [PATCH] Fix compiler detection on Windows (#2136) Signed-off-by: Toby Harradine --- setup.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index c19b60fb5..adf5d4ae5 100644 --- a/setup.py +++ b/setup.py @@ -42,13 +42,12 @@ def check_compiler_available(): m = ccompiler.new_compiler() with tempfile.TemporaryDirectory() as tdir: - with tempfile.NamedTemporaryFile(prefix="dummy", suffix=".c", dir=tdir) as tfile: - tfile.write(b"int main(int argc, char** argv) {return 0;}") - tfile.seek(0) - try: - m.compile([tfile.name], output_dir=tdir) - except (CCompilerError, DistutilsPlatformError): - return False + with open(os.path.join(tdir, "dummy.c"), "w") as tfile: + tfile.write("int main(int argc, char** argv) {return 0;}") + try: + m.compile([tfile.name], output_dir=tdir) + except (CCompilerError, DistutilsPlatformError): + return False return True