| Name | polywrap-wasm JSON |
| Version |
0.1.0
JSON |
| download |
| home_page | |
| Summary | Polywrap Wasm |
| upload_time | 2023-09-02 11:49:18 |
| maintainer | |
| docs_url | None |
| author | Cesar |
| requires_python | >=3.10,<4.0 |
| license | |
| keywords |
|
| VCS |
|
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
Polywrap Wasm
=============
This package contains the runtime for executing Wasm wrappers.
Quickstart
----------
The following code snippet demonstrates how to use the runtime to execute a Wasm wrapper.
Imports
~~~~~~~
>>> import os
>>> from typing import cast
>>> from polywrap_core import Uri, FileReader, InvokerClient
>>> from polywrap_wasm import WasmWrapper
>>> from polywrap_msgpack import msgpack_decode
>>> from polywrap_manifest import deserialize_wrap_manifest, AnyWrapManifest
Create a Wasm wrapper
~~~~~~~~~~~~~~~~~~~~~
>>> path_to_wrapper = os.path.join(os.path.dirname(__file__), "..", "tests", "cases", "simple")
>>> assert os.path.exists(path_to_wrapper)
>>> with open(os.path.join(path_to_wrapper, "wrap.wasm"), "rb") as f:
... wasm_module = f.read()
>>> assert isinstance(wasm_module, bytes)
>>> with open(os.path.join(path_to_wrapper, "wrap.info"), "rb") as f:
... manifest = deserialize_wrap_manifest(f.read())
>>> assert isinstance(manifest, AnyWrapManifest)
>>> wrapper = WasmWrapper(
... cast(FileReader, NotImplemented),
... wasm_module,
... manifest
... )
>>> assert isinstance(wrapper, WasmWrapper)
Invocation
~~~~~~~~~~
>>> message = "Hello, World!"
>>> args = {"arg": message}
>>> result = wrapper.invoke(
... uri=Uri.from_str("wrap://authority/path"),
... method="simpleMethod",
... args=args,
... client=cast(InvokerClient, NotImplemented),
... )
>>> assert result.encoded is True
>>> assert msgpack_decode(cast(bytes, result.result)) == message
Raw data
{
"_id": null,
"home_page": "",
"name": "polywrap-wasm",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Cesar",
"author_email": "cesar@polywrap.io",
"download_url": "https://files.pythonhosted.org/packages/96/5d/ae9a63224c8407a8089540790603d294a32ef6124064d0e4d02fb8ce61d3/polywrap_wasm-0.1.0.tar.gz",
"platform": null,
"description": "Polywrap Wasm\n=============\nThis package contains the runtime for executing Wasm wrappers.\n\nQuickstart\n----------\nThe following code snippet demonstrates how to use the runtime to execute a Wasm wrapper.\n\nImports\n~~~~~~~\n\n>>> import os\n>>> from typing import cast\n>>> from polywrap_core import Uri, FileReader, InvokerClient\n>>> from polywrap_wasm import WasmWrapper\n>>> from polywrap_msgpack import msgpack_decode\n>>> from polywrap_manifest import deserialize_wrap_manifest, AnyWrapManifest\n\nCreate a Wasm wrapper\n~~~~~~~~~~~~~~~~~~~~~\n\n>>> path_to_wrapper = os.path.join(os.path.dirname(__file__), \"..\", \"tests\", \"cases\", \"simple\")\n>>> assert os.path.exists(path_to_wrapper)\n>>> with open(os.path.join(path_to_wrapper, \"wrap.wasm\"), \"rb\") as f:\n... wasm_module = f.read()\n>>> assert isinstance(wasm_module, bytes)\n>>> with open(os.path.join(path_to_wrapper, \"wrap.info\"), \"rb\") as f:\n... manifest = deserialize_wrap_manifest(f.read())\n>>> assert isinstance(manifest, AnyWrapManifest)\n>>> wrapper = WasmWrapper(\n... cast(FileReader, NotImplemented),\n... wasm_module,\n... manifest\n... )\n>>> assert isinstance(wrapper, WasmWrapper)\n\nInvocation\n~~~~~~~~~~\n\n>>> message = \"Hello, World!\"\n>>> args = {\"arg\": message}\n>>> result = wrapper.invoke(\n... uri=Uri.from_str(\"wrap://authority/path\"),\n... method=\"simpleMethod\",\n... args=args,\n... client=cast(InvokerClient, NotImplemented),\n... )\n>>> assert result.encoded is True\n>>> assert msgpack_decode(cast(bytes, result.result)) == message\n",
"bugtrack_url": null,
"license": "",
"summary": "Polywrap Wasm",
"version": "0.1.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "da8faceb587c6a51e4969d80450ac01f0cd0bc27234cff632f3fa541494fc1e8",
"md5": "410fcf4495d51fa32fd62d646c4e600e",
"sha256": "485a7a01a6180c5e666f13c7c94fc941fddf9cd48e9c3730451ab055f2b1b828"
},
"downloads": -1,
"filename": "polywrap_wasm-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "410fcf4495d51fa32fd62d646c4e600e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10,<4.0",
"size": 24871,
"upload_time": "2023-09-02T11:49:17",
"upload_time_iso_8601": "2023-09-02T11:49:17.218672Z",
"url": "https://files.pythonhosted.org/packages/da/8f/aceb587c6a51e4969d80450ac01f0cd0bc27234cff632f3fa541494fc1e8/polywrap_wasm-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "965dae9a63224c8407a8089540790603d294a32ef6124064d0e4d02fb8ce61d3",
"md5": "1d0d64dcbb2af42d32053b315262b389",
"sha256": "fd1da31d9a581917ec1c5b371b2142097193906b6eb84e9fbac0bc6e9cd60a22"
},
"downloads": -1,
"filename": "polywrap_wasm-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "1d0d64dcbb2af42d32053b315262b389",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10,<4.0",
"size": 13339,
"upload_time": "2023-09-02T11:49:18",
"upload_time_iso_8601": "2023-09-02T11:49:18.739547Z",
"url": "https://files.pythonhosted.org/packages/96/5d/ae9a63224c8407a8089540790603d294a32ef6124064d0e4d02fb8ce61d3/polywrap_wasm-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-02 11:49:18",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "polywrap-wasm"
}