Skip to content

gh-124621: Emscripten: Support pyrepl in browser - #136931

Merged
ambv merged 8 commits into
python:mainfrom
hoodmane:pyrepl-emscripten
Jul 22, 2025
Merged

gh-124621: Emscripten: Support pyrepl in browser#136931
ambv merged 8 commits into
python:mainfrom
hoodmane:pyrepl-emscripten

Conversation

@hoodmane

@hoodmanehoodmane commented Jul 21, 2025

Copy link
Copy Markdown
Contributor

Basic support for pyrepl in Emscripten. Limitations:

  • requires JSPI
  • no signal handling implemented

As followup work, it would be nice to implement a webworker variant for when JSPI is not available and proper signal handling.

Because it requires JSPI, it doesn't work in Safari. Firefox requires setting an experimental flag. All the Chromiums have full support since May. Until we make it work without JSPI, let's keep the original web_example around.

cc @ambv

Basic support for pyrepl in Emscripten. Limitations:
* requires JSPI
* no signal handling implemented
As followup work, it would be nice to implement a webworker variant
for when JSPI is not available and proper signal handling.
Because it requires JSPI, it doesn't work in Safari. Firefox requires
setting an experimental flag. All the Chromiums have full support since
May. Until we make it work without JSPI, let's keep the original web_example
around.
@hoodmane

Copy link
Copy Markdown
ContributorAuthor

@adqm If you want to work on any of the followup tasks, let me know. I'm happy to meet / provide suggestions as well if you need them.

@hoodmane

Copy link
Copy Markdown
ContributorAuthor

!buildbot emscripten

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @hoodmane for commit 50c9932 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F136931%2Fmerge

The command will test the builders whose names match following regular expression: emscripten

The builders matched are:

  • WASM Emscripten PR

@hoodmanehoodmane added topic-repl Related to the interactive shell OS-emscripten labels Jul 21, 2025
@hoodmane

Copy link
Copy Markdown
ContributorAuthor

!buildbot emscripten

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @hoodmane for commit c83eb65 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F136931%2Fmerge

The command will test the builders whose names match following regular expression: emscripten

The builders matched are:

  • WASM Emscripten PR

@hoodmanehoodmane changed the title gh-124621: Emscripten: Support pyreplgh-124621: Emscripten: Support pyrepl in browserJul 21, 2025
@hoodmane

Copy link
Copy Markdown
ContributorAuthor

!buildbot emscripten

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @hoodmane for commit 60e65f5 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F136931%2Fmerge

The command will test the builders whose names match following regular expression: emscripten

The builders matched are:

  • WASM Emscripten PR

Comment threadTools/wasm/emscripten/web_example_pyrepl_jspi/index.html
Comment threadTools/wasm/emscripten/web_example_pyrepl_jspi/index.html Outdated
Comment threadTools/wasm/emscripten/web_example_pyrepl_jspi/index.html Outdated
Comment threadModules/posixmodule.c
@ambvambv added the needs backport to 3.14 bugs and security fixes label Jul 22, 2025
@ambv
ambv merged commit c933a6b into python:mainJul 22, 2025
51 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @hoodmane for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @hoodmane and @ambv, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker c933a6bb329bb97bc7e448388dad1b74f7ca4baa 3.14

hoodmane added a commit to hoodmane/cpython that referenced this pull request Jul 22, 2025
Basic support for pyrepl in Emscripten. Limitations:
* requires JSPI
* no signal handling implemented
As followup work, it would be nice to implement a webworker variant
for when JSPI is not available and proper signal handling.
Because it requires JSPI, it doesn't work in Safari. Firefox requires
setting an experimental flag. All the Chromiums have full support since
May. Until we make it work without JSPI, let's keep the original web_example
around.
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Éric <merwok@netwok.org>
(cherry picked from commit c933a6b)
@hoodmane
hoodmane deleted the pyrepl-emscripten branch July 22, 2025 10:28
@bedevere-app

Copy link
Copy Markdown

GH-136978 is a backport of this pull request to the 3.14 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.14 bugs and security fixes label Jul 22, 2025
ambv added a commit to ambv/cpython that referenced this pull request Jul 22, 2025
…GH-136931)
Basic support for pyrepl in Emscripten. Limitations:
* requires JSPI
* no signal handling implemented
As followup work, it would be nice to implement a webworker variant
for when JSPI is not available and proper signal handling.
Because it requires JSPI, it doesn't work in Safari. Firefox requires
setting an experimental flag. All the Chromiums have full support since
May. Until we make it work without JSPI, let's keep the original web_example
around.
(cherry picked from commit c933a6b)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Éric <merwok@netwok.org>
@bedevere-app

Copy link
Copy Markdown

GH-136988 is a backport of this pull request to the 3.14 branch.

hoodmane added a commit to hoodmane/cpython that referenced this pull request Jul 22, 2025
If there is an error, we have to return `-errno` not positive errno.
Included in backport of pythonGH-136931: python#136988
ambv added a commit that referenced this pull request Jul 22, 2025
…H-136988)
Basic support for pyrepl in Emscripten. Limitations:
* requires JSPI
* no signal handling implemented
As followup work, it would be nice to implement a webworker variant
for when JSPI is not available and proper signal handling.
Because it requires JSPI, it doesn't work in Safari. Firefox requires
setting an experimental flag. All the Chromiums have full support since
May. Until we make it work without JSPI, let's keep the original web_example
around.
(cherry picked from commit c933a6b)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Éric <merwok@netwok.org>
ambv pushed a commit that referenced this pull request Jul 22, 2025
If there is an error, we have to return `-errno` not positive errno.
Included in backport of GH-136931: #136988
@adqm

adqm commented Jul 23, 2025

Copy link
Copy Markdown
Contributor

Exciting stuff!

@adqm If you want to work on any of the followup tasks, let me know. I'm happy to meet / provide suggestions as well if you need them.

@hoodmane, I'm certainly happy to help where I can, which is probably more on the web-UI side than on the low-level-details side (though I'd be happy to learn more there, too). If there are particular things you think it would be helpful for me to look at, just let me know; otherwise, I'll poke at the demo and see where to go from there. Happy to coordinate however makes sense for you.

@hoodmane

Copy link
Copy Markdown
ContributorAuthor

more on the web-UI side

Help with the UI or anything is very welcome!

taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
Basic support for pyrepl in Emscripten. Limitations:
* requires JSPI
* no signal handling implemented
As followup work, it would be nice to implement a webworker variant
for when JSPI is not available and proper signal handling.
Because it requires JSPI, it doesn't work in Safari. Firefox requires
setting an experimental flag. All the Chromiums have full support since
May. Until we make it work without JSPI, let's keep the original web_example
around.
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Éric <merwok@netwok.org>
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
If there is an error, we have to return `-errno` not positive errno.
Included in backport of pythonGH-136931: python#136988
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
Basic support for pyrepl in Emscripten. Limitations:
* requires JSPI
* no signal handling implemented
As followup work, it would be nice to implement a webworker variant
for when JSPI is not available and proper signal handling.
Because it requires JSPI, it doesn't work in Safari. Firefox requires
setting an experimental flag. All the Chromiums have full support since
May. Until we make it work without JSPI, let's keep the original web_example
around.
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Éric <merwok@netwok.org>
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
If there is an error, we have to return `-errno` not positive errno.
Included in backport of pythonGH-136931: python#136988
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2025
…GH-136931) (pythonGH-136988)
Basic support for pyrepl in Emscripten. Limitations:
* requires JSPI
* no signal handling implemented
As followup work, it would be nice to implement a webworker variant
for when JSPI is not available and proper signal handling.
Because it requires JSPI, it doesn't work in Safari. Firefox requires
setting an experimental flag. All the Chromiums have full support since
May. Until we make it work without JSPI, let's keep the original web_example
around.
(cherry picked from commit c933a6b)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Éric <merwok@netwok.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OS-emscriptentopic-replRelated to the interactive shell

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@hoodmane@bedevere-bot@adqm@merwok@tomasr8@ambv