Skip to content

Commit fd5b49c

Browse files
authored
fix type hints; bump version to 0.9.0 (#49)
This fixes the type hints so Python, pdoc3, etc. can handle them -- not just MyPy. Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent a77c6b2 commit fd5b49c

11 files changed

Lines changed: 223 additions & 93 deletions

File tree

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.8.0"
3+
version = "0.9.0"
44
edition = "2021"
55
exclude = ["cpython"]
66

examples/cli/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ snapshot, which may differ from later revisions.
1313
## Prerequisites
1414

1515
* `Wasmtime` 16.0.0 (later versions may use a different, incompatible `wasi-cli` snapshot)
16-
* `componentize-py` 0.8.0
16+
* `componentize-py` 0.9.0
1717

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

2222
```
2323
cargo install --version 16.0.0 wasmtime-cli
24-
pip install componentize-py==0.8.0
24+
pip install componentize-py==0.9.0
2525
```
2626

2727
## Running the demo

examples/http/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ which may differ from later revisions.
1414
## Prerequisites
1515

1616
* `Wasmtime` 16.0.0 (later versions may use a different, incompatible `wasi-http` snapshot)
17-
* `componentize-py` 0.8.0
17+
* `componentize-py` 0.9.0
1818

1919
Below, we use [Rust](https://rustup.rs/)'s `cargo` to install `Wasmtime`. If
2020
you don't have `cargo`, you can download and install from
2121
https://github.com/bytecodealliance/wasmtime/releases/tag/v16.0.0.
2222

2323
```
2424
cargo install --version 16.0.0 wasmtime-cli
25-
pip install componentize-py==0.8.0
25+
pip install componentize-py==0.9.0
2626
```
2727

2828
## Running the demo

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` 16.0.0 (later versions may use a different, incompatible `wasi-cli` snapshot)
14-
* `componentize-py` 0.8.0
14+
* `componentize-py` 0.9.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/v16.0.0.
2323

2424
```
2525
cargo install --version 16.0.0 wasmtime-cli
26-
pip install componentize-py==0.8.0
26+
pip install componentize-py==0.9.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/tcp/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ snapshot, which may differ from later revisions.
1414
## Prerequisites
1515

1616
* `Wasmtime` 16.0.0 (later versions may use a different, incompatible `wasi-cli` snapshot)
17-
* `componentize-py` 0.8.0
17+
* `componentize-py` 0.9.0
1818

1919
Below, we use [Rust](https://rustup.rs/)'s `cargo` to install `Wasmtime`. If
2020
you don't have `cargo`, you can download and install from
2121
https://github.com/bytecodealliance/wasmtime/releases/tag/v16.0.0.
2222

2323
```
2424
cargo install --version 16.0.0 wasmtime-cli
25-
pip install componentize-py==0.8.0
25+
pip install componentize-py==0.9.0
2626
```
2727

2828
## Running the demo

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ features = ["pyo3/extension-module"]
77

88
[project]
99
name = "componentize-py"
10-
version = "0.8.0"
10+
version = "0.9.0"
1111
description = "Tool to package Python applications as WebAssembly components"
1212
readme = "README.md"
1313
license = { file = "LICENSE" }

src/command.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ pub struct Bindings {
7171
///
7272
/// This will be created if it does not already exist.
7373
pub output_dir: PathBuf,
74-
75-
/// Disable type annotations
76-
#[arg(short = 'n', long)]
77-
pub no_typings: bool,
7874
}
7975

8076
pub fn run<T: Into<OsString> + Clone, I: IntoIterator<Item = T>>(args: I) -> Result<()> {
@@ -92,7 +88,6 @@ fn generate_bindings(common: Common, bindings: Bindings) -> Result<()> {
9288
.unwrap_or_else(|| Path::new("wit").to_owned()),
9389
common.world.as_deref(),
9490
&bindings.output_dir,
95-
!bindings.no_typings,
9691
)
9792
}
9893

src/lib.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,12 @@ impl Invoker for MyInvoker {
167167
}
168168
}
169169

170-
pub fn generate_bindings(
171-
wit_path: &Path,
172-
world: Option<&str>,
173-
output_dir: &Path,
174-
with_typings: bool,
175-
) -> Result<()> {
170+
pub fn generate_bindings(wit_path: &Path, world: Option<&str>, output_dir: &Path) -> Result<()> {
176171
let (resolve, world) = parse_wit(wit_path, world)?;
177172
let summary = Summary::try_new(&resolve, world)?;
178173
let world_dir = output_dir.join(resolve.worlds[world].name.to_snake_case().escape());
179174
fs::create_dir_all(&world_dir)?;
180-
summary.generate_code(&world_dir, with_typings, true)?;
175+
summary.generate_code(&world_dir, true)?;
181176

182177
Ok(())
183178
}
@@ -378,7 +373,7 @@ pub async fn componentize(
378373
.as_ref()
379374
.and_then(|(p, c)| c.bindings.as_deref().map(|f| (p, f)))
380375
{
381-
summary.generate_code(world_dir.path(), false, false)?;
376+
summary.generate_code(world_dir.path(), false)?;
382377

383378
let paths = python_path
384379
.iter()
@@ -405,7 +400,7 @@ pub async fn componentize(
405400
let module = resolve.worlds[world].name.to_snake_case();
406401
let world_dir = world_dir.path().join(&module);
407402
fs::create_dir_all(&world_dir)?;
408-
summary.generate_code(&world_dir, false, false)?;
403+
summary.generate_code(&world_dir, false)?;
409404

410405
(vec!["world".to_owned()], module)
411406
};

src/python.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@ fn python_componentize(
2929

3030
#[pyo3::pyfunction]
3131
#[pyo3(name = "generate_bindings")]
32-
#[pyo3(signature = (wit_path, world, output_dir, with_typings))]
32+
#[pyo3(signature = (wit_path, world, output_dir))]
3333
fn python_generate_bindings(
3434
wit_path: PathBuf,
3535
world: Option<&str>,
3636
output_dir: PathBuf,
37-
with_typings: bool,
3837
) -> PyResult<()> {
39-
crate::generate_bindings(&wit_path, world, &output_dir, with_typings)
38+
crate::generate_bindings(&wit_path, world, &output_dir)
4039
.map_err(|e| PyAssertionError::new_err(format!("{e:?}")))
4140
}
4241

0 commit comments

Comments
 (0)