Skip to content

Commit ccf7e2e

Browse files
committed
Cut down component section of README
Don't mention the old `wasmtime.bindgen` support
1 parent 1c05889 commit ccf7e2e

File tree

1 file changed

+5
-81
lines changed

1 file changed

+5
-81
lines changed

README.md

Lines changed: 5 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -93,87 +93,11 @@ print(your_wasm_file.run())
9393

9494
## Components
9595

96-
The `wasmtime` package has initial support for running WebAssembly components in
97-
Python with high-level bindings. WebAssembly components are defined by the
98-
[component model] and are a flagship feature under development for Wasmtime and
99-
its bindings. Components enable communication between the host and WebAssembly
100-
guests with richer types than the numerical primitives supported by core
101-
WebAssembly. For example with a component Python can pass a string to wasm and
102-
back.
103-
104-
Components are represented as `*.wasm` binaries in the same manner as core
105-
WebAssembly modules. With a component binary you can generate Python bindings
106-
with:
107-
108-
```sh
109-
$ python -m wasmtime.bindgen the-component.wasm --out-dir the-bindings
110-
```
111-
112-
An example of using this can be done with the [`wasm-tools`] repository. For
113-
example with this core wasm module at `demo.wat`:
114-
115-
```wasm
116-
(module
117-
(import "python" "print" (func $print (param i32 i32)))
118-
(memory (export "memory") 1)
119-
120-
(func (export "run")
121-
i32.const 100 ;; base pointer of string
122-
i32.const 13 ;; length of string
123-
call $print)
124-
125-
(data (i32.const 100) "Hello, world!")
126-
)
127-
```
128-
129-
and with this [`*.wit`] interface at `demo.wit`:
130-
131-
```text
132-
package my:demo;
133-
134-
world demo {
135-
import python: interface {
136-
print: func(s: string);
137-
}
138-
139-
export run: func();
140-
}
141-
```
142-
143-
And this `demo.py` script
144-
145-
```python
146-
from demo import Root, RootImports, imports
147-
from wasmtime import Store
148-
149-
class Host(imports.Python):
150-
def print(self, s: str):
151-
print(s)
152-
153-
def main():
154-
store = Store()
155-
demo = Root(store, RootImports(Host()))
156-
demo.run(store)
157-
158-
if __name__ == '__main__':
159-
main()
160-
```
161-
162-
```sh
163-
$ wasm-tools component embed demo.wit demo.wat -o demo.wasm
164-
$ wasm-tools component new demo.wasm -o demo.component.wasm
165-
$ python -m wasmtime.bindgen demo.component.wasm --out-dir demo
166-
$ python demo.py
167-
Hello, world!
168-
```
169-
170-
The generated package `demo` has all of the requisite exports/imports into the
171-
component bound. The `demo` package is additionally annotated with types to
172-
assist with type-checking and self-documentation as much as possible.
173-
174-
[component model]: https://github.com/WebAssembly/component-model
175-
[`wasm-tools`]: https://github.com/bytecodealliance/wasm-tools
176-
[`*.wit`]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md
96+
Components are also supported in `wasmtime-py`. For more information see the
97+
documentation of
98+
[`wasmtime.component`](https://bytecodealliance.github.io/wasmtime-py/component/index.html).
99+
Using a component is similar to using core wasm modules, and for examples see
100+
the `tests/component/` directory.
177101

178102
## Contributing
179103

0 commit comments

Comments
 (0)