-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support jupyter-lite / pyodide #11
Comments
See https://go.dev/blog/wasi - try building with GOOS=wasip1 GOARCH=wasm - use go 1.21 or higher Update: this works up to the usage of the .so file in the Pyodide python REPL: Following the steps at https://pyodide.org/en/stable/development/building-and-testing-packages.html#building-and-testing-packages-out-of-tree pip install pyodide-build
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
PYODIDE_EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version)
./emsdk install ${PYODIDE_EMSCRIPTEN_VERSION}
./emsdk activate ${PYODIDE_EMSCRIPTEN_VERSION}
source emsdk_env.sh
cd ..
pyodide build
pyodide venv .venv-pyodide
source .venv-pyodide/bin/activate
pip install "./dist/esbuild_py-0.1.5-cp311-cp311-emscripten_3_1_46_wasm32.whl"
python >>> import ctypes
>>> from pathlib import Path
>>> import os
>>> lib_path = Path('build/lib.emscripten_3_1_46_wasm32-cpython-311/_esbuild.cpython-311-wasm32-emscripten.so').absolute()
>>> so = ctypes.CDLL(lib_path)
>>> so.transform
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/python311.zip/ctypes/__init__.py", line 389, in __getattr__
File "/lib/python311.zip/ctypes/__init__.py", line 394, in __getitem__
AttributeError: Tried to lookup unknown symbol "transform" in dynamic lib: /path/to/esbuild-py/build/lib.emscripten_3_1_46_wasm32-cpython-311/_esbuild.cpython-311-wasm32-emscripten.so
>>> so.__dict__
{'_name': PosixPath('/path/to/esbuild-py/build/lib.emscripten_3_1_46_wasm32-cpython-311/_esbuild.cpython-311-wasm32-emscripten.so'), '_FuncPtr': <class 'ctypes.CDLL.__init__.<locals>._FuncPtr'>, '_handle': 23285320} |
May not work without go:wasmexport - see golang/go#65199 although there is discussion of using main with stdin/out |
Alternative solution: use JS FFI to run the esbuild WASM when in pyodide contexts https://pyodide.org/en/stable/usage/api/python-api/code.html#pyodide.code.run_js - see discussion at pyodide/pyodide#4696 (comment) Can detect pyodide at runtime with https://pyodide.org/en/0.16.1/faq.html#how-to-detect-that-code-is-run-with-pyodide |
See
The text was updated successfully, but these errors were encountered: