Skip to content

Commit 07d0afb

Browse files
authored
add p3 CLI example (#202)
* add p3 CLI example Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net> * refer to WASI repo Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net> --------- Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
1 parent 43fddde commit 07d0afb

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

examples/cli-p3/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Example: `cli-p3`
2+
3+
This is an example of how to use [componentize-py] and [Wasmtime] to build and
4+
run a Python-based component targetting version `0.3.0-rc-2026-01-06` of the
5+
[wasi-cli] `command` world.
6+
7+
[componentize-py]: https://github.com/bytecodealliance/componentize-py
8+
[Wasmtime]: https://github.com/bytecodealliance/wasmtime
9+
[wasi-cli]: https://github.com/WebAssembly/WASI/tree/v0.3.0-rc-2026-01-06/proposals/cli/wit-0.3.0-draft
10+
11+
## Prerequisites
12+
13+
* `Wasmtime` 41.0.3
14+
* `componentize-py` 0.21.0
15+
16+
Below, we use [Rust](https://rustup.rs/)'s `cargo` to install `Wasmtime`. If
17+
you don't have `cargo`, you can download and install from
18+
https://github.com/bytecodealliance/wasmtime/releases/tag/v41.0.3.
19+
20+
```
21+
cargo install --version 41.0.3 wasmtime-cli
22+
pip install componentize-py==0.21.0
23+
```
24+
25+
## Running the demo
26+
27+
```
28+
componentize-py -d ../../wit -w wasi:cli/command@0.3.0-rc-2026-01-06 componentize app -o cli.wasm
29+
wasmtime run -Sp3 -Wcomponent-model-async cli.wasm
30+
```
31+
32+
The `wasmtime run` command above should print "Hello, world!".

examples/cli-p3/app.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from wit_world import exports
2+
3+
class Run(exports.Run):
4+
async def run(self):
5+
print("Hello, world!")

0 commit comments

Comments
 (0)