Uh oh!
There was an error while loading. Please reload this page.
gh-127111: Emscripten Make web example work again - #127113
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I moved the web example from `Tools/wasm` into `Tools/wasm/emscripten/web_example`. I also added a new target `build_emscripten` which is `build_wasm` but also builds the web_example. The web_example needs: 1. python.html, copied 2. python.worker.mjs copied 3. python.mjs and python.wasm output from the main linking of the Python interpreter 4. The webserver that sets COOP and COEP 5. python3.14.zip This last is created by the `wasm_assets.py` script, which required a pretty small set of changes to work fine for us. The last thing that should be done is the `python.worker.mjs` script should be made independent of the Python version: currently 3.14 is hard coded. I ran into trouble doing this, so maybe I can leave it to a followup.
JeffersGlass
commented
Nov 26, 2024
The Emscripten seems to work fine, however when viewing the web_example (using the provided server.py), I still get a CORS error: # Shell
(base) jglass@jglass-XPS-8930:~/Documents/cpython$ python Tools/wasm/emscripten/web_example/server.py Serving HTTP on 127.0.0.1 port 8000 (http://127.0.0.1:8000/) ...
127.0.0.1 - - [26/Nov/2024 07:28:13] "GET /Tools/wasm/emscripten/web_example/python.html HTTP/1.1" 200 -
127.0.0.1 - - [26/Nov/2024 07:28:15] "GET /Tools/wasm/emscripten/web_example/python.worker.mjs HTTP/1.1" 200 -
127.0.0.1 - - [26/Nov/2024 07:28:15] code 404, message File not found
127.0.0.1 - - [26/Nov/2024 07:28:15] "GET /Tools/wasm/emscripten/web_example/python.mjs HTTP/1.1" 404 -
127.0.0.1 - - [26/Nov/2024 07:28:17] code 404, message File not found
127.0.0.1 - - [26/Nov/2024 07:28:17] "GET /mini-coi.js HTTP/1.1" 404 - |
hoodmane
commented
Nov 26, 2024
Thanks for testing it @JeffersGlass. Maybe I'll have to try a different CDN. It worked fine for me though... |
There was a problem hiding this comment.
The general shape of this makes sense.
From a general process perspective, this needs a news entry to describe that that web example has been updated, and documentation in the WASM README on how to run the example.
However, assuming the usage instructions are python Tools/wasm/emscripten build and open web_example/python.html - I get 2 errors.
First, during the build process, the macOS version of realpath apparently doesn't honor the -s flag, so the usage on L223 of the Tools/emscripten/__main__.py raises an error and python Tools/wasm/emscripten build doesn't complete.
Second, I wasn't able to see the example working in practice. When I open file:///.../web_example/python.html in Chrome, I get the following error:
python.html:50 Uncaught (in promise) SecurityError: Failed to construct 'Worker': Script at 'file:///Users/rkm/projects/python/cpython/cross-build/wasm32-emscripten/web_example/python.worker.mjs' cannot be accessed from origin 'null'.
at WorkerManager.initialiseWorker (python.html:50:27)
at new WorkerManager (python.html:45:14)
at window.onload (python.html:350:33)
If I use python -m http.server to serve the web_example folder, and open python.html, I get:
Uncaught ReferenceError: SharedArrayBuffer is not defined
at new StdinBuffer (python.worker.mjs:5:24)
at python.worker.mjs:62:21
EDIT: Strike that - I see from @JeffersGlass comment that python web_example/server.py is the expected operation; that works for me. That only leaves the issue with realpath failing during the build (that's a problem that I didn't pick up with my review of #126903, but we can fix it here)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Apple's crappy gnu coreutils strike again. |
hoodmane
commented
Nov 30, 2024
@JeffersGlass This isn't a CORS error, you're serving it out of the source directory whereas you need to serve it out of the output directory: ./cross-build/wasm32-emscripten/web_example/server.py |
freakboy3742
left a comment
There was a problem hiding this comment.
A couple of documentation tweaks; I'm still having issues with realpath as well. Not sure if I'm doing something wrong, though.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
hoodmane
commented
Dec 2, 2024
Thanks for the review @freakboy3742! I continue to appreciate your detailed PR feedback. I've been enjoying working with you so far on this. |
Apply shell check fixes don't disparage BSD coreutils fix indentation realpath not readlink
hoodmane
commented
Dec 2, 2024
@freakboy3742 I reverted changes to |
Thanks for making the requested changes! @freakboy3742: please review the changes made to this pull request. |
freakboy3742
left a comment
There was a problem hiding this comment.
This obviously needs the changes from #127506 to be fully usable on macOS; but I'm happy with this as a set of changes in itself.
Moves the Emscripten web example into a standalone folder, and updates Makefile targets to build the web example. Instructions for usage have also been added.
Moves the Emscripten web example into a standalone folder, and updates Makefile targets to build the web example. Instructions for usage have also been added.
I moved the web example from
Tools/wasmintoTools/wasm/emscripten/web_example. I also added a new targetbuild_emscriptenwhich isbuild_wasmbut also builds the web_example. The web_example needs:This last is created by the
wasm_assets.pyscript, which required a pretty small set of changes to work fine for us.The last thing that should be done is the
python.worker.mjsscript should be made independent of the Python version: currently 3.14 is hard coded. I ran into trouble doing this, so maybe I can leave it to a followup.