From 83e59ae1f27c289be2da878c8ed051b89a84a001 Mon Sep 17 00:00:00 2001 From: Valentin Boussot Date: Thu, 20 Aug 2026 23:11:19 +0200 Subject: [PATCH] fix(itkwasm): support wasmtime 48 wasmtime 48.0.0 removes `DirPerms` and `FilePerms` and replaces the two `WasiConfig.preopen_dir` permission arguments with a single `fs_mutable` boolean, simplifying wasi-filesystem permissions to read-write or read-only (bytecodealliance/wasmtime#14010). Importing either enum raises ImportError, and because `pipeline` imports them at module scope, `import itkwasm` fails outright on wasmtime >= 48. Read-write is the default on both sides of that change: `preopen_dir` defaults to `dir_perms=DirPerms.READ_WRITE, file_perms=FilePerms.READ_WRITE` from 28.0.0 through 47.0.1, and to `fs_mutable=True` from 48.0.0. Passing neither argument therefore keeps the same permissions across the whole declared range and needs no version branching. `preopen_dir` is reached only by pipelines carrying a TextFile or BinaryFile interface, so verification uses one: on wasmtime 28.0.0, 47.0.1 and 48.0.0, `input-output-files-test.wasi.wasm` reads a text and a binary input from one preopened directory, writes both outputs into a second, and the bytes written to disk match the expected contents. --- packages/core/python/itkwasm/itkwasm/pipeline.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/core/python/itkwasm/itkwasm/pipeline.py b/packages/core/python/itkwasm/itkwasm/pipeline.py index 497270611..1f38a312d 100644 --- a/packages/core/python/itkwasm/itkwasm/pipeline.py +++ b/packages/core/python/itkwasm/itkwasm/pipeline.py @@ -46,8 +46,6 @@ WasiConfig, Linker, WasmtimeError, - DirPerms, - FilePerms ) # Get the value of the ITKWASM_CACHE_DIR environment variable @@ -86,7 +84,12 @@ def __init__( wasi_config.argv = args for preopen in preopen_directories: - wasi_config.preopen_dir(preopen, preopen, DirPerms.READ_WRITE, FilePerms.READ_WRITE) + # Read-write is the default on both sides of the wasmtime 48.0.0 + # signature change: `dir_perms=DirPerms.READ_WRITE, + # file_perms=FilePerms.READ_WRITE` up to 47.0.1, `fs_mutable=True` + # from 48.0.0, where the two enums were removed. Passing neither + # keeps read-write across the supported range. + wasi_config.preopen_dir(preopen, preopen) store.set_wasi(wasi_config)