componentize-py


Namecomponentize-py JSON
Version 0.13.1 PyPI version JSON
download
home_pageNone
SummaryTool to package Python applications as WebAssembly components
upload_time2024-04-03 02:52:33
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords webassembly wasm component
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # componentize-py

**A [Bytecode Alliance](https://bytecodealliance.org/) project**

This is a tool to convert a Python application to a [WebAssembly
component](https://github.com/WebAssembly/component-model).  It takes the
following as input:

- a [WIT](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md) file or directory
- the name of a [WIT world](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#wit-worlds) defined in the above file or directory
- the name of a Python module which targets said world
- a list of directories in which to find the Python module and its dependencies

The output is a component which may be run using
e.g. [`wasmtime`](https://github.com/bytecodealliance/wasmtime).

## Getting Started

First, install [Python 3.10 or later](https://www.python.org/) and
[pip](https://pypi.org/project/pip/) if you don't already have them.  Then,
install `componentize-py`:

```shell
pip install componentize-py
```

Next, create or download the WIT world you'd like to target, e.g.:

```shell
cat >hello.wit <<EOF
package example:hello;
world hello {
  export hello: func() -> string;
}
EOF
```

If you're using an IDE or just want to examine the bindings produced for the WIT
world, you can generate them using the `bindings` subcommand:

```shell
componentize-py -d hello.wit -w hello bindings .
```

Then, use the `hello` module produced by the command above to write your app:

```shell
cat >app.py <<EOF
import hello
class Hello(hello.Hello):
    def hello(self) -> str:
        return "Hello, World!"
EOF
```

And finally generate the component:

```shell
componentize-py -d hello.wit -w hello componentize app -o app.wasm
```

See the
[examples](https://github.com/bytecodealliance/componentize-py/tree/main/examples)
directories for more examples, including various ways to run the components you've
created.

## Known Limitations

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`
the following may not work:

```python
import x

class Hello(hello.Hello):
    def hello(self) -> str:
        return x.y.foo()
```

That's because importing `x` does not necessarily resolve `y`.  This can be
addressed by modifying the code to import `y` at the top level of the file:

```python
from x import y

class Hello(hello.Hello):
    def hello(self) -> str:
        return y.foo()
```

This limitation is being tracked as [issue
#23](https://github.com/bytecodealliance/componentize-py/issues/23).

See [the issue tracker](https://github.com/bytecodealliance/componentize-py/issues) for other known issues.

## Contributing

See
[CONTRIBUTING.md](https://github.com/bytecodealliance/componentize-py/tree/main/CONTRIBUTING.md)
for details on how to contribute to the project and build it from source.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "componentize-py",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": "Fermyon Engineering <engineering@fermyon.com>",
    "keywords": "webassembly, wasm, component",
    "author": null,
    "author_email": "Fermyon Engineering <engineering@fermyon.com>",
    "download_url": "https://files.pythonhosted.org/packages/26/13/120eb91864d78fb8805a9c526cbbc86ab55316fff75553674e430cd76a20/componentize_py-0.13.1.tar.gz",
    "platform": null,
    "description": "# componentize-py\n\n**A [Bytecode Alliance](https://bytecodealliance.org/) project**\n\nThis is a tool to convert a Python application to a [WebAssembly\ncomponent](https://github.com/WebAssembly/component-model).  It takes the\nfollowing as input:\n\n- a [WIT](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md) file or directory\n- the name of a [WIT world](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#wit-worlds) defined in the above file or directory\n- the name of a Python module which targets said world\n- a list of directories in which to find the Python module and its dependencies\n\nThe output is a component which may be run using\ne.g. [`wasmtime`](https://github.com/bytecodealliance/wasmtime).\n\n## Getting Started\n\nFirst, install [Python 3.10 or later](https://www.python.org/) and\n[pip](https://pypi.org/project/pip/) if you don't already have them.  Then,\ninstall `componentize-py`:\n\n```shell\npip install componentize-py\n```\n\nNext, create or download the WIT world you'd like to target, e.g.:\n\n```shell\ncat >hello.wit <<EOF\npackage example:hello;\nworld hello {\n  export hello: func() -> string;\n}\nEOF\n```\n\nIf you're using an IDE or just want to examine the bindings produced for the WIT\nworld, you can generate them using the `bindings` subcommand:\n\n```shell\ncomponentize-py -d hello.wit -w hello bindings .\n```\n\nThen, use the `hello` module produced by the command above to write your app:\n\n```shell\ncat >app.py <<EOF\nimport hello\nclass Hello(hello.Hello):\n    def hello(self) -> str:\n        return \"Hello, World!\"\nEOF\n```\n\nAnd finally generate the component:\n\n```shell\ncomponentize-py -d hello.wit -w hello componentize app -o app.wasm\n```\n\nSee the\n[examples](https://github.com/bytecodealliance/componentize-py/tree/main/examples)\ndirectories for more examples, including various ways to run the components you've\ncreated.\n\n## Known Limitations\n\nCurrently, the application can only import dependencies during build time, which\nmeans any imports used at runtime must be resolved at the top level of the\napplication module.  For example, if `x` is a module with a submodule named `y`\nthe following may not work:\n\n```python\nimport x\n\nclass Hello(hello.Hello):\n    def hello(self) -> str:\n        return x.y.foo()\n```\n\nThat's because importing `x` does not necessarily resolve `y`.  This can be\naddressed by modifying the code to import `y` at the top level of the file:\n\n```python\nfrom x import y\n\nclass Hello(hello.Hello):\n    def hello(self) -> str:\n        return y.foo()\n```\n\nThis limitation is being tracked as [issue\n#23](https://github.com/bytecodealliance/componentize-py/issues/23).\n\nSee [the issue tracker](https://github.com/bytecodealliance/componentize-py/issues) for other known issues.\n\n## Contributing\n\nSee\n[CONTRIBUTING.md](https://github.com/bytecodealliance/componentize-py/tree/main/CONTRIBUTING.md)\nfor details on how to contribute to the project and build it from source.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Tool to package Python applications as WebAssembly components",
    "version": "0.13.1",
    "project_urls": {
        "repository": "https://github.com/bytecodealliance/componentize-py"
    },
    "split_keywords": [
        "webassembly",
        " wasm",
        " component"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e5b3ccee66d3436e440c7568fa7f56da2ae6a21240d7b05eb45a5c4cb65fcb3d",
                "md5": "c228e24252d9f5d0ebbb4906e6fea870",
                "sha256": "edf96917f6cb99e5b21509f0556bd29f364f7cf3b2fde8020b8d7629f02e9246"
            },
            "downloads": -1,
            "filename": "componentize_py-0.13.1-cp37-abi3-macosx_10_12_x86_64.whl",
            "has_sig": false,
            "md5_digest": "c228e24252d9f5d0ebbb4906e6fea870",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": null,
            "size": 38802845,
            "upload_time": "2024-04-03T02:51:15",
            "upload_time_iso_8601": "2024-04-03T02:51:15.555577Z",
            "url": "https://files.pythonhosted.org/packages/e5/b3/ccee66d3436e440c7568fa7f56da2ae6a21240d7b05eb45a5c4cb65fcb3d/componentize_py-0.13.1-cp37-abi3-macosx_10_12_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "75fb4cab837e3f623e438cafa1a1a0c652c5ff93af96419317c4926ec5cac225",
                "md5": "a85825ef3843ff5e4b161a49c45cda2e",
                "sha256": "aeb40d9443f4ea8408b092f8480e60ee219ffe98db6c5baf57a3ecc7294976b2"
            },
            "downloads": -1,
            "filename": "componentize_py-0.13.1-cp37-abi3-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "a85825ef3843ff5e4b161a49c45cda2e",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": null,
            "size": 38513309,
            "upload_time": "2024-04-03T02:51:32",
            "upload_time_iso_8601": "2024-04-03T02:51:32.176313Z",
            "url": "https://files.pythonhosted.org/packages/75/fb/4cab837e3f623e438cafa1a1a0c652c5ff93af96419317c4926ec5cac225/componentize_py-0.13.1-cp37-abi3-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "189aa8afa3677a0035da964868a431d3fb6cfcc9e1028f4ac3d462532689a0df",
                "md5": "cb4a1da8073e02fa588f38e1220d97bf",
                "sha256": "5fd9bfa636fd52b90a2bc90756173688e60093334fc38c3017bb9eb3b1d72a43"
            },
            "downloads": -1,
            "filename": "componentize_py-0.13.1-cp37-abi3-manylinux_2_28_aarch64.whl",
            "has_sig": false,
            "md5_digest": "cb4a1da8073e02fa588f38e1220d97bf",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": null,
            "size": 40175767,
            "upload_time": "2024-04-03T02:51:52",
            "upload_time_iso_8601": "2024-04-03T02:51:52.571395Z",
            "url": "https://files.pythonhosted.org/packages/18/9a/a8afa3677a0035da964868a431d3fb6cfcc9e1028f4ac3d462532689a0df/componentize_py-0.13.1-cp37-abi3-manylinux_2_28_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8251ec45f73b23c7cd16193023019baddb47a17a777edc8e1d920dccc4516e35",
                "md5": "3fb70782656e709b33fedf7fcedeb03f",
                "sha256": "4c4db20b31026319e14f449151a40fcd6fa3c8edb47285d4b8b88037ac0f46eb"
            },
            "downloads": -1,
            "filename": "componentize_py-0.13.1-cp37-abi3-manylinux_2_28_x86_64.whl",
            "has_sig": false,
            "md5_digest": "3fb70782656e709b33fedf7fcedeb03f",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": null,
            "size": 40471037,
            "upload_time": "2024-04-03T02:52:11",
            "upload_time_iso_8601": "2024-04-03T02:52:11.010519Z",
            "url": "https://files.pythonhosted.org/packages/82/51/ec45f73b23c7cd16193023019baddb47a17a777edc8e1d920dccc4516e35/componentize_py-0.13.1-cp37-abi3-manylinux_2_28_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1bbed4fef62ccddc84fe9867d7c9a77b9fbe2daf6b27d9aa8ec24c784f25750f",
                "md5": "f393e5ae2c18d05fb7effcc4b8586a7e",
                "sha256": "d7eda4ec53432f88ae3031e02dfee149a94903db24dcad70ffc5cc42b0099997"
            },
            "downloads": -1,
            "filename": "componentize_py-0.13.1-cp37-abi3-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "f393e5ae2c18d05fb7effcc4b8586a7e",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": null,
            "size": 37840958,
            "upload_time": "2024-04-03T02:52:30",
            "upload_time_iso_8601": "2024-04-03T02:52:30.212072Z",
            "url": "https://files.pythonhosted.org/packages/1b/be/d4fef62ccddc84fe9867d7c9a77b9fbe2daf6b27d9aa8ec24c784f25750f/componentize_py-0.13.1-cp37-abi3-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2613120eb91864d78fb8805a9c526cbbc86ab55316fff75553674e430cd76a20",
                "md5": "c526a9a3aacc2ba90cf6ffb1fe5ab03e",
                "sha256": "75edcb3497fcbe38e81fab57fbbd0be5d2bbcbb7af8c9b7f832bad05aeef9578"
            },
            "downloads": -1,
            "filename": "componentize_py-0.13.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c526a9a3aacc2ba90cf6ffb1fe5ab03e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 152918,
            "upload_time": "2024-04-03T02:52:33",
            "upload_time_iso_8601": "2024-04-03T02:52:33.168037Z",
            "url": "https://files.pythonhosted.org/packages/26/13/120eb91864d78fb8805a9c526cbbc86ab55316fff75553674e430cd76a20/componentize_py-0.13.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-03 02:52:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bytecodealliance",
    "github_project": "componentize-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "componentize-py"
}
        
Elapsed time: 0.28671s