diff --git a/stencil_benchmarks/tools/compilation.py b/stencil_benchmarks/tools/compilation.py index d098e79..cf671f5 100644 --- a/stencil_benchmarks/tools/compilation.py +++ b/stencil_benchmarks/tools/compilation.py @@ -136,21 +136,21 @@ def __init__( srcfile.write(code.encode()) srcfile.flush() - with tempfile.NamedTemporaryFile(suffix=".so") as library: - result = subprocess.run( - [compile_command[0], "-o", library.name, srcfile.name] - + compile_command[1:], - capture_output=True, + library_name = pathlib.Path(srcfile.name).with_suffix(".so") + result = subprocess.run( + [compile_command[0], "-o", library_name, srcfile.name] + + compile_command[1:], + capture_output=True, + ) + if result.returncode != 0: + raise CompilationError(result.stderr.decode()) + if result.stdout or result.stderr: + warnings.warn( + "unexpected compilation output: " + + result.stdout.decode() + + result.stderr.decode() ) - if result.returncode != 0: - raise CompilationError(result.stderr.decode()) - if result.stdout or result.stderr: - warnings.warn( - "unexpected compilation output: " - + result.stdout.decode() - + result.stderr.decode() - ) - self._library = ctypes.cdll.LoadLibrary(library.name) + self._library = ctypes.cdll.LoadLibrary(library_name) def __getattr__(self, attr: str) -> Callable[[Any], str]: """Access library function by name.