fusedwasi 0.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
fusedwasi-0.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: fusedwasi
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Header-only C host for the WASI Component Model, for core modules fused from components (wasm2c and other C hosts)
|
|
5
|
+
Author: o-murphy
|
|
6
|
+
Author-email: o-murphy <thehelixpg@gmail.com>
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# fusedwasi
|
|
11
|
+
|
|
12
|
+
Header-only C host for the WASI Component Model, for core modules fused from components (wasm2c and other C hosts), with a Python twin.
|
|
13
|
+
|
|
14
|
+
**Placeholder: nothing is released yet.** What follows is the idea and the shape of the API, taken from the code that is to move here (the WASI 0.2 host of `wasmext`: `c/p2/*.h` and `p2/*.py`).
|
|
15
|
+
|
|
16
|
+
## The idea
|
|
17
|
+
|
|
18
|
+
A tool such as `meld fuse` turns a composed component into **one core module**: a memory for each component, the adapters between them are plain wasm, and the imports are the flat core form of `wasi:*` functions. Such a module needs only a host that implements those imports. `fusedwasi` is that host and nothing else: no engine, no component parser, no canonical ABI between components (the fuse already built it in).
|
|
19
|
+
|
|
20
|
+
```mermaid
|
|
21
|
+
flowchart TB
|
|
22
|
+
subgraph build["1. Build"]
|
|
23
|
+
direction LR
|
|
24
|
+
C1["component A<br/>(any language)"] --> F["meld fuse<br/>(or unbundle)"]
|
|
25
|
+
C2["component B"] --> F
|
|
26
|
+
F --> M["one core module<br/>memory per component<br/>imports wasi:*@0.2"]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
subgraph run["2. Run"]
|
|
30
|
+
direction LR
|
|
31
|
+
H["C host (.h)<br/>wasmext, other C hosts"] --> FW
|
|
32
|
+
Y["Python host (.py)<br/>wasmhost"] --> FW
|
|
33
|
+
FW["fusedwasi<br/>state: handles, memories, hooks<br/>one function per import:<br/>cli · clocks · random · io · filesystem · sockets"]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
build -- "AOT: wasm2c · runtime: any engine" --> run
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**AOT and runtime.** The library asks the engine for two things only: the memory of each component (a base and a size) and a way to call a function for each import. So it does not matter how the module runs: compiled ahead of time to C with `wasm2c` (the C headers are included into the generated glue, nothing is needed at run time), or in an interpreter or a JIT that calls the same functions through its import table (the C headers from an embedder, the Python twin from a Python host). Only the AOT route has been run so far (wasmext, `wasm2c`); the runtime route follows from the interface and is not tested.
|
|
40
|
+
|
|
41
|
+
## The API (planned; the shape of the current code)
|
|
42
|
+
|
|
43
|
+
One state, one flat function per import, the same names and arguments in C and in Python. The host gives the state what it decides (arguments, preopened directories, which sockets are allowed, the standard streams, a trap); the rest is the library.
|
|
44
|
+
|
|
45
|
+
```c
|
|
46
|
+
#include "wasi_p2_cli.h" /* or wasi_p2_filesystem.h, wasi_p2_sockets.h, ... */
|
|
47
|
+
|
|
48
|
+
wasi_p2_state s;
|
|
49
|
+
wasi_p2_init(&s); /* defaults: system clocks, /dev/urandom, nothing allowed in sockets */
|
|
50
|
+
s.args = args, s.arg_count = 2;
|
|
51
|
+
s.realloc = my_cabi_realloc; /* the cabi_realloc of component `comp` */
|
|
52
|
+
s.trap = my_trap; /* in a wasm2c module: wasm_rt_trap */
|
|
53
|
+
wasi_p2_set_memory(&s, 0, base, size); /* once for each component; set again when the memory grows */
|
|
54
|
+
|
|
55
|
+
/* the body of an import of the module: the first argument is the component whose memory it is */
|
|
56
|
+
wasi_cli_environment_get_arguments(&s, /*comp*/ 0, /*retptr*/ ptr);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from fusedwasi import Host, wasi_p2_cli as cli # the module names follow the C headers
|
|
61
|
+
|
|
62
|
+
host = Host([memory], args=["prog"], realloc=my_cabi_realloc) # a memory is any writable buffer
|
|
63
|
+
cli.wasi_cli_environment_get_arguments(host, 0, ptr)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
| Part | What the host gives | What the library does |
|
|
67
|
+
|---|---|---|
|
|
68
|
+
| memory | a base and a size for each component | checked, little-endian loads and stores; a pointer outside is a trap |
|
|
69
|
+
| handles | nothing | the table of `own` and `borrow` (generation + index), `[resource-drop]` |
|
|
70
|
+
| lists and strings it returns | `realloc` (the `cabi_realloc` of the component) | placing them in the guest's memory |
|
|
71
|
+
| files | the preopened directories (`path`, `name`, `writable`) | paths confined below the preopen (POSIX) |
|
|
72
|
+
| sockets | `socket_addr_check`, `allow_ip_name_lookup`; refused by default | TCP, UDP, name lookup (POSIX) |
|
|
73
|
+
| time, random, exit, wait | a hook, or the system's own | the rest |
|
|
74
|
+
|
|
75
|
+
Every function is `static inline` and nothing is global or thread-local, so a module links only what it imports and several instances can live in a process.
|
|
76
|
+
|
|
77
|
+
## Who uses it
|
|
78
|
+
|
|
79
|
+
- **wasmext** (C, through `wasm2c`): the glue of a module includes the headers; no Python at run time.
|
|
80
|
+
- **wasmhost** (Python): the twin in `.py` under the engines it supports.
|
|
81
|
+
- **Any other host** that can give a memory and call a function for each import.
|
|
82
|
+
|
|
83
|
+
## Not here
|
|
84
|
+
|
|
85
|
+
Components made of components (the fuse does that), WASI 0.3 and async, an engine, a parser of WIT.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# fusedwasi
|
|
2
|
+
|
|
3
|
+
Header-only C host for the WASI Component Model, for core modules fused from components (wasm2c and other C hosts), with a Python twin.
|
|
4
|
+
|
|
5
|
+
**Placeholder: nothing is released yet.** What follows is the idea and the shape of the API, taken from the code that is to move here (the WASI 0.2 host of `wasmext`: `c/p2/*.h` and `p2/*.py`).
|
|
6
|
+
|
|
7
|
+
## The idea
|
|
8
|
+
|
|
9
|
+
A tool such as `meld fuse` turns a composed component into **one core module**: a memory for each component, the adapters between them are plain wasm, and the imports are the flat core form of `wasi:*` functions. Such a module needs only a host that implements those imports. `fusedwasi` is that host and nothing else: no engine, no component parser, no canonical ABI between components (the fuse already built it in).
|
|
10
|
+
|
|
11
|
+
```mermaid
|
|
12
|
+
flowchart TB
|
|
13
|
+
subgraph build["1. Build"]
|
|
14
|
+
direction LR
|
|
15
|
+
C1["component A<br/>(any language)"] --> F["meld fuse<br/>(or unbundle)"]
|
|
16
|
+
C2["component B"] --> F
|
|
17
|
+
F --> M["one core module<br/>memory per component<br/>imports wasi:*@0.2"]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
subgraph run["2. Run"]
|
|
21
|
+
direction LR
|
|
22
|
+
H["C host (.h)<br/>wasmext, other C hosts"] --> FW
|
|
23
|
+
Y["Python host (.py)<br/>wasmhost"] --> FW
|
|
24
|
+
FW["fusedwasi<br/>state: handles, memories, hooks<br/>one function per import:<br/>cli · clocks · random · io · filesystem · sockets"]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
build -- "AOT: wasm2c · runtime: any engine" --> run
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**AOT and runtime.** The library asks the engine for two things only: the memory of each component (a base and a size) and a way to call a function for each import. So it does not matter how the module runs: compiled ahead of time to C with `wasm2c` (the C headers are included into the generated glue, nothing is needed at run time), or in an interpreter or a JIT that calls the same functions through its import table (the C headers from an embedder, the Python twin from a Python host). Only the AOT route has been run so far (wasmext, `wasm2c`); the runtime route follows from the interface and is not tested.
|
|
31
|
+
|
|
32
|
+
## The API (planned; the shape of the current code)
|
|
33
|
+
|
|
34
|
+
One state, one flat function per import, the same names and arguments in C and in Python. The host gives the state what it decides (arguments, preopened directories, which sockets are allowed, the standard streams, a trap); the rest is the library.
|
|
35
|
+
|
|
36
|
+
```c
|
|
37
|
+
#include "wasi_p2_cli.h" /* or wasi_p2_filesystem.h, wasi_p2_sockets.h, ... */
|
|
38
|
+
|
|
39
|
+
wasi_p2_state s;
|
|
40
|
+
wasi_p2_init(&s); /* defaults: system clocks, /dev/urandom, nothing allowed in sockets */
|
|
41
|
+
s.args = args, s.arg_count = 2;
|
|
42
|
+
s.realloc = my_cabi_realloc; /* the cabi_realloc of component `comp` */
|
|
43
|
+
s.trap = my_trap; /* in a wasm2c module: wasm_rt_trap */
|
|
44
|
+
wasi_p2_set_memory(&s, 0, base, size); /* once for each component; set again when the memory grows */
|
|
45
|
+
|
|
46
|
+
/* the body of an import of the module: the first argument is the component whose memory it is */
|
|
47
|
+
wasi_cli_environment_get_arguments(&s, /*comp*/ 0, /*retptr*/ ptr);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from fusedwasi import Host, wasi_p2_cli as cli # the module names follow the C headers
|
|
52
|
+
|
|
53
|
+
host = Host([memory], args=["prog"], realloc=my_cabi_realloc) # a memory is any writable buffer
|
|
54
|
+
cli.wasi_cli_environment_get_arguments(host, 0, ptr)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
| Part | What the host gives | What the library does |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| memory | a base and a size for each component | checked, little-endian loads and stores; a pointer outside is a trap |
|
|
60
|
+
| handles | nothing | the table of `own` and `borrow` (generation + index), `[resource-drop]` |
|
|
61
|
+
| lists and strings it returns | `realloc` (the `cabi_realloc` of the component) | placing them in the guest's memory |
|
|
62
|
+
| files | the preopened directories (`path`, `name`, `writable`) | paths confined below the preopen (POSIX) |
|
|
63
|
+
| sockets | `socket_addr_check`, `allow_ip_name_lookup`; refused by default | TCP, UDP, name lookup (POSIX) |
|
|
64
|
+
| time, random, exit, wait | a hook, or the system's own | the rest |
|
|
65
|
+
|
|
66
|
+
Every function is `static inline` and nothing is global or thread-local, so a module links only what it imports and several instances can live in a process.
|
|
67
|
+
|
|
68
|
+
## Who uses it
|
|
69
|
+
|
|
70
|
+
- **wasmext** (C, through `wasm2c`): the glue of a module includes the headers; no Python at run time.
|
|
71
|
+
- **wasmhost** (Python): the twin in `.py` under the engines it supports.
|
|
72
|
+
- **Any other host** that can give a memory and call a function for each import.
|
|
73
|
+
|
|
74
|
+
## Not here
|
|
75
|
+
|
|
76
|
+
Components made of components (the fuse does that), WASI 0.3 and async, an engine, a parser of WIT.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "fusedwasi"
|
|
3
|
+
version = "0.0.0"
|
|
4
|
+
description = "Header-only C host for the WASI Component Model, for core modules fused from components (wasm2c and other C hosts)"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
dependencies = []
|
|
8
|
+
|
|
9
|
+
[[project.authors]]
|
|
10
|
+
name = "o-murphy"
|
|
11
|
+
email = "thehelixpg@gmail.com"
|
|
12
|
+
|
|
13
|
+
[build-system]
|
|
14
|
+
requires = ["uv_build>=0.13.1,<0.14.0"]
|
|
15
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "fusedwasi"
|
|
3
|
+
version = "0.0.0"
|
|
4
|
+
description = "Header-only C host for the WASI Component Model, for core modules fused from components (wasm2c and other C hosts)"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [{ name = "o-murphy", email = "thehelixpg@gmail.com" }]
|
|
7
|
+
requires-python = ">=3.10"
|
|
8
|
+
dependencies = []
|
|
9
|
+
|
|
10
|
+
[build-system]
|
|
11
|
+
requires = ["uv_build>=0.13.1,<0.14.0"]
|
|
12
|
+
build-backend = "uv_build"
|