Skip to content

Commit a63e030

Browse files
authored
use "wit_world" module name by default for generated bindings (#150)
Previously, we used a name derived from the WIT world name, but this is more predictable. It can be overridden using the `--world-module` option, which now applies to both the `bindings` and `componentize` subcommands. I've also bumped the version to 0.17.0 since this is a breaking change. Fixes #149 Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent c21fdfc commit a63e030

File tree

25 files changed

+99
-73
lines changed

25 files changed

+99
-73
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "componentize-py"
3-
version = "0.16.0"
3+
version = "0.17.0"
44
edition = "2021"
55
exclude = ["cpython"]
66

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ Then, use the `hello` module produced by the command above to write your app:
4646

4747
```shell
4848
cat >app.py <<EOF
49-
import hello
50-
class Hello(hello.Hello):
49+
import wit_world
50+
class WitWorld(wit_world.WitWorld):
5151
def hello(self) -> str:
5252
return "Hello, World!"
5353
EOF

bundled/poll_loop.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
import socket
1212
import subprocess
1313

14-
from proxy.types import Ok, Err
15-
from proxy.imports import types, streams, poll, outgoing_handler
16-
from proxy.imports.types import (
14+
from wit_world.types import Ok, Err
15+
from wit_world.imports import types, streams, poll, outgoing_handler
16+
from wit_world.imports.types import (
1717
IncomingBody,
1818
OutgoingBody,
1919
OutgoingRequest,
2020
IncomingResponse,
2121
)
22-
from proxy.imports.streams import StreamError_Closed, InputStream
23-
from proxy.imports.poll import Pollable
22+
from wit_world.imports.streams import StreamError_Closed, InputStream
23+
from wit_world.imports.poll import Pollable
2424
from typing import Optional, cast
2525

2626
# Maximum number of bytes to read at a time

examples/cli/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ run a Python-based component targetting the [wasi-cli] `command` world.
1010
## Prerequisites
1111

1212
* `Wasmtime` 26.0.0 or later
13-
* `componentize-py` 0.16.0
13+
* `componentize-py` 0.17.0
1414

1515
Below, we use [Rust](https://rustup.rs/)'s `cargo` to install `Wasmtime`. If
1616
you don't have `cargo`, you can download and install from
1717
https://github.com/bytecodealliance/wasmtime/releases/tag/v26.0.0.
1818

1919
```
2020
cargo install --version 26.0.0 wasmtime-cli
21-
pip install componentize-py==0.16.0
21+
pip install componentize-py==0.17.0
2222
```
2323

2424
## Running the demo

examples/cli/app.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
from command import exports
2-
1+
from wit_world import exports
2+
from wit_world.imports.environment import get_arguments
3+
import pdb
34

45
class Run(exports.Run):
56
def run(self) -> None:
7+
if "--pdb" in get_arguments():
8+
pdb.set_trace()
69
print("Hello, world!")

examples/http/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ run a Python-based component targetting the [wasi-http] `proxy` world.
1010
## Prerequisites
1111

1212
* `Wasmtime` 26.0.0 or later
13-
* `componentize-py` 0.16.0
13+
* `componentize-py` 0.17.0
1414

1515
Below, we use [Rust](https://rustup.rs/)'s `cargo` to install `Wasmtime`. If
1616
you don't have `cargo`, you can download and install from
1717
https://github.com/bytecodealliance/wasmtime/releases/tag/v26.0.0.
1818

1919
```
2020
cargo install --version 26.0.0 wasmtime-cli
21-
pip install componentize-py==0.16.0
21+
pip install componentize-py==0.17.0
2222
```
2323

2424
## Running the demo

examples/http/app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
import hashlib
1010
import poll_loop
1111

12-
from proxy import exports
13-
from proxy.types import Ok
14-
from proxy.imports import types
15-
from proxy.imports.types import (
12+
from wit_world import exports
13+
from wit_world.types import Ok
14+
from wit_world.imports import types
15+
from wit_world.imports.types import (
1616
Method_Get,
1717
Method_Post,
1818
Scheme,

examples/matrix-math/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ within a guest component.
1111
## Prerequisites
1212

1313
* `wasmtime` 26.0.0 or later
14-
* `componentize-py` 0.16.0
14+
* `componentize-py` 0.17.0
1515
* `NumPy`, built for WASI
1616

1717
Note that we use an unofficial build of NumPy since the upstream project does
@@ -23,7 +23,7 @@ https://github.com/bytecodealliance/wasmtime/releases/tag/v26.0.0.
2323

2424
```
2525
cargo install --version 26.0.0 wasmtime-cli
26-
pip install componentize-py==0.16.0
26+
pip install componentize-py==0.17.0
2727
curl -OL https://github.com/dicej/wasi-wheels/releases/download/v0.0.1/numpy-wasi.tar.gz
2828
tar xf numpy-wasi.tar.gz
2929
```

examples/matrix-math/app.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
import sys
55
import numpy
6-
import matrix_math
7-
from matrix_math import exports
8-
from matrix_math.types import Err
6+
import wit_world
7+
from wit_world import exports
8+
from wit_world.types import Err
99

1010

11-
class MatrixMath(matrix_math.MatrixMath):
11+
class WitWorld(wit_world.WitWorld):
1212
def multiply(self, a: list[list[float]], b: list[list[float]]) -> list[list[float]]:
1313
print(f"matrix_multiply received arguments {a} and {b}")
1414
return numpy.matmul(a, b).tolist() # type: ignore
@@ -21,4 +21,4 @@ def run(self) -> None:
2121
print("usage: matrix-math <matrix> <matrix>", file=sys.stderr)
2222
exit(-1)
2323

24-
print(MatrixMath().multiply(eval(args[0]), eval(args[1])))
24+
print(WitWorld().multiply(eval(args[0]), eval(args[1])))

0 commit comments

Comments
 (0)