{"id":29419891,"url":"https://github.com/bytecodealliance/componentize-py","last_synced_at":"2026-01-02T22:32:24.791Z","repository":{"id":156905705,"uuid":"620555136","full_name":"bytecodealliance/componentize-py","owner":"bytecodealliance","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-02T00:00:52.000Z","size":902,"stargazers_count":208,"open_issues_count":22,"forks_count":28,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-07-12T00:44:55.418Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bytecodealliance.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-28T23:14:10.000Z","updated_at":"2025-07-07T09:34:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"5fa4c04b-e932-4385-b9f2-0bc60a64799a","html_url":"https://github.com/bytecodealliance/componentize-py","commit_stats":null,"previous_names":["bytecodealliance/componentize-py"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/bytecodealliance/componentize-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytecodealliance%2Fcomponentize-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytecodealliance%2Fcomponentize-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytecodealliance%2Fcomponentize-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytecodealliance%2Fcomponentize-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bytecodealliance","download_url":"https://codeload.github.com/bytecodealliance/componentize-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytecodealliance%2Fcomponentize-py/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264922908,"owners_count":23683705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-12T01:13:18.419Z","updated_at":"2026-01-02T22:32:24.764Z","avatar_url":"https://github.com/bytecodealliance.png","language":"Rust","readme":"# 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 \u003ehello.wit \u003c\u003cEOF\npackage example:hello;\nworld hello {\n  export hello: func() -\u003e 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 hello_guest\n```\n\nThen, use the `hello` module produced by the command above to write your app:\n\n```shell\ncat \u003eapp.py \u003c\u003cEOF\nimport wit_world\nclass WitWorld(wit_world.WitWorld):\n    def hello(self) -\u003e str:\n        return \"Hello, World!\"\nEOF\n```\n\nAnd finally generate the component:\n\n```shell\ncomponentize-py -d hello.wit -w hello componentize --stub-wasi app -o app.wasm\n```\n\nTo test it, you can install `wasmtime-py` and use it to generate host-side\nbindings for the component:\n\n```shell\npip install wasmtime\npython3 -m wasmtime.bindgen app.wasm --out-dir hello_host\n```\n\nNow we can write a simple host app using those bindings:\n\n```shell\ncat \u003ehost.py \u003c\u003cEOF\nfrom hello_host import Root\nfrom wasmtime import Config, Engine, Store\n\nconfig = Config()\nconfig.cache = True\nengine = Engine(config)\nstore = Store(engine)\nhello = Root(store)\nprint(f\"component says: {hello.hello(store)}\")\nEOF\n```\n\nAnd finally run it:\n\n```shell\n $ python3 host.py\ncomponent says: Hello, World!\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) -\u003e 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) -\u003e 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","funding_links":[],"categories":["WASM/WASI 🕸️","Tools"],"sub_categories":["Programming Language Support"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytecodealliance%2Fcomponentize-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytecodealliance%2Fcomponentize-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytecodealliance%2Fcomponentize-py/lists"}