terminated with an error I should be able to track down but have not yet:
Error: Aborting compilation due to previous errors
em++: error: ‘/Users/davidmarques/prog/emsdk/node/12.18.1_64bit/bin/node /Users/davidmarques/prog/emsdk/upstream/emscripten/src/compiler.js /var/folders/n7/djb71lls55v7nqfm8fdv6rg40000gn/T/tmp989b439j.txt’ failed (1)
Storing dependency cache.
Elapsed Time: 42 min 30 sec
The following command returned a non-zero value: em++ -o embuilt/bin/deploy-stub.js -Lembuilt/lib -Lembuilt/tmp embuilt/tmp/cpython-38-darwin/deploy-stub.bc -s WARN_ON_UNDEFINED_SYMBOLS=1 --memory-init-file 0 -s EXIT_RUNTIME=1 thirdparty/emscripten-libs/python/lib/libpython3.8.a -O3
But, the build did create core.so, direct.so, and physics.so so I included them in my app build, and it seemed ok (about a hundred undefined _ZN…) – but still nothing when it runs, and no error. I am looking now to see if the problem is static vs shared libraries.
Not entirely true. There was an error (below) but from my reading of the source code continues with the fallback – “falling back to ArrayBuffer instantiation”. So I am not sure what to try next, I don’t know what is not working.
Sideways progress (?). core and direct are not getting linked in. This shows up in the build (link errors below) and then running the program errors on “missing function: initcore”.
I assume this has to do with them being shared instead of static libraries? Unless the init function name has changed? (init_core and Pyinit_core do not work either, and the same result if I build one of your sample programs).
These errors in the build seem to indicate the problem:
WARNING: Python cannot import extension modules under frozen Python packages; panda3d.core will be inaccessible. passing either -l to link in extension modules or use -x panda3d to exclude the entire package.
WARNING: Python cannot import extension modules under frozen Python packages; panda3d.direct will be inaccessible. passing either -l to link in extension modules or use -x panda3d to exclude the entire package.
WARNING: Python cannot import extension modules under frozen Python packages; panda3d.physics will be inaccessible. passing either -l to link in extension modules or use -x panda3d to exclude the entire package.
I haven’t figured out where to add the -l, I get an error when I put it on the emcc line. Still working on the idea that they are not compiled in properly, but not sure how to get there.
The -l flag is to pfreeze, which sets freezer.linkExtensionModules = True, so you could do that, but you could also just ignore the warning and make sure you link in core.bc and direct.bc yourself and call PyInit_core, etc.
Great. If you can get it working, in return I will replicate the process twice on new systems and write up the process in detail.
I trapped the editor.c and put it on my server here
I also put the entire directory a Maze.zip in case you want to look into what I did.
I am a little confused about the application/wasm. I looked at the js code and it seems the code already has a workaround (resulting in “falling back to ArrayBuffer instantiation”) and that code looks functionally the same as recommended in stack overflow.
It’s a web server configuration thing; it looks like you’re using Apache, so you need to set AddType application/wasm .wasm somewhere in the Apache configuration. But, as you said, it does have a fall back, but perhaps it is less efficient this way.
In fact, if you type this into the JS console, you’ll see that it does execute Python code:
Sorry, I wasn’t clear. I know panda3d is a package, I just meant that loading core module by itself not in the context of panda3d package puzzled me, but I don’t know any of the details of how the naming gets resolved, I didn’t see where the load put that module into the panda3d package. Just haven’t read through it enough.
Trying your suggestion… almost the same result “ModuleNotFoundError: No module named ‘panda3d.core’” – slight progress?
I didn’t mean to suggest that you didn’t know panda3d was a package; it’s the Python interpreter that evidently isn’t yet convinced of it. Evidently, Python 3 requires a __package__ member to be set on every module that is supposed to be a package.
Because we link in and initialize core.bc directly, we need to manually set up “panda3d” as a package, and then we attach the loaded “core” module into the module dictionary of the “panda3d” module, which is what the code in loadPanda is meant to do.