From 852ade02ff89c54e31ebe75cb97d0767f336b245 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sun, 11 Jan 2026 09:40:20 +0000 Subject: [PATCH 01/14] bump pyodide used in tests to 0.29 --- .github/workflows/ci.yml | 28 ++++------------ emscripten/get_emscripten_version.js | 8 +++++ emscripten/get_python_version.js | 9 +++++ emscripten/package-lock.json | 50 ++++++++++++++++++++++++++++ emscripten/package.json | 6 ++++ noxfile.py | 36 +++++++++++++++++--- 6 files changed, 110 insertions(+), 27 deletions(-) create mode 100644 emscripten/get_emscripten_version.js create mode 100644 emscripten/get_python_version.js create mode 100644 emscripten/package-lock.json create mode 100644 emscripten/package.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3d29a9a..e8dfdc9d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -422,27 +422,14 @@ jobs: shell: msys2 {0} run: PATH="$PATH:/c/Users/runneradmin/.cargo/bin" nox -s test-examples - test-emscripten: - name: Test Emscripten - runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + - uses: astral-sh/setup-uv@v7 - uses: actions/setup-node@v6 with: - node-version: 18 + node-version: 22 - run: | - PYODIDE_VERSION=0.21.0 - - cd emscripten - npm i pyodide@0.21.0 - cd node_modules/pyodide/ - npx -y prettier -w pyodide.asm.js - EMSCRIPTEN_VERSION=$(node -p "require('./repodata.json').info.platform.split('_').slice(1).join('.')") - PYTHON_VERSION=3.10 - - echo "PYODIDE_VERSION=$PYODIDE_VERSION" >> $GITHUB_ENV - echo "EMSCRIPTEN_VERSION=$EMSCRIPTEN_VERSION" >> $GITHUB_ENV - echo "PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV + uvx nox -s install-pyodide-emscripten echo "ORIG_PATH=$PATH" >> $GITHUB_ENV - uses: dtolnay/rust-toolchain@nightly with: @@ -452,11 +439,6 @@ jobs: with: version: ${{env.EMSCRIPTEN_VERSION}} actions-cache-folder: emsdk-cache - - uses: actions/setup-python@v6 - id: setup-python - with: - python-version: ${{env.PYTHON_VERSION}} - - run: pip install nox - uses: actions/cache@v5 with: path: | @@ -466,4 +448,6 @@ jobs: - name: Test run: | export PATH=$ORIG_PATH:$PATH - nox -s test-examples-emscripten + uvx nox -s test-examples-emscripten + with: + UV_PYTHON: ${{ env.PYTHON_VERSION }} diff --git a/emscripten/get_emscripten_version.js b/emscripten/get_emscripten_version.js new file mode 100644 index 00000000..ae85ccc4 --- /dev/null +++ b/emscripten/get_emscripten_version.js @@ -0,0 +1,8 @@ +import { loadPyodide } from "pyodide"; + +const pyodide = await loadPyodide(); + +pyodide.runPython(` +import platform +print(platform.platform().split("-")[1]) +`); diff --git a/emscripten/get_python_version.js b/emscripten/get_python_version.js new file mode 100644 index 00000000..8ea8f94d --- /dev/null +++ b/emscripten/get_python_version.js @@ -0,0 +1,9 @@ +import { loadPyodide } from "pyodide"; + +const pyodide = await loadPyodide(); + +pyodide.runPython(` +import sys +major, minor = sys.version_info[:2] +print(f"{major}.{minor}") +`); diff --git a/emscripten/package-lock.json b/emscripten/package-lock.json new file mode 100644 index 00000000..7f375544 --- /dev/null +++ b/emscripten/package-lock.json @@ -0,0 +1,50 @@ +{ + "name": "emscripten", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "pyodide": "^0.29.1" + } + }, + "node_modules/@types/emscripten": { + "version": "1.41.5", + "resolved": "https://registry.npmjs.org/@types/emscripten/-/emscripten-1.41.5.tgz", + "integrity": "sha512-cMQm7pxu6BxtHyqJ7mQZ2kXWV5SLmugybFdHCBbJ5eHzOo6VhBckEgAT3//rP5FwPHNPeEiq4SmQ5ucBwsOo4Q==", + "license": "MIT" + }, + "node_modules/pyodide": { + "version": "0.29.1", + "resolved": "https://registry.npmjs.org/pyodide/-/pyodide-0.29.1.tgz", + "integrity": "sha512-mpk9jtkiM7Ugh1r9P9dbR8vKrmf0lED32hBZq+Fn1kkkBiUoOjSsJEWcyprugICpiFpIXpUOf80ZrvFXkQMk2g==", + "license": "MPL-2.0", + "dependencies": { + "@types/emscripten": "^1.41.4", + "ws": "^8.5.0" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/ws": { + "version": "8.8.1", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} diff --git a/emscripten/package.json b/emscripten/package.json new file mode 100644 index 00000000..480d76dc --- /dev/null +++ b/emscripten/package.json @@ -0,0 +1,6 @@ +{ + "type": "module", + "dependencies": { + "pyodide": "^0.29.1" + } +} diff --git a/noxfile.py b/noxfile.py index e86a0c1a..9cd4a491 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,9 +1,11 @@ import os +from contextlib import ExitStack from inspect import cleandoc as heredoc from glob import glob from pathlib import Path import shutil import sys +import json import nox import nox.command @@ -227,10 +229,34 @@ def test(session: nox.Session): session.run("pytest", "setuptools_rust", "tests", *session.posargs) +PYODIDE_VERSION = "0.29.1" +EMSCRIPTEN_DIR = Path("./emscripten").resolve() + + +@nox.session(name="install-pyodide-emscripten") +def install_pyodide_emscripten(session: nox.Session): + with session.chdir(EMSCRIPTEN_DIR): + session.run("npm", "install", f"pyodide@{PYODIDE_VERSION}", external=True) + emscripten_version = session.run("node", "get_emscripten_version.js", external=True, silent=True).strip() + python_version = session.run("node", "get_python_version.js", external=True, silent=True).strip() + + with ExitStack() as stack: + if "GITHUB_ENV" in os.environ: + out = stack.enter_context(open(os.environ["GITHUB_ENV"], "a")) + else: + out = sys.stdout + + print(f"PYODIDE_VERSION={PYODIDE_VERSION}", file=out) + print(f"EMSCRIPTEN_VERSION={emscripten_version}", file=out) + print(f"PYTHON_VERSION={python_version}", file=out) + + if "GITHUB_ENV" not in os.environ: + print("You will need to install emscripten yourself to match the target version.") + + @nox.session(name="test-examples-emscripten") def test_examples_emscripten(session: nox.Session): session.install(".", "build") - emscripten_dir = Path("./emscripten").resolve() session.run( "rustup", @@ -250,20 +276,20 @@ def test_examples_emscripten(session: nox.Session): env = os.environ.copy() env.update( RUSTUP_TOOLCHAIN="nightly", - PYTHONPATH=str(emscripten_dir), + PYTHONPATH=str(EMSCRIPTEN_DIR), _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata__emscripten_wasm32-emscripten", _PYTHON_HOST_PLATFORM="emscripten_3_1_14_wasm32", CARGO_BUILD_TARGET="wasm32-unknown-emscripten", CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_LINKER=str( - emscripten_dir / "emcc_wrapper.py" + EMSCRIPTEN_DIR / "emcc_wrapper.py" ), - PYO3_CONFIG_FILE=str(emscripten_dir / "pyo3_config.ini"), + PYO3_CONFIG_FILE=str(EMSCRIPTEN_DIR / "pyo3_config.ini"), ) with session.chdir(example): cmd = ["python", "-m", "build", "--wheel", "--no-isolation"] session.run(*cmd, env=env, external=True) - with session.chdir(emscripten_dir): + with session.chdir(EMSCRIPTEN_DIR): session.run("node", "runner.js", str(example), external=True) From dd4753fb54c702e08cf523c9de1575ac931f726a Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sun, 11 Jan 2026 09:52:20 +0000 Subject: [PATCH 02/14] fix YAML syntax --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8dfdc9d..4e2e6530 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -422,6 +422,8 @@ jobs: shell: msys2 {0} run: PATH="$PATH:/c/Users/runneradmin/.cargo/bin" nox -s test-examples + test-emscripten: + runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: astral-sh/setup-uv@v7 From 08ff34e412486fe02b71a47cd48e300d0daa97f0 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sun, 11 Jan 2026 09:54:58 +0000 Subject: [PATCH 03/14] `with` -> `env` --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e2e6530..9076a192 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -451,5 +451,5 @@ jobs: run: | export PATH=$ORIG_PATH:$PATH uvx nox -s test-examples-emscripten - with: + env: UV_PYTHON: ${{ env.PYTHON_VERSION }} From 39f8f67e64833f4ce53ad249ed69410faa43bd82 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sun, 11 Jan 2026 10:52:23 +0000 Subject: [PATCH 04/14] use temporary pyo3 config with correct version --- emscripten/pyo3_config.ini | 7 ------ noxfile.py | 49 +++++++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 26 deletions(-) delete mode 100644 emscripten/pyo3_config.ini diff --git a/emscripten/pyo3_config.ini b/emscripten/pyo3_config.ini deleted file mode 100644 index a91b4f9c..00000000 --- a/emscripten/pyo3_config.ini +++ /dev/null @@ -1,7 +0,0 @@ -implementation=CPython -version=3.10 -shared=true -abi3=false -lib_name=python3.10 -pointer_width=32 -suppress_build_script_link_lines=false diff --git a/noxfile.py b/noxfile.py index 9cd4a491..e0b75a97 100644 --- a/noxfile.py +++ b/noxfile.py @@ -6,6 +6,7 @@ import shutil import sys import json +import tempfile import nox import nox.command @@ -272,25 +273,35 @@ def test_examples_emscripten(session: nox.Session): examples_dir / "html-py-ever", examples_dir / "namespace_package", ] - for example in test_crates: - env = os.environ.copy() - env.update( - RUSTUP_TOOLCHAIN="nightly", - PYTHONPATH=str(EMSCRIPTEN_DIR), - _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata__emscripten_wasm32-emscripten", - _PYTHON_HOST_PLATFORM="emscripten_3_1_14_wasm32", - CARGO_BUILD_TARGET="wasm32-unknown-emscripten", - CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_LINKER=str( - EMSCRIPTEN_DIR / "emcc_wrapper.py" - ), - PYO3_CONFIG_FILE=str(EMSCRIPTEN_DIR / "pyo3_config.ini"), - ) - with session.chdir(example): - cmd = ["python", "-m", "build", "--wheel", "--no-isolation"] - session.run(*cmd, env=env, external=True) - - with session.chdir(EMSCRIPTEN_DIR): - session.run("node", "runner.js", str(example), external=True) + + with tempfile.NamedTemporaryFile() as pyo3_config: + pyo3_config.write(f"""\ +implementation=CPython +version={PYTHON_VERSION} +shared=true +abi3=false +pointer_width=32 +""") + + for example in test_crates: + env = os.environ.copy() + env.update( + RUSTUP_TOOLCHAIN="nightly", + PYTHONPATH=str(EMSCRIPTEN_DIR), + _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata__emscripten_wasm32-emscripten", + _PYTHON_HOST_PLATFORM="emscripten_3_1_14_wasm32", + CARGO_BUILD_TARGET="wasm32-unknown-emscripten", + CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_LINKER=str( + EMSCRIPTEN_DIR / "emcc_wrapper.py" + ), + PYO3_CONFIG_FILE=pyo3_config.name, + ) + with session.chdir(example): + cmd = ["python", "-m", "build", "--wheel", "--no-isolation"] + session.run(*cmd, env=env, external=True) + + with session.chdir(EMSCRIPTEN_DIR): + session.run("node", "runner.js", str(example), external=True) @nox.session(name="bump-version") From 23bb27bacfb0401c28b02f5e890aa64db9cb139f Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sun, 11 Jan 2026 10:55:07 +0000 Subject: [PATCH 05/14] correct emscripten vars --- emscripten/_sysconfigdata__emscripten_wasm32-emscripten.py | 4 ++-- noxfile.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/emscripten/_sysconfigdata__emscripten_wasm32-emscripten.py b/emscripten/_sysconfigdata__emscripten_wasm32-emscripten.py index 6596c0ac..3c3b21d9 100644 --- a/emscripten/_sysconfigdata__emscripten_wasm32-emscripten.py +++ b/emscripten/_sysconfigdata__emscripten_wasm32-emscripten.py @@ -8,9 +8,9 @@ "CCSHARED": "", "CFLAGS": "-Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g " "-fwrapv -O3 -Wall -O2 -g0 -fPIC", - "EXT_SUFFIX": ".cpython-310-wasm32-emscripten.so", + "EXT_SUFFIX": ".cpython-313-wasm32-emscripten.so", "HOST_GNU_TYPE": "wasm32-unknown-emscripten", "LDSHARED": "emcc -sSIDE_MODULE=1", "Py_DEBUG": "0", - "py_version_nodot": "310", + "py_version_nodot": "313", } diff --git a/noxfile.py b/noxfile.py index e0b75a97..8fa0836c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -274,6 +274,9 @@ def test_examples_emscripten(session: nox.Session): examples_dir / "namespace_package", ] + python_version = os.environ["PYTHON_VERSION"] + emscripten_version = os.environ["EMSCRIPTEN_VERSION"] + with tempfile.NamedTemporaryFile() as pyo3_config: pyo3_config.write(f"""\ implementation=CPython @@ -283,13 +286,15 @@ def test_examples_emscripten(session: nox.Session): pointer_width=32 """) + emscripten_version_joined = emscripten_version.replace('.', '_') + for example in test_crates: env = os.environ.copy() env.update( RUSTUP_TOOLCHAIN="nightly", PYTHONPATH=str(EMSCRIPTEN_DIR), _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata__emscripten_wasm32-emscripten", - _PYTHON_HOST_PLATFORM="emscripten_3_1_14_wasm32", + _PYTHON_HOST_PLATFORM=f"emscripten_{emscripten_version_joined}_wasm32", CARGO_BUILD_TARGET="wasm32-unknown-emscripten", CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_LINKER=str( EMSCRIPTEN_DIR / "emcc_wrapper.py" From fddad3c77c32ac2154ffbbbef357f81a267a4611 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Wed, 14 Jan 2026 18:01:23 +0000 Subject: [PATCH 06/14] format --- noxfile.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/noxfile.py b/noxfile.py index 8fa0836c..ae7f91e7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -238,8 +238,12 @@ def test(session: nox.Session): def install_pyodide_emscripten(session: nox.Session): with session.chdir(EMSCRIPTEN_DIR): session.run("npm", "install", f"pyodide@{PYODIDE_VERSION}", external=True) - emscripten_version = session.run("node", "get_emscripten_version.js", external=True, silent=True).strip() - python_version = session.run("node", "get_python_version.js", external=True, silent=True).strip() + emscripten_version = session.run( + "node", "get_emscripten_version.js", external=True, silent=True + ).strip() + python_version = session.run( + "node", "get_python_version.js", external=True, silent=True + ).strip() with ExitStack() as stack: if "GITHUB_ENV" in os.environ: @@ -252,7 +256,9 @@ def install_pyodide_emscripten(session: nox.Session): print(f"PYTHON_VERSION={python_version}", file=out) if "GITHUB_ENV" not in os.environ: - print("You will need to install emscripten yourself to match the target version.") + print( + "You will need to install emscripten yourself to match the target version." + ) @nox.session(name="test-examples-emscripten") @@ -286,7 +292,7 @@ def test_examples_emscripten(session: nox.Session): pointer_width=32 """) - emscripten_version_joined = emscripten_version.replace('.', '_') + emscripten_version_joined = emscripten_version.replace(".", "_") for example in test_crates: env = os.environ.copy() From 91b7092821e03c8cb79e251cbaa55286e4befb45 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Wed, 14 Jan 2026 18:01:56 +0000 Subject: [PATCH 07/14] fixup variable --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index ae7f91e7..844ccc58 100644 --- a/noxfile.py +++ b/noxfile.py @@ -286,7 +286,7 @@ def test_examples_emscripten(session: nox.Session): with tempfile.NamedTemporaryFile() as pyo3_config: pyo3_config.write(f"""\ implementation=CPython -version={PYTHON_VERSION} +version={python_version} shared=true abi3=false pointer_width=32 From 35f3e96c8854f05c269d26f6c3b4bc97204c0823 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Thu, 15 Jan 2026 10:46:12 +0000 Subject: [PATCH 08/14] fix config file --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 844ccc58..cdc982ec 100644 --- a/noxfile.py +++ b/noxfile.py @@ -283,7 +283,7 @@ def test_examples_emscripten(session: nox.Session): python_version = os.environ["PYTHON_VERSION"] emscripten_version = os.environ["EMSCRIPTEN_VERSION"] - with tempfile.NamedTemporaryFile() as pyo3_config: + with tempfile.NamedTemporaryFile('w') as pyo3_config: pyo3_config.write(f"""\ implementation=CPython version={python_version} From e30c5db0f5eef1369e75cceb052198eb6c931348 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Thu, 15 Jan 2026 10:50:19 +0000 Subject: [PATCH 09/14] flush config --- noxfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/noxfile.py b/noxfile.py index cdc982ec..b170cb04 100644 --- a/noxfile.py +++ b/noxfile.py @@ -291,6 +291,7 @@ def test_examples_emscripten(session: nox.Session): abi3=false pointer_width=32 """) + pyo3_config.flush() emscripten_version_joined = emscripten_version.replace(".", "_") From 63fcc169032f3ff10ad74bbb84b3c29445888cbc Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Thu, 15 Jan 2026 10:55:17 +0000 Subject: [PATCH 10/14] fix ruff format --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index b170cb04..ab9c2be9 100644 --- a/noxfile.py +++ b/noxfile.py @@ -283,7 +283,7 @@ def test_examples_emscripten(session: nox.Session): python_version = os.environ["PYTHON_VERSION"] emscripten_version = os.environ["EMSCRIPTEN_VERSION"] - with tempfile.NamedTemporaryFile('w') as pyo3_config: + with tempfile.NamedTemporaryFile("w") as pyo3_config: pyo3_config.write(f"""\ implementation=CPython version={python_version} From 099e1b10f7719a76498411c4d6cf2ec6449b364c Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Thu, 15 Jan 2026 10:56:46 +0000 Subject: [PATCH 11/14] remove json import --- noxfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index ab9c2be9..cd874470 100644 --- a/noxfile.py +++ b/noxfile.py @@ -5,7 +5,6 @@ from pathlib import Path import shutil import sys -import json import tempfile import nox From 1cb32537d062fcb87499ebd98776e3b983f20888 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Thu, 15 Jan 2026 11:05:57 +0000 Subject: [PATCH 12/14] update runner.js for "module" form --- emscripten/runner.js | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/emscripten/runner.js b/emscripten/runner.js index 68bf0ea1..37711289 100644 --- a/emscripten/runner.js +++ b/emscripten/runner.js @@ -1,5 +1,5 @@ -const { opendir } = require("node:fs/promises"); -const { loadPyodide } = require("pyodide"); +import { opendir } from "node:fs/promises"; +import { loadPyodide } from "pyodide"; async function findWheel(distDir) { const dir = await opendir(distDir); @@ -10,7 +10,7 @@ async function findWheel(distDir) { } } -function make_tty_ops(stream){ +function make_tty_ops(stream) { return { // get_char has 3 particular return values: // a.) the next character represented as an integer @@ -32,14 +32,14 @@ function make_tty_ops(stream){ }, put_char(tty, val) { try { - if(val !== null){ + if (val !== null) { tty.output.push(val); } if (val === null || val === 10) { process.stdout.write(Buffer.from(tty.output)); tty.output = []; } - } catch(e){ + } catch (e) { console.warn(e); } }, @@ -49,32 +49,31 @@ function make_tty_ops(stream){ } stream.write(Buffer.from(tty.output)); tty.output = []; - } + }, }; } -function setupStreams(FS, TTY){ +function setupStreams(FS, TTY) { let mytty = FS.makedev(FS.createDevice.major++, 0); let myttyerr = FS.makedev(FS.createDevice.major++, 0); - TTY.register(mytty, make_tty_ops(process.stdout)) - TTY.register(myttyerr, make_tty_ops(process.stderr)) - FS.mkdev('/dev/mytty', mytty); - FS.mkdev('/dev/myttyerr', myttyerr); - FS.unlink('/dev/stdin'); - FS.unlink('/dev/stdout'); - FS.unlink('/dev/stderr'); - FS.symlink('/dev/mytty', '/dev/stdin'); - FS.symlink('/dev/mytty', '/dev/stdout'); - FS.symlink('/dev/myttyerr', '/dev/stderr'); + TTY.register(mytty, make_tty_ops(process.stdout)); + TTY.register(myttyerr, make_tty_ops(process.stderr)); + FS.mkdev("/dev/mytty", mytty); + FS.mkdev("/dev/myttyerr", myttyerr); + FS.unlink("/dev/stdin"); + FS.unlink("/dev/stdout"); + FS.unlink("/dev/stderr"); + FS.symlink("/dev/mytty", "/dev/stdin"); + FS.symlink("/dev/mytty", "/dev/stdout"); + FS.symlink("/dev/myttyerr", "/dev/stderr"); FS.closeStream(0); FS.closeStream(1); FS.closeStream(2); - var stdin = FS.open('/dev/stdin', 0); - var stdout = FS.open('/dev/stdout', 1); - var stderr = FS.open('/dev/stderr', 1); + var stdin = FS.open("/dev/stdin", 0); + var stdout = FS.open("/dev/stdout", 1); + var stderr = FS.open("/dev/stderr", 1); } - const pkgDir = process.argv[2]; const distDir = pkgDir + "/dist"; const testDir = pkgDir + "/tests"; From 0f91ec04f113b5bae63aa548fcef4b116e0d7ac4 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Thu, 15 Jan 2026 13:44:15 +0000 Subject: [PATCH 13/14] define pyodide --- emscripten/runner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emscripten/runner.js b/emscripten/runner.js index 37711289..37f4c5dc 100644 --- a/emscripten/runner.js +++ b/emscripten/runner.js @@ -84,7 +84,7 @@ async function main() { let errcode = 1; try { - pyodide = await loadPyodide(); + const pyodide = await loadPyodide(); const FS = pyodide.FS; setupStreams(FS, pyodide._module.TTY); const NODEFS = FS.filesystems.NODEFS; From d66fe6d89762ed3417b5f1edc664963c0373b020 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Thu, 15 Jan 2026 20:57:12 +0000 Subject: [PATCH 14/14] try without `setupStreams` --- emscripten/runner.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/emscripten/runner.js b/emscripten/runner.js index 37f4c5dc..bba3a086 100644 --- a/emscripten/runner.js +++ b/emscripten/runner.js @@ -50,6 +50,7 @@ function make_tty_ops(stream) { stream.write(Buffer.from(tty.output)); tty.output = []; }, + fsync(tty) {}, }; } @@ -86,7 +87,7 @@ async function main() { try { const pyodide = await loadPyodide(); const FS = pyodide.FS; - setupStreams(FS, pyodide._module.TTY); + // setupStreams(FS, pyodide._module.TTY); const NODEFS = FS.filesystems.NODEFS; FS.mkdir("/test_dir"); FS.mount(NODEFS, { root: testDir }, "/test_dir");