Browser build in any plans?

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:

BASECFLAGS=-m32 LDFLAGS=-m32 emconfigure ./configure --without-threads --without-pymalloc --disable-shared --without-signal-module --disable-toolbox-glue --disable-ipv6

as recommended in the emscripten pages for OSX.

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.

Happens immediately:

$ python
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:

A few notes in other forums seem to indicate a problem with freeze

cx-freeze problem on python3

another cx_freeze and python3.5

Oh, okay. Just ignore those _winapi and pep517 warnings, 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.

There is a bit more dump, I just didn’t scroll down. Now added to that file in the link below.

You can also see the browser directly at:

python simple demo

In case you know better what you are looking for, I put up the full build trace and the js console trace at:


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 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/…/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’"

Full trace at full build trace

Xcode version problem would not surprise me. That might be a good reason to do this on linux.

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 does. Do I need to copy/edit 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?

Or maybe just these lines from your example:

source /home/rdb/local/src/emsdk_portable/
export CXXFLAGS="-std=c++11"
python makepanda/ --nothing --use-direct --use-gles2 --optimize 4 --outputdir embuilt --target emscripten $@

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,

python makepanda/ --nothing --no-png --use-egg --use-zlib --no-freetype --use-bullet --no-openssl --use-direct --use-pview --use-gles2 --use-openal --use-vorbis --optimize 4 --outputdir embuilt --target emscripten --no-egl --python-incdir /Users/davidmarques/prog/Python-3.8.6/Include --python-libdir /Users/davidmarques/prog/Python-3.8.6/Lib


python makepanda/ --nothing --use-direct --use-gles2 --optimize 4 --outputdir embuilt --target emscripten --python-incdir /Users/davidmarques/prog/Python-3.8.6/Include --python-libdir /Users/davidmarques/prog/Python-3.8.6/Lib

no difference.

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.

This looks like an actual bug:

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
~~~~~ ^ ~~~~~~~~~~

The full trace is here

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.