Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions stencil_benchmarks/tools/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down