You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
run python using the following command line wasmtime run --mapdir /::. ./python.wasm
Observe: everything works as expected. You end up in a REPL
try to 'mount' the python installation into a different directory (e.g. /usr) by running wasmtime run --mapdir /usr::. --env PYTHONHOME=/usr/lib/python3.11 ./python.wasm
Observe: you get
This is caused because there's logic within Python to know where to look for the stdlib that gets baked in. As of right now that logic looks for /lib for the stdlib, so mounting to /usr where the lib directory of a build is will cause that to fail as that would make /usr/lib be where the stdlib resides which isn't where Python will go looking.
There are two possible solutions to this annoyance. One is to patch things up to be relative to the binary location somehow. The other is to embed the pure Python code into the binary. The latter would require making sure there's a way to map to the source, if available, so that tracebacks are a bit nicer (otherwise the source code lines won't show up).
brettcannon
changed the title
Python WASM-WASI can't be executed from a different directory than root.
Python WASM-WASI can't be executed from a different directory than root
Jan 13, 2023
❯ wasmtime --mapdir /usr/local/lib::lib python.wasmPython 3.11.2 (tags/v3.11.2-dirty:878ead1, Mar 27 2023, 22:47:44) [Clang 14.0.4 (https://github.com/llvm/llvm-project 29f1039a7285a5c3a9c353d05414 on wasiType "help", "copyright", "credits" or "license" for more information.>>>
Bug report
wasmtime run --mapdir /::. ./python.wasm
Observe: everything works as expected. You end up in a REPL
/usr
) by runningwasmtime run --mapdir /usr::. --env PYTHONHOME=/usr/lib/python3.11 ./python.wasm
Observe: you get
I was not able to successfully execute Python when mounting the installation directory to something different than
/
Your environment
5.15.79.1-microsoft-standard-WSL2
The text was updated successfully, but these errors were encountered: