Skip to content

Commit

Permalink
refactor: rename to pyrt_wit_wire
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohe-Am committed Apr 21, 2024
1 parent 5da888d commit 876db95
Show file tree
Hide file tree
Showing 36 changed files with 125 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .ghjk/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
envs
hash.json
hash.json
121 changes: 83 additions & 38 deletions .ghjk/lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,6 @@
"ports": {
"version": "0",
"configResolutions": {
"9aaf6a4fddacb5a219afcb3a46e1fd21049cbbeb5808c49be95ea371e3928fc0": {
"version": "0.13.5",
"depConfigs": {
"tar_aa": {
"version": "1.34",
"depConfigs": {},
"portRef": "[email protected]"
}
},
"portRef": "[email protected]"
},
"9e3fa7742c431c34ae7ba8d1e907e50c937ccfb631fb4dcfb7a1773742abe267": {
"version": "1.34",
"depConfigs": {},
"portRef": "[email protected]"
},
"5155b24a1a756a5b91108ba34188d8bc4f5d6744f5ac29454450d6275663df86": {
"version": "v24.1",
"depConfigs": {},
Expand Down Expand Up @@ -227,6 +211,11 @@
},
"portRef": "[email protected]"
},
"9e3fa7742c431c34ae7ba8d1e907e50c937ccfb631fb4dcfb7a1773742abe267": {
"version": "1.34",
"depConfigs": {},
"portRef": "[email protected]"
},
"f4760b34b6c9f9f96207cfb380deb77007a212a60bd10bdb3dc9d20b94c2785c": {
"version": "v8.15.2",
"depConfigs": {},
Expand Down Expand Up @@ -473,6 +462,37 @@
}
},
"portRef": "[email protected]"
},
"f1552d80bc05967757fc8f6530cfb4a0f875a6e6d46167eedc2530b533abac26": {
"version": "19.0.2",
"depConfigs": {
"cargo_binstall_ghrel": {
"version": "v1.6.4",
"depConfigs": {},
"portRef": "[email protected]"
},
"rust_rustup": {
"version": "1.77.2",
"depConfigs": {
"rustup_rustlang": {
"version": "1.27.0",
"depConfigs": {
"git_aa": {
"version": "2.40.1",
"depConfigs": {},
"portRef": "[email protected]"
}
},
"portRef": "[email protected]"
}
},
"portRef": "[email protected]",
"profile": "minimal"
}
},
"portRef": "[email protected]",
"crateName": "wasmtime-cli",
"locked": true
}
}
},
Expand All @@ -486,7 +506,6 @@
"id": "ports",
"config": {
"installs": [
"269266fdca40e20f9361848270d3e0f8ca6d4616",
"db5b506ba0936c6713a2efef3ee82df7ea271b06",
"651e1043d59561e4e71e5fb0775daf746467a028",
"e7b2f3414caa4c4441240c02dcb8f7c781fd01ee",
Expand Down Expand Up @@ -579,7 +598,8 @@
"installs": [
"be7e967b2420f3d6a8af7d3ff11192362ee4b5c8",
"5dfbf570fa87f14a3524560c40bd08d0d62a7526",
"a24f45ef0b2064658d87264a95d31fe4694f6f4e"
"a24f45ef0b2064658d87264a95d31fe4694f6f4e",
"a4de04b77193fd53fed574b61e8568dc63a53544"
],
"env": {},
"allowedPortDeps": [
Expand All @@ -604,26 +624,6 @@
],
"globalEnv": {
"installs": {
"269266fdca40e20f9361848270d3e0f8ca6d4616": {
"version": "0.13.5",
"port": {
"ty": "denoWorker@v1",
"name": "wasmedge_ghrel",
"platforms": [
"aarch64-linux",
"x86_64-linux",
"aarch64-darwin",
"x86_64-darwin"
],
"version": "0.1.0",
"deps": [
{
"name": "tar_aa"
}
],
"moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/wasmedge.ts"
}
},
"db5b506ba0936c6713a2efef3ee82df7ea271b06": {
"version": "v24.1",
"port": {
Expand Down Expand Up @@ -1241,6 +1241,51 @@
],
"moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/cpy_bs.ts"
}
},
"a4de04b77193fd53fed574b61e8568dc63a53544": {
"version": "19.0.2",
"depConfigs": {
"rust_rustup": {
"portRef": "[email protected]",
"profile": "minimal"
}
},
"port": {
"ty": "denoWorker@v1",
"name": "cargobi_cratesio",
"platforms": [
"x86_64-linux",
"aarch64-linux",
"x86_64-darwin",
"aarch64-darwin",
"x86_64-windows",
"aarch64-windows",
"x86_64-freebsd",
"aarch64-freebsd",
"x86_64-netbsd",
"aarch64-netbsd",
"x86_64-aix",
"aarch64-aix",
"x86_64-solaris",
"aarch64-solaris",
"x86_64-illumos",
"aarch64-illumos",
"x86_64-android",
"aarch64-android"
],
"version": "0.1.0",
"deps": [
{
"name": "cargo_binstall_ghrel"
},
{
"name": "rust_rustup"
}
],
"moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/cargobi.ts"
},
"crateName": "wasmtime-cli",
"locked": true
}
},
"allowedPortDeps": {
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,10 @@ jobs:
mkdir -p $(dirname $WASM_FILE)
wasm-opt -Oz target/wasm/wasm32-unknown-unknown/debug/typegraph_core.wasm -o $WASM_FILE.opt
wasm-tools component new $WASM_FILE.opt -o $WASM_FILE
ghjk x gen-pyrt-bind
ghjk x build-pyrt
jco transpile $WASM_FILE -o typegraph/node/sdk/src/gen --map metatype:typegraph/host=../host/host.js
cd typegraph/node
pnpm install
Expand Down
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ repos:
|typegate/deno.lock
|.*\.snap$|typegate/src/typegraphs/.*\.json
|website/docs/reference/
|libs/pyrt_component/pyrt/imports/.*
)
|libs/pyrt_wit_wire/pyrt)
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.2
hooks:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ members = [

exclude = [
"typegate/tests/runtimes/wasm/rust",
"libs/pyrt_component"
"libs/pyrt_wit_wire"
]

[workspace.package]
Expand Down
7 changes: 1 addition & 6 deletions dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ RUN set -eux; \
automake \
# wasm-opt deps \
clang \
## wasmedge-sys \
libclang-dev \
## openssl deps \
pkg-config \
libssl-dev \
Expand Down Expand Up @@ -101,8 +99,7 @@ RUN . $GHJK_ENV \
&& chmod +x /tini \
&& mkdir -p /lib/sym \
&& ln -s /lib/aarch64-linux-gnu /lib/sym/arm64 \
&& ln -s /lib/x86_64-linux-gnu /lib/sym/amd64 \
&& cp $(dirname $(realpath $(which wasmedge)))/.. /.wasmedge -r
&& ln -s /lib/x86_64-linux-gnu /lib/sym/amd64

#
FROM gcr.io/distroless/cc-debian11:${DISTROLESS_TAG} as prd
Expand All @@ -113,13 +110,11 @@ ARG TARGETARCH

ENV NO_COLOR true
ENV DENO_DIR /deno-dir/
ENV LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:/.wasmedge/lib64"

WORKDIR /app

COPY --from=runtime-bin /tini /tini
COPY --from=runtime-bin /lib/sym /lib/sym
COPY --from=runtime-bin /.wasmedge /.wasmedge
COPY --from=builder /lib/*-linux-gnu/libz.so* /lib/sym/${TARGETARCH}

COPY --from=builder /app/target/release/typegate /bin/typegate
Expand Down
2 changes: 0 additions & 2 deletions dev/cross.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ RUN set -eux \
automake \
# protoc\
libprotoc-dev:$ARCH \
# wasmedge-sys crate build dep\
libclang-dev \
# openssl crate build deps \
pkg-config \
libssl-dev:$ARCH \
Expand Down
7 changes: 2 additions & 5 deletions dev/lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ dev:
- typegraph/node/LICENSE.md
- typegraph/node/sdk/LICENSE.md
lines:
installer.sh:
(WASMEDGE_VERSION=").+("): WASMEDGE_VERSION
rust-toolchain.toml:
(channel = ").+("): RUST_VERSION
ghjk.ts:
Expand All @@ -17,12 +15,12 @@ dev:
(const\s+PNPM_VERSION\s*=\s*").*(";): PNPM_VERSION
(const\s+WASM_TOOLS_VERSION = ").*(";): WASM_TOOLS_VERSION
(const\s+JCO_VERSION =\s*").*(";): JCO_VERSION
(const\s+WASMEDGE_VERSION\s*=\s*").*(";): WASMEDGE_VERSION
(const\s+WASM_OPT_VERSION\s*=\s*").*(";): WASM_OPT_VERSION
(const\s+MOLD_VERSION\s*=\s*").*(";): MOLD_VERSION
(const\s+CMAKE_VERSION\s*=\s*").*(";): CMAKE_VERSION
(const\s+CARGO_INSTA_VERSION\s*=\s*").*(";): CARGO_INSTA_VERSION
(const\s+TEMPORAL_VERSION\s*=\s*").*(";): TEMPORAL_VERSION
(const\s+WASMTIME_VERSION\s*=\s*").*(";): WASMTIME_VERSION
(const\s+METATYPE_VERSION\s*=\s*").*(";): METATYPE_VERSION
.github/*/*.yml:
'( GHJK_VERSION: ").+(")': GHJK_VERSION
Expand Down Expand Up @@ -95,8 +93,7 @@ dev:
CARGO_INSTA_VERSION: 1.33.0
WASM_TOOLS_VERSION: 1.0.53
JCO_VERSION: 1.0.0
WASMTIME_VERSION: 18.0.2
WASMEDGE_VERSION: 0.13.5
WASMTIME_VERSION: 19.0.2
TYPEGRAPH_VERSION: 0.0.3
PRISMA_VERSION: 5.5.2
METATYPE_VERSION: 0.3.7-0
Expand Down
18 changes: 10 additions & 8 deletions ghjk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const PYTHON_VERSION = "3.8.18";
const PNPM_VERSION = "v8.15.2";
const WASM_TOOLS_VERSION = "1.0.53";
const JCO_VERSION = "1.0.0";
const WASMEDGE_VERSION = "0.13.5";
const WASMTIME_VERSION = "19.0.2";
const WASM_OPT_VERSION = "0.116.0";
const MOLD_VERSION = "v2.4.0";
const CMAKE_VERSION = "3.28.0-rc6";
Expand All @@ -28,6 +28,11 @@ const installs = {
version: WASM_OPT_VERSION,
locked: true,
}),
wasmtime: ports.cargobi({
crateName: "wasmtime-cli",
version: WASMTIME_VERSION,
locked: true,
}),
};

const allowedPortDeps = [
Expand All @@ -44,7 +49,6 @@ const inOci = () => !!Deno.env.get("OCI");
const inDev = () => !inCi() && !inOci();

ghjk.install(
ports.wasmedge({ version: WASMEDGE_VERSION }),
ports.protoc({ version: PROTOC_VERSION }),
ports.asdf({
pluginRepo: "https://github.com/asdf-community/asdf-cmake",
Expand Down Expand Up @@ -132,18 +136,16 @@ ghjk.task("gen-pyrt-bind", {
installs: installs.comp_py,
allowedPortDeps,
async fn({ $ }) {
await $.removeIfExists("./libs/pyrt_component/pyrt");
await $`componentize-py -d wit/ bindings .`.cwd("./libs/pyrt_component");
await $.removeIfExists("./libs/pyrt_wit_wire/pyrt");
await $`componentize-py -d wit/ bindings .`.cwd("./libs/pyrt_wit_wire");
},
});

ghjk.task("build-pyrt", {
installs: [...installs.comp_py, installs.wasm_opt],
installs: [...installs.comp_py, installs.wasm_opt, installs.wasmtime],
allowedPortDeps,
async fn({ $ }) {
await $`componentize-py -d wit/ componentize -o ../../target/pyrt.wasm main`
.cwd("./libs/pyrt_component");
// TODO: explicitly install wasmtime
await $`componentize-py -d ./libs/pyrt_wit_wire/wit/ componentize -o ./target/pyrt.wasm libs.pyrt_wit_wire.main`;
await $`wasmtime compile -W component-model ./target/pyrt.wasm -o ./target/pyrt.cwasm`;
// await $`wasm-opt -Oz ./target/pyrt.wasm -o ./target/pyrt.wasm2`;
},
Expand Down
19 changes: 0 additions & 19 deletions installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,3 @@ Or moving the executable to another directory in your PATH:
$ sudo mv $EXE /usr/local/bin
EOF
fi

WASMEDGE_VERSION="0.13.5"

cat <<EOF
NOTE!: libwasmedge.so is required to work with the meta program.
If not installed, consider using the following command to install it...
\$WASMEDGE_VERSION=$WASMEDGE_VERSION
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v \$WASMEDGE_VERSION
...and make sure the dynamic linker can find the library.
For example, if you installed in in the default location of "~/.wasmedge/lib", add that to \$LD_LIBRARY_PATH.
More details on how to install wasmedge can be found at https://wasmedge.org/docs/start/install/
Alternative builds of the meta cli that don't require libwasmedge are also availaible.
Consult https://metatype.dev/docs/reference/meta-cli for more details.
EOF
1 change: 1 addition & 0 deletions libs/pyrt_component/main.py → libs/pyrt_wit_wire/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pyrt.exports

# NOTE: all imports must be toplevel as constrained by `componentize-py`
# https://github.com/bytecodealliance/componentize-py/issues/23
from pyrt.imports.shared import Req, Ok, Err

# from pyrt.imports.typegate_wire import hostcall
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
[tool.poetry]
name = "pyrt-component"
name = "pyrt_wit_wire"
version = "0.3.7-0"
description = "Wasm component implementing the PythonRuntime vm."
authors = ["Your Name <[email protected]>"]
description = "Wasm component implementing the PythonRuntime host using wit_wire protocol."
license = "Elastic-2.0"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.8"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import weakref

from ..types import Result, Ok, Err, Some
from ..exports import mat_wire
from ..imports import shared
from ..exports import mat_wire

class MatWire(Protocol):

Expand All @@ -20,3 +20,5 @@ def init(self, args: mat_wire.InitArgs) -> mat_wire.InitResponse:
@abstractmethod
def handle(self, req: shared.Req) -> Result[str, str]:
raise NotImplementedError


Loading

0 comments on commit 876db95

Please sign in to comment.