Skip to content

Commit

Permalink
Use external process to generate componentize-py wasm binary
Browse files Browse the repository at this point in the history
Invoking the `componentize_py.componentize()` directly in process was
affecting the state of wasmtime somehow that resulted in
`test_instance.py` failing:

```
tests/test_instance.py ............Fatal Python error: Illegal instruction

Current thread 0x00000001e8d86100 (most recent call first):
  File "wasmtime-py/wasmtime/_bindings.py", line 2792 in wasmtime_instance_new
  File "wasmtime-py/wasmtime/_instance.py", line 34 in __init__
  File "wasmtime-py/tests/test_instance.py", line 179 in test_start_trap
Illegal instruction: 4
```

Don't know the root cause, but calling `componentize-py` in a separate
process fixes this issue.
  • Loading branch information
jamesls committed May 8, 2024
1 parent ead07e7 commit 0be271c
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions tests/bindgen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ def test_bare_funcs():
from wasmtime.bindgen import generate
import wasmtime
import contextlib
import componentize_py
import importlib
import tempfile
import subprocess
import shutil


TEST_ROOT = Path(__file__).parent
Expand Down Expand Up @@ -111,20 +112,17 @@ def testsuite_name(self):

def generate_bindings(testcase: BindgenTestCase):
wit_path = testcase.wit_full_path
python_path = [str(testcase.app_dir)]
stub_wasi = True
componentize_py = shutil.which('componentize-py')
if componentize_py is None:
raise RuntimeError("Could not find componentize-py executable.")
with tempfile.NamedTemporaryFile('w') as f:
output_wasm = str(f.name + '.wasm')
with chdir(testcase.app_dir):
componentize_py.componentize(wit_path,
testcase.world_name,
python_path,
[],
testcase.app_name,
output_wasm,
# isyswasfa=None
None,
stub_wasi)
subprocess.run([
componentize_py, '-d', str(wit_path), '-w', testcase.world_name,
'componentize', '--stub-wasi', testcase.app_name,
'-o', output_wasm
], check=True)
# Once we've done that now generate the python bindings.
testsuite_name = testcase.testsuite_name
with open(output_wasm, 'rb') as out:
Expand Down

0 comments on commit 0be271c

Please sign in to comment.