Fix pathing issue when wat2wasm is not globally installed

This commit is contained in:
Johan B.W. de Vries 2022-05-07 12:14:34 +02:00
parent 249c00f6a2
commit 6b717dba0b
2 changed files with 7 additions and 3 deletions

View File

@ -19,7 +19,7 @@ server:
python3.8 -m http.server
test: venv/.done
venv/bin/pytest tests $(TEST_FLAGS)
WAT2WASM=$(WAT2WASM) venv/bin/pytest tests $(TEST_FLAGS)
lint: venv/.done
venv/bin/pylint py2wasm

View File

@ -1,6 +1,8 @@
import io
import os
import subprocess
import sys
from tempfile import NamedTemporaryFile
from pywasm import binary
@ -9,14 +11,16 @@ from pywasm import Runtime
from py2wasm.utils import process
def wat2wasm(code_wat):
path = os.environ.get('WAT2WASM', 'wat2wasm')
with NamedTemporaryFile('w+t') as input_fp:
input_fp.write(code_wat)
input_fp.flush()
with NamedTemporaryFile('w+b') as output_fp:
result = subprocess.run(
subprocess.run(
[
'wat2wasm',
path,
input_fp.name,
'-o',
output_fp.name,