Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Compile Python as a shared library and dynamically load it at runtime #1
I modified the code such that it build the Python shared library and compiles it to an asm.js module. I added an example that imports this shared library at runtime.
The compilation of the shared library works as does the import, but unfortunately I still get errors when running the code in production:
Summary of changes:
Any idea where the problem could be? Would be really great to get DLL loading to work, as this would allow (in my understanding) to dynamically import additional Python modules that rely on C extensions (such as numpy).
Accordingly to https://github.com/kripken/emscripten/wiki/Linking I believe that brings 5-10% slowdown, but that may be worth it.
The Py_Initialize error you get may be caused by not including any Python module (.py/.pyc) whatsoever in your
Also one needs to make Python actually compile dlopen support (e.g. add
Last it's worth noting that with 1.38.1, which defaults to WASM=1, dynamic linking is broken.
Did some experiments today while cleaning-up my code:
Looks like that doesn't work with Chromium indeed.
I asked about it at https://groups.google.com/forum/#!topic/emscripten-discuss/cE3hUV3fDSw
exactly what i have hit on chromium 71, is it practical to load the .wasm with a worker while waiting to dlopen() it, seems your position is a "no" ?
i have actually an enormous libpanda3d.js of 20MiB to download/eval after already huge libpython (3.7.2), before i can import anything.
i'm quite sure wasm would be faster but i got lost in contradictory documentation and outdated samples. maybe because of difference beetween browsers ?
sure but the official response there is "I don't think we can point to a specific time, it depends on a lot of things, in particular on how many people help out and how much - help is always welcome and necessary"
by "sample" i mean things i can work on from to help, as i already have a ffi interface for micropython-wasm ( based on @brion work there https://github.com/brion/libffi/tree/emscripten-work )