Oh, but note that the C code in freezify will need further changes, because the module initialization syntax in Python changed. For example, what was inithashlib is now PyInit_hashlib. Some other modules may be removed or unnecessary, it may be good to comment out some of those lines and add them back in as you find they are needed.
If all the extension modules are linked in libpython3.8.a, then you should not need to pick up additional .o files.
I have been working on exactly that, assuming that your C code was out of date. In the process of trying to figure out all the new errors, not a simple 1:1, but will work through it.
Well, the simple answer is that commenting them all out reduces the missing globals to just 2:
__posix_spawnx, task_manager_poll
Result of running the html file is the same.
But I noted that now (after a rebuild of Python with no --without configure flags) I have two missing globals at the top, _winapi and pep517.
Iāll try going back to a different build of Python, but I donāt think it will make a difference. But it would not surprise me if the emscripten build of Python is a problem. I am using:
I donāt think __posix_spawnx is something we can provide, there may need to be another Python configuration flag set to disable that. However, I think that we may be able to ignore it until it becomes a problem.
task_manager_poll sounds like it might be a Panda thing? Iām not at my laptop right now but Iāll look later to see what I was using that for.
I donāt know why something is trying to import _winapi or pep517. Can you give me the exact error message that this is showing? Clearly, _winapi is not going to be available, but itās not supposed to be.
$ python dmm_freezify.py
There are some missing modules: [ā_winapiā, āpep517ā]
There is a _winapi.c in the Python dist, and I was thinking of forcing that in the Makefile (but as you say, not a win system), but donāt know what I can do about pep517. I remember that was required in the requirements.txt builds.
Not sure what to try. Playing with the emscripten configure flags doesnāt seem to make any difference, but maybe I havenāt done the right combination.
BTW, the full java console error (I assume the map and MIME problems are irrelevant, but just for context) is:
Some cookies are misusing the recommended āSameSiteā attribute 2
wasm streaming compile failed: TypeError: Response has unsupported MIME type editor.html:1:516
Oh, okay. Just ignore those _winapi and pep517 warnings, FreezeTool.py just picks up all imported modules, even conditional ones, that doesnāt necessarily indicate a problem.
The SystemError: unknown opcode seems like the error to actually look at. This might indicate a problem with the frozen bytecode somehow, hmm. Setting Py_VerboseFlag to 1 might shed additional light.
Oh, hang on. Are you running freeze with another copy of Python 3.8? If you are running it with a different version, then that would result in a different bytecode that the built interpreter canāt run.
Also, you are passing in versions of libssl.a and libcrypto.a that appear to be compiled for the host, rather than for emscripten, which isnāt useful. I suggest leaving those out.
I really recommend commenting out the Py_SetProgramName call, since it might crash given that the wrong argument type is passed.
I wondered about the versions (though I was using 3.9 for both previously). I will switch back since that is what I have installed. But emscripten build of 3.9.1 makes over a hundred warnings for mismatched parameters and several errors that are hard to simply comment out. I guess I will install 3.8.6 and go from there.
OK, that worked! On the simple python script. Now try to add panda3.
Does the build from source maybe not work on OSX? Following README.md I still get lots of errors. I added the thirdparty but still get these warnings:
WARNING: Could not locate thirdparty package fftw, excluding from build
WARNING: Could not locate thirdparty package gles, excluding from build
WARNING: Could not locate thirdparty package gles2, excluding from build
WARNING: Could not locate thirdparty package egl, excluding from build
WARNING: Could not locate pkg-config package gtkĀ±2.0, excluding from build
Generating dependenciesā¦
WARNING: file depends on Python but is not in an ABI-specific directory: built/bin/p3dcparse
WARNING: file depends on Python but is not in an ABI-specific directory: built/bin/deploy-stub
WARNING: file depends on Python but is not in an ABI-specific directory: built/bin/deploy-stubw
Then 20 errors, all like this:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ā¦/include/c++/v1/ctime:70:9: error:
no member named āctimeā in the global namespace
using ::ctime;
~~^
About half of them were āforward declaration of ātmāā or " member access into incomplete type ātmā"
Xcode is not relevant and not being used. You need to compile with emscripten (with the emsdk active before you run makepanda). You are currently building for macOS. Pass --target emscripten, and drop --universal.
Sorry, I am a little slow here. Do you mean compile panda3d using emcc? So I need to get a list of all .py files and do a pfreeze then emcc -o file.o for each one? I guess I thought that is what makepanda.py does. Do I need to copy/edit makepanda.py into a makefile for emscripten to use?
Sorry, something was a big jump there for me, I didnāt follow. I understand the goal and why I have to do it, but not sure how to get from here to there other than how I did my own app. But the difference here is that I have hundreds of .py files and no āmainā to start. I guess that is what all the cmake files are for in your example?
But āCannot cross-compile for emscripten from darwinā
That seems to indicate I need to be on linux or windows? Or that I am using the wrong python. (But my emscripten build of python did not result in a usable python, just the library. I will see if I can fix that.)
No, you donāt need to do all that, but you do need to run makepanda with --target emscripten, otherwise makepanda will build for your macOS machine instead of for the browser environment.
The error message suggests you didnāt check out the webgl-port branch of the repository, but you checked out some other branch.
Ah. I did check it out, and have referenced it many times, but I assumed you had the 2015 version of panda3d there. So I downloaded the panda3d source directly and tried to compile from that. Will the old version of panda3d work? I will then have to debug my app with the old version?
BTW, I changed the app to use csv instead of pandas, to get rid of the problem with pandas. Had to figure out a few new little glitches, but no big deal.
I donāt understand what you mean with the old version of panda3d. You need to check out the Panda3D source repository using Git and point it to the webgl-port branch. The last commit on the webgl-port branch was made a month ago.
OK, that is what I did, am building it from there now. I did notice a December date on most of the files, but the thread discussing that port was all about 2.7 of python and started in 2015, so I assumed it used an old version of panda3. My bad assumption.
Warnings on every item (mostly āoverriding currently unsupported use of floating point exceptions on this targetā), but it did build. But what it built are .bc files and no modules core or direct. Iāll keep working through it, see if I can figure it out.
Did you see warnings about makepanda missing the Python thirdparty library? Without passing --python-incdir and --python-libdir, makepanda will expect Python to be in include and lib directories under thirdparty/emscripten-libs/python under the source tree.
Did not see any warnings about thirdparty. This was the only unusual warning:
em++: warning: linking a library with -shared will emit a static object file. This is a form of emulation to support existing build systems. If you want to build a runtime shared library use the SIDE_MODULE setting. [-Wemcc]
But I assume not relevant, because we want static not runtime.
I rebuilt with those pointers to the python include and python library,
The problem I have for the next step is that the there are no core and direct (the build is also looking for panda3d.physics, warning) in the panda3d directory. I started all over from downloading the webgl-port, setting emsdk_env, with the identical result.
So sorry to take up so much of your time. If I thought I would need this much help I wouldnāt have started. Apologies.
In file included from panda/src/pgraphnodes/p3pgraphnodes_composite2.cxx:4:
panda/src/pgraphnodes/sceneGraphAnalyzer.cxx:38:13: warning: result of comparison of constant 4294967296 with expression of type āsize_tā (aka āunsigned longā) is always false [-Wtautological-constant-out-of-range-compare]
if (bytes > 4294967296) { // 4 GiB
~~~~~ ^ ~~~~~~~~~~
FWIW, the freezify now works with the panda libraries included (even though they were .bc, not sure why it worked now), but of course the app does nothing without core and direct.
FYI, I had to add ā-s DISABLE_EXCEPTION_THROWING=0ā to the emcc command.
Thatās just a warning, and it looks like a harmless one.
Thanks for the full trace. Apparently you built with the --nothing flag, which tells makepanda to exclude all packages not explicitly named (including Python!). You will have to add --use-python to add Python, at the very least, and possibly also --use-zlib, and later you can add --use-vorbis, --use-freetype, and --use-png.