bytecodealliance / componentize-py

Apache License 2.0
136 stars 13 forks source link

pyo3_runtime.PanicException: internal error: entered unreachable code #31

Closed eliabieri closed 11 months ago

eliabieri commented 11 months ago

I ran into the following issue:

thread '<unnamed>' panicked at 'internal error: entered unreachable code', src/lib.rs:450:35
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/Users/eliabieri/Library/Caches/pypoetry/virtualenvs/widget-4qY9vehV-py3.11/bin/componentize-py", line 8, in <module>
    sys.exit(script())
             ^^^^^^^^
pyo3_runtime.PanicException: internal error: entered unreachable code

Steps to reproduce

Prerequisites: Poetry 1) Clone repo git clone --recurse-submodules git@github.com:eliabieri/wg_display_widget_py.git 2) Install dependencies poetry install 3) Generate bindings poetry run componentize-py --wit-path wg_display_widget_wit/wit --world widget bindings . 4) Generate component poetry run componentize-py --wit-path wg_display_widget_wit/wit --world widget componentize --output widget.wasm --python-path widget widget

dicej commented 11 months ago

Hi @eliabieri. Thanks for reporting this.

I just opened https://github.com/bytecodealliance/componentize-py/pull/32, which should fix the panic. I'll publish a 0.4.3 release with the fix soon.

Also, you'll need to rename widget/widget.py to something else (e.g. widget/app.py) because componentize-py gets confused when there's two widget modules in the path (the one you wrote and the one that gets generated from widget.wit).

With both of the above changes, I was able to build the component successfully. I haven't tried running it yet, since I'm not sure how to set up the appropriate host environment. If you have trouble with that, please let me know how to reproduce it, and I'll be happy to help debug.

dicej commented 11 months ago

One more thing: you might need to add a from widget import types line to your code. See https://github.com/bytecodealliance/componentize-py#known-limitations for details.

eliabieri commented 11 months ago

Thank you, @dicej. ✨ Thanks to your superfast and detailed response, I was now able to build the component.

The component cannot be instantiated yet in my setup, but that most likely another issue. Going to resolve this issue and open up another one if other problems arise.