Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-127111: Emscripten Make web example work again#127113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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 alsobuilds the web_example. The web_example needs:1. python.html, copied2. python.worker.mjs copied3. python.mjs and python.wasm output from the main linking of the Python interpreter4. The webserver that sets COOP and COEP5. python3.14.zipThis last is created by the `wasm_assets.py` script, which required a prettysmall set of changes to work fine for us.The last thing that should be done is the `python.worker.mjs` script should bemade independent of the Python version: currently 3.14 is hard coded. I raninto trouble doing this, so maybe I can leave it to a followup.
JeffersGlass commentedNov 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 found127.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 found127.0.0.1 - - [26/Nov/2024 07:28:17]"GET /mini-coi.js HTTP/1.1" 404 - |
hoodmane commentedNov 26, 2024
Thanks for testing it@JeffersGlass. Maybe I'll have to try a different CDN. It worked fine for me though... |
freakboy3742 left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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 arepython Tools/wasm/emscripten build and openweb_example/python.html - I get 2 errors.
First, during the build process, the macOS version ofrealpath apparently doesn't honor the-s flag, so the usage on L223 of theTools/emscripten/__main__.py raises an error andpython Tools/wasm/emscripten build doesn't complete.
Second, I wasn't able to see the example working in practice. When I openfile:///.../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 usepython -m http.server to serve theweb_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:21EDIT: Strike that - I see from@JeffersGlass comment thatpython web_example/server.py is the expected operation; that works for me. That only leaves the issue withrealpath 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 |
hoodmane commentedNov 29, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Apple's crappy gnu coreutils strike again. |
hoodmane commentedNov 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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 commentedDec 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 fixesdon't disparage BSD coreutilsfix indentationrealpath not readlink
hoodmane commentedDec 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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.
bfb0788 intopython:mainUh oh!
There was an error while loading.Please reload this page.
Moves the Emscripten web example into a standalone folder, and updates Makefile targets to build the web example. Instructions for usage havealso been added.
Moves the Emscripten web example into a standalone folder, and updates Makefile targets to build the web example. Instructions for usage havealso been added.
Uh oh!
There was an error while loading.Please reload this page.
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.