Skip to content

Commit

Permalink
Update dependencies to latest. (#44)
Browse files Browse the repository at this point in the history
* Update dependencies to latest.

This commit updates dependencies to latest.

It also updates the WASI adapter to be compatible with Wasmtime 15.

* Fix linting error.

* Add missing semicolons to WITs.

* Add more missing semicolons.

* Fix to tests for changed resource API.

* More fixes to Wasmtime 15 API changes.

* More API changes.

* More test fixes.

* remove obsolete paragraph from README.md

Signed-off-by: Joel Dice <joel.dice@fermyon.com>

* bump version to 0.7.0; update http example

Signed-off-by: Joel Dice <joel.dice@fermyon.com>

---------

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Co-authored-by: Joel Dice <joel.dice@fermyon.com>
  • Loading branch information
peterhuene and dicej authored Nov 29, 2023
1 parent e34f133 commit 65e7697
Show file tree
Hide file tree
Showing 57 changed files with 2,359 additions and 2,410 deletions.
1,335 changes: 612 additions & 723 deletions Cargo.lock

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "componentize-py"
version = "0.6.0"
version = "0.7.0"
edition = "2021"
exclude = ["cpython"]

Expand All @@ -9,43 +9,43 @@ name = "componentize_py"
crate-type = ["cdylib", "rlib"]

[dependencies]
anyhow = { version = "1.0.68", features = ["backtrace"] }
clap = { version = "4.1.4", features = ["derive"] }
tar = "0.4.38"
tempfile = "3.5.0"
zstd = "0.11.1"
anyhow = { version = "1.0.75", features = ["backtrace"] }
clap = { version = "4.4.10", features = ["derive"] }
tar = "0.4.40"
tempfile = "3.8.1"
zstd = "0.13.0"
componentize-py-shared = { path = "shared" }
wasmparser = "0.107.0"
wasm-encoder = "0.29.0"
wit-parser = "0.12.2"
wit-component = "0.17.0"
indexmap = "2.0.0"
wasmparser = "0.118.0"
wasm-encoder = "0.38.0"
wit-parser = "0.13.0"
wit-component = "0.18.2"
indexmap = "2.1.0"
bincode = "1.3.3"
heck = "0.4.1"
pyo3 = { version = "0.18.3", features = ["abi3-py37", "extension-module"], optional = true }
wasmtime-wasi = "14.0.3"
wasi-common = "14.0.3"
wasmtime = { version = "14.0.3", features = [ "component-model" ] }
once_cell = "1.17.1"
pyo3 = { version = "0.20.0", features = ["abi3-py37", "extension-module"], optional = true }
wasmtime-wasi = "15.0.0"
wasi-common = "15.0.0"
wasmtime = { version = "15.0.0", features = [ "component-model" ] }
once_cell = "1.18.0"
component-init = { git = "https://github.com/dicej/component-init" }
async-trait = "0.1.68"
futures = "0.3.28"
tokio = { version = "1.27.0", features = ["macros", "rt", "rt-multi-thread", "fs"] }
bytes = "1.4.0"
async-trait = "0.1.74"
futures = "0.3.29"
tokio = { version = "1.34.0", features = ["macros", "rt", "rt-multi-thread", "fs"] }
bytes = "1.5.0"
pretty_env_logger = "0.5.0"
cap-std = "2.0.0"
im-rc = "15.1.0"

[dev-dependencies]
async-trait = "0.1.68"
once_cell = "1.17.1"
proptest = "1.1.0"
async-trait = "0.1.74"
once_cell = "1.18.0"
proptest = "1.4.0"
hex = "0.4.3"

[build-dependencies]
anyhow = "1.0.68"
tar = "0.4.38"
zstd = "0.11.1"
anyhow = "1.0.75"
tar = "0.4.40"
zstd = "0.13.0"
test-generator = { path = "test-generator" }

[workspace]
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ For an example of running a sandboxed Python guest within a Python host, see

## Known Limitations

This project does not yet support [interface
versions](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#package-declaration),
but it's coming soon.

Currently, the application can only import dependencies during build time, which
means any imports used at runtime must be resolved at the top level of the
application module. For example, if `x` is a module with a submodule named `y`
Expand Down
Binary file not shown.
9 changes: 2 additions & 7 deletions adapters/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
The subdirectory of this directory contains a build of the WASI Preview 1
component adapter. It was built from commit `e8766e49` of
https://github.com/dicej/wasmtime using the
`ci/build-wasi-preview1-component-adapter.sh` script.

TODO: Switch back to upstream once
https://github.com/bytecodealliance/wasmtime/pull/7444 has been merged and
released.
component adapter. It was built from commit `6f0da84` of
https://github.com/bytecodealliance/wasmtime.
Binary file not shown.
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn package_all_the_things(out_dir: &Path) -> Result<()> {
let path = out_dir.join("wasm32-wasi/release/libcomponentize_py_runtime.a");

if path.exists() {
let clang = wasi_sdk.join(&format!("bin/{CLANG_EXECUTABLE}"));
let clang = wasi_sdk.join(format!("bin/{CLANG_EXECUTABLE}"));
if clang.exists() {
let name = "libcomponentize_py_runtime.so";

Expand Down Expand Up @@ -209,7 +209,7 @@ fn package_all_the_things(out_dir: &Path) -> Result<()> {
}

compress(
&repo_dir.join("adapters/e8766e49"),
&repo_dir.join("adapters/6f0da84"),
"wasi_snapshot_preview1.reactor.wasm",
out_dir,
false,
Expand Down
6 changes: 3 additions & 3 deletions bundled/poll_loop.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Defines a custom `asyncio` event loop backed by `wasi:io/poll#poll-list`.
"""Defines a custom `asyncio` event loop backed by `wasi:io/poll#poll`.
This also includes helper classes and functions for working with `wasi:http`.
Expand Down Expand Up @@ -108,7 +108,7 @@ def close(self):
self.body = None

class PollLoop(asyncio.AbstractEventLoop):
"""Custom `asyncio` event loop backed by `wasi:io/poll#poll-list`."""
"""Custom `asyncio` event loop backed by `wasi:io/poll#poll`."""

def __init__(self):
self.wakers = []
Expand All @@ -135,7 +135,7 @@ def run_until_complete(self, future):

new_wakers = []
ready = [False] * len(pollables)
for index in poll.poll_list(pollables):
for index in poll.poll(pollables):
ready[index] = True

for (ready, pollable), waker in zip(zip(ready, pollables), wakers):
Expand Down
8 changes: 4 additions & 4 deletions examples/http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ which may differ from later revisions.
## Prerequisites

* `Wasmtime` 14.0.3 (later versions may use a different, incompatible `wasi-http` snapshot)
* `componentize-py` 0.6.0
* `componentize-py` 0.7.0

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

```
cargo install --version 14.0.3 wasmtime-cli
cargo install --version 15.0.0 wasmtime-cli
pip install componentize-py
```

Expand All @@ -30,7 +30,7 @@ pip install componentize-py
First, build the app and run it:

```
componentize-py -d wit -w proxy componentize app -o http.wasm
componentize-py -d wit -w wasi:http/proxy@0.2.0-rc-2023-11-10 componentize app -o http.wasm
wasmtime serve http.wasm
```

Expand Down
27 changes: 11 additions & 16 deletions examples/http/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ async def handle_async(request: IncomingRequest, response_out: ResponseOutparam)

urls = map(lambda pair: str(pair[1], "utf-8"), filter(lambda pair: pair[0] == "url", headers))

response = OutgoingResponse(200, Fields([("content-type", b"text/plain")]))
response = OutgoingResponse(Fields.from_list([("content-type", b"text/plain")]))

response_body = response.write()
response_body = response.body()

ResponseOutparam.set(response_out, Ok(response))

Expand All @@ -64,12 +64,9 @@ async def handle_async(request: IncomingRequest, response_out: ResponseOutparam)
elif isinstance(method, MethodPost) and path == "/echo":
# Echo the request body back to the client without buffering.

response = OutgoingResponse(
200,
Fields(list(filter(lambda pair: pair[0] == "content-type", headers)))
)
response = OutgoingResponse(Fields.from_list(list(filter(lambda pair: pair[0] == "content-type", headers))))

response_body = response.write()
response_body = response.body()

ResponseOutparam.set(response_out, Ok(response))

Expand All @@ -84,9 +81,10 @@ async def handle_async(request: IncomingRequest, response_out: ResponseOutparam)

sink.close()
else:
response = OutgoingResponse(400, Fields([]))
response = OutgoingResponse(Fields.from_list([]))
response.set_status_code(400)
ResponseOutparam.set(response_out, Ok(response))
OutgoingBody.finish(response.write(), None)
OutgoingBody.finish(response.body(), None)

async def sha256(url: str) -> Tuple[str, str]:
"""Download the contents of the specified URL, computing the SHA-256
Expand All @@ -106,13 +104,10 @@ async def sha256(url: str) -> Tuple[str, str]:
case _:
scheme = SchemeOther(url_parsed.scheme)

request = OutgoingRequest(
MethodGet(),
url_parsed.path,
scheme,
url_parsed.netloc,
Fields([])
)
request = OutgoingRequest(Fields.from_list([]))
request.set_scheme(scheme)
request.set_authority(url_parsed.netloc)
request.set_path_with_query(url_parsed.path)

response = await poll_loop.send(request)
status = response.status()
Expand Down
35 changes: 2 additions & 33 deletions examples/http/wit/command-extended.wit
Original file line number Diff line number Diff line change
@@ -1,37 +1,6 @@
// All of the same imports and exports available in the wasi:cli/command world
// with addition of HTTP proxy related imports:
world command-extended {
import wasi:clocks/wall-clock@0.2.0-rc-2023-10-18;
import wasi:clocks/monotonic-clock@0.2.0-rc-2023-10-18;
import wasi:clocks/timezone@0.2.0-rc-2023-10-18;
import wasi:filesystem/types@0.2.0-rc-2023-10-18;
import wasi:filesystem/preopens@0.2.0-rc-2023-10-18;
import wasi:sockets/instance-network@0.2.0-rc-2023-10-18;
import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-10-18;
import wasi:sockets/network@0.2.0-rc-2023-10-18;
import wasi:sockets/tcp-create-socket@0.2.0-rc-2023-10-18;
import wasi:sockets/tcp@0.2.0-rc-2023-10-18;
import wasi:sockets/udp-create-socket@0.2.0-rc-2023-10-18;
import wasi:sockets/udp@0.2.0-rc-2023-10-18;
import wasi:random/random@0.2.0-rc-2023-10-18;
import wasi:random/insecure@0.2.0-rc-2023-10-18;
import wasi:random/insecure-seed@0.2.0-rc-2023-10-18;
import wasi:io/poll@0.2.0-rc-2023-10-18;
import wasi:io/streams@0.2.0-rc-2023-10-18;
import wasi:cli/environment@0.2.0-rc-2023-10-18;
import wasi:cli/exit@0.2.0-rc-2023-10-18;
import wasi:cli/stdin@0.2.0-rc-2023-10-18;
import wasi:cli/stdout@0.2.0-rc-2023-10-18;
import wasi:cli/stderr@0.2.0-rc-2023-10-18;
import wasi:cli/terminal-input@0.2.0-rc-2023-10-18;
import wasi:cli/terminal-output@0.2.0-rc-2023-10-18;
import wasi:cli/terminal-stdin@0.2.0-rc-2023-10-18;
import wasi:cli/terminal-stdout@0.2.0-rc-2023-10-18;
import wasi:cli/terminal-stderr@0.2.0-rc-2023-10-18;

// We should replace all others with `include self.command`
// as soon as the unioning of worlds is available:
// https://github.com/WebAssembly/component-model/issues/169
import wasi:logging/logging@0.2.0-rc-2023-10-18;
import wasi:http/outgoing-handler@0.2.0-rc-2023-10-18;
include wasi:cli/command@0.2.0-rc-2023-11-10;
import wasi:http/outgoing-handler@0.2.0-rc-2023-11-10;
}
2 changes: 1 addition & 1 deletion examples/http/wit/deps/cli/command.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:cli@0.2.0-rc-2023-10-18;
package wasi:cli@0.2.0-rc-2023-11-10;

world command {
include reactor;
Expand Down
35 changes: 17 additions & 18 deletions examples/http/wit/deps/cli/reactor.wit
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
package wasi:cli@0.2.0-rc-2023-10-18;
package wasi:cli@0.2.0-rc-2023-11-10;

world reactor {
import wasi:clocks/wall-clock@0.2.0-rc-2023-10-18;
import wasi:clocks/monotonic-clock@0.2.0-rc-2023-10-18;
import wasi:clocks/timezone@0.2.0-rc-2023-10-18;
import wasi:filesystem/types@0.2.0-rc-2023-10-18;
import wasi:filesystem/preopens@0.2.0-rc-2023-10-18;
import wasi:sockets/instance-network@0.2.0-rc-2023-10-18;
import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-10-18;
import wasi:sockets/network@0.2.0-rc-2023-10-18;
import wasi:sockets/tcp-create-socket@0.2.0-rc-2023-10-18;
import wasi:sockets/tcp@0.2.0-rc-2023-10-18;
import wasi:sockets/udp-create-socket@0.2.0-rc-2023-10-18;
import wasi:sockets/udp@0.2.0-rc-2023-10-18;
import wasi:random/random@0.2.0-rc-2023-10-18;
import wasi:random/insecure@0.2.0-rc-2023-10-18;
import wasi:random/insecure-seed@0.2.0-rc-2023-10-18;
import wasi:io/poll@0.2.0-rc-2023-10-18;
import wasi:io/streams@0.2.0-rc-2023-10-18;
import wasi:clocks/wall-clock@0.2.0-rc-2023-11-10;
import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10;
import wasi:filesystem/types@0.2.0-rc-2023-11-10;
import wasi:filesystem/preopens@0.2.0-rc-2023-11-10;
import wasi:sockets/instance-network@0.2.0-rc-2023-11-10;
import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-10;
import wasi:sockets/network@0.2.0-rc-2023-11-10;
import wasi:sockets/tcp-create-socket@0.2.0-rc-2023-11-10;
import wasi:sockets/tcp@0.2.0-rc-2023-11-10;
import wasi:sockets/udp-create-socket@0.2.0-rc-2023-11-10;
import wasi:sockets/udp@0.2.0-rc-2023-11-10;
import wasi:random/random@0.2.0-rc-2023-11-10;
import wasi:random/insecure@0.2.0-rc-2023-11-10;
import wasi:random/insecure-seed@0.2.0-rc-2023-11-10;
import wasi:io/poll@0.2.0-rc-2023-11-10;
import wasi:io/streams@0.2.0-rc-2023-11-10;

import environment;
import exit;
Expand Down
6 changes: 3 additions & 3 deletions examples/http/wit/deps/cli/stdio.wit
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
interface stdin {
use wasi:io/streams@0.2.0-rc-2023-10-18.{input-stream};
use wasi:io/streams@0.2.0-rc-2023-11-10.{input-stream};

get-stdin: func() -> input-stream;
}

interface stdout {
use wasi:io/streams@0.2.0-rc-2023-10-18.{output-stream};
use wasi:io/streams@0.2.0-rc-2023-11-10.{output-stream};

get-stdout: func() -> output-stream;
}

interface stderr {
use wasi:io/streams@0.2.0-rc-2023-10-18.{output-stream};
use wasi:io/streams@0.2.0-rc-2023-11-10.{output-stream};

get-stderr: func() -> output-stream;
}
29 changes: 21 additions & 8 deletions examples/http/wit/deps/clocks/monotonic-clock.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package wasi:clocks@0.2.0-rc-2023-11-10;
/// WASI Monotonic Clock is a clock API intended to let users measure elapsed
/// time.
///
Expand All @@ -9,24 +10,36 @@
///
/// It is intended for measuring elapsed time.
interface monotonic-clock {
use wasi:io/poll@0.2.0-rc-2023-10-18.{pollable};
use wasi:io/poll@0.2.0-rc-2023-11-10.{pollable};

/// A timestamp in nanoseconds.
/// An instant in time, in nanoseconds. An instant is relative to an
/// unspecified initial value, and can only be compared to instances from
/// the same monotonic-clock.
type instant = u64;

/// A duration of time, in nanoseconds.
type duration = u64;

/// Read the current value of the clock.
///
/// The clock is monotonic, therefore calling this function repeatedly will
/// produce a sequence of non-decreasing values.
now: func() -> instant;

/// Query the resolution of the clock.
resolution: func() -> instant;
/// Query the resolution of the clock. Returns the duration of time
/// corresponding to a clock tick.
resolution: func() -> duration;

/// Create a `pollable` which will resolve once the specified time has been
/// reached.
subscribe: func(
/// Create a `pollable` which will resolve once the specified instant
/// occured.
subscribe-instant: func(
when: instant,
absolute: bool
) -> pollable;

/// Create a `pollable` which will resolve once the given duration has
/// elapsed, starting at the time at which this function was called.
/// occured.
subscribe-duration: func(
when: duration,
) -> pollable;
}
Loading

0 comments on commit 65e7697

Please sign in to comment.