Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
47.0.1
48.0.0
2 changes: 1 addition & 1 deletion ci/download-wasmtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# set to "dev" to download the latest or pick a tag from
# https://github.com/bytecodealliance/wasmtime/tags
WASMTIME_VERSION = "v47.0.0"
WASMTIME_VERSION = "v48.0.0"


def main(platform, arch):
Expand Down
8 changes: 4 additions & 4 deletions tests/component/test_linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def test_add_instance(self):
pass
with root.add_instance('y'):
pass
with self.assertRaises(WasmtimeError):
root.add_instance('x')
with self.assertRaises(WasmtimeError):
root.add_instance('y')
with root.add_instance('x'):
pass
with root.add_instance('y'):
pass
with root.add_instance('z'):
pass

Expand Down
4 changes: 2 additions & 2 deletions tests/test_wasi.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_config(self):
config.stdout_file = 'some-directory/without-a-rainbow'
with self.assertRaises(WasmtimeError):
config.stderr_file = 'some-directory/without-a-rainbow'
config.preopen_dir('wasmtime', 'other', DirPerms.READ_WRITE, FilePerms.READ_WRITE)
config.preopen_dir('wasmtime', 'other', True)
config.preopen_dir('wasmtime', 'other2')

def test_preview1(self):
Expand All @@ -51,7 +51,7 @@ def test_preview1(self):
def preopen_nonexistent(self):
config = WasiConfig()
with self.assertRaises(WasmtimeError):
config.preopen_dir('/path/to/nowhere', '/', DirPerms.READ_ONLY, FilePerms.READ_ONLY)
config.preopen_dir('/path/to/nowhere', '/', False)

def test_custom_print(self):
linker = Linker(Engine())
Expand Down
4 changes: 1 addition & 3 deletions wasmtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from ._table import Table
from ._memory import Memory
from ._instance import Instance
from ._wasi import WasiConfig, FilePerms, DirPerms
from ._wasi import WasiConfig
from ._linker import Linker
from ._tag import Tag
from ._instance_pre import InstancePre
Expand Down Expand Up @@ -62,8 +62,6 @@
'Module',
'Instance',
'WasiConfig',
'FilePerms',
'DirPerms',
'Linker',
'WasmtimeError',
'StoreContext',
Expand Down
16 changes: 3 additions & 13 deletions wasmtime/_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2055,23 +2055,13 @@ def wasi_config_inherit_stderr(config: Any) -> None:
def wasi_config_set_stderr_custom(config: Any, callback: Any, data: Any, finalizer: Any) -> None:
return _wasi_config_set_stderr_custom(config, callback, data, finalizer) # type: ignore

class wasi_dir_perms_flags(Enum):
WASMTIME_WASI_DIR_PERMS_READ = 1
WASMTIME_WASI_DIR_PERMS_WRITE = 2

wasi_dir_perms = ctypes.c_size_t

class wasi_file_perms_flags(Enum):
WASMTIME_WASI_FILE_PERMS_READ = 1
WASMTIME_WASI_FILE_PERMS_WRITE = 2

wasi_file_perms = ctypes.c_size_t

_wasi_config_preopen_dir = dll.wasi_config_preopen_dir
_wasi_config_preopen_dir.restype = ctypes.c_bool
_wasi_config_preopen_dir.argtypes = [ctypes.POINTER(wasi_config_t), ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.c_char), wasi_dir_perms, wasi_file_perms]
def wasi_config_preopen_dir(config: Any, host_path: Any, guest_path: Any, dir_perms: Any, file_perms: Any) -> bool:
return _wasi_config_preopen_dir(config, host_path, guest_path, dir_perms, file_perms) # type: ignore
_wasi_config_preopen_dir.argtypes = [ctypes.POINTER(wasi_config_t), ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.c_char), ctypes.c_bool]
def wasi_config_preopen_dir(config: Any, host_path: Any, guest_path: Any, fs_mutable: Any) -> bool:
return _wasi_config_preopen_dir(config, host_path, guest_path, fs_mutable) # type: ignore

wasmtime_storage_type_kind_t = ctypes.c_uint8

Expand Down
14 changes: 2 additions & 12 deletions wasmtime/_wasi.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ def _encode_path(path: Union[str, bytes, PathLike]) -> bytes:
return path2
return path2.encode('utf8')

class DirPerms(Enum):
READ_ONLY = ffi.wasi_dir_perms_flags.WASMTIME_WASI_DIR_PERMS_READ.value
WRITE_ONLY = ffi.wasi_dir_perms_flags.WASMTIME_WASI_DIR_PERMS_WRITE.value
READ_WRITE = ffi.wasi_dir_perms_flags.WASMTIME_WASI_DIR_PERMS_READ.value | ffi.wasi_dir_perms_flags.WASMTIME_WASI_DIR_PERMS_WRITE.value

class FilePerms(Enum):
READ_ONLY = ffi.wasi_file_perms_flags.WASMTIME_WASI_FILE_PERMS_READ.value
WRITE_ONLY = ffi.wasi_file_perms_flags.WASMTIME_WASI_FILE_PERMS_WRITE.value
READ_WRITE = ffi.wasi_file_perms_flags.WASMTIME_WASI_FILE_PERMS_READ.value | ffi.wasi_file_perms_flags.WASMTIME_WASI_FILE_PERMS_WRITE.value


CustomOutput = Callable[[bytes], Union[int, None]]
CUSTOM_OUTPUTS: Slab[CustomOutput] = Slab()
Expand Down Expand Up @@ -179,7 +169,7 @@ def inherit_stderr(self) -> None:
"""
ffi.wasi_config_inherit_stderr(self.ptr())

def preopen_dir(self, path: str, guest_path: str, dir_perms: DirPerms = DirPerms.READ_WRITE, file_perms: FilePerms = FilePerms.READ_WRITE) -> None:
def preopen_dir(self, path: str, guest_path: str, fs_mutable: bool = True) -> None:
"""
Allows the WASI program to access the directory at `path` using the
path `guest_path` within the WASI program.
Expand All @@ -193,7 +183,7 @@ def preopen_dir(self, path: str, guest_path: str, dir_perms: DirPerms = DirPerms
"""
path_ptr = c_char_p(path.encode('utf-8'))
guest_path_ptr = c_char_p(guest_path.encode('utf-8'))
if not ffi.wasi_config_preopen_dir(self.ptr(), path_ptr, guest_path_ptr, dir_perms.value, file_perms.value):
if not ffi.wasi_config_preopen_dir(self.ptr(), path_ptr, guest_path_ptr, fs_mutable):
raise WasmtimeError('failed to add preopen dir')


Expand Down
Loading