diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 47e2d973..c6317c1f 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -129,14 +129,6 @@ jobs: done ls -l "$WASM_RUNTIME_DIR" - # `WasmCompiledWheelTest` imports a real compiled pyemscripten_2026_0 wheel. Under - # `-PrequireWasmRuntime` a missing wheel is a failure, not a skip, so fetch them first: by URL, - # each accepted only against the sha256 the script pins. The script pins none today: the - # wheel has to be a pypackpack-built cp315t one (leader, Decision 10 (c) c1, 2026-11-26), and - # until pypackpack #82 produces it this job fails on that one test, by name, by design. - - name: Fetch the pinned wasm wheels - run: bash python-multiplatform/scripts/wasm/build-cpython.sh wheels - # `-PrequireWasmRuntime` is the second half of the guard, and it is what makes this job unable # to repeat the original defect: if either task would skip -- no interpreter, or no # Chromium-family browser for karma -- the build fails naming what was missing, instead of diff --git a/docs/platforms/wasm-design.md b/docs/platforms/wasm-design.md index 368ee3c9..36960cef 100644 --- a/docs/platforms/wasm-design.md +++ b/docs/platforms/wasm-design.md @@ -121,9 +121,9 @@ Evidence, from the 3.14.2 GIL build this replaced: a real PyPI wheel, `pydantic_ and ran on that build (`validate_python(42) -> 42`, a `ValidationError` raised and caught, the exception exercises the unwinding ABI), and fails with `tag import requires a WebAssembly.Tag` on the stock build. This is one wheel and one code path; it does not show that every compiled extension -loads. A cp314 wheel does not load in 3.15t, so `WasmCompiledWheelTest` now waits for a pypackpack-built -cp315t wheel (leader, Decision 10 (c) c1, 2026-11-26; pypackpack #82) and until then reports a named -skip that fails under `-PrequireWasmRuntime` (`python-multiplatform/scripts/wasm/build-cpython.sh wheels` pins none yet); +loads. A cp314 wheel does not load in 3.15t, so `WasmCompiledWheelTest` now loads pypackpack-built +cp315t wheels (leader, Decision 10 (c) c1, 2026-11-26; pypackpack #82), checked in as test fixtures +under `python-multiplatform/src/wasmJsTest/resources/wheels/` with their provenance (leader, 2026-11-27); `WasmInterpreterAbiTest` checks the claims, with `python-multiplatform/scripts/wasm/build-cpython.sh stock` as the negative control. Emscripten is pinned to 5.0.3 because that is what the platform specifies, and installing it replaces `~/emsdk/upstream` in place (a global setting). diff --git a/python-multiplatform/build.gradle.kts b/python-multiplatform/build.gradle.kts index 10897236..c5215ed1 100644 --- a/python-multiplatform/build.gradle.kts +++ b/python-multiplatform/build.gradle.kts @@ -2080,22 +2080,13 @@ val buildWasmPython by tasks.registering(Exec::class) { } /** - * Where `python-multiplatform/scripts/wasm/build-cpython.sh wheels` puts the pinned compiled wheels the wasm suite loads - * (`wasmJsTest/.../WasmCompiledWheelTest`). Not checked in: they are downloaded by URL and accepted - * only against the sha256 the script pins. + * The compiled wheels the wasm suite loads (`wasmJsTest/.../WasmCompiledWheelTest`): test fixtures + * checked in under `src/wasmJsTest/resources/wheels/`, built by pypackpack (#82) and pinned by sha256 + * in the test and the README beside them (leader, 2026-11-27). `-PwasmWheelsDir` overrides it. */ val wasmWheelsDir: String = (project.findProperty("wasmWheelsDir")?.toString() ?: System.getenv("PMP_WASM_WHEELS_DIR") - ?: rootProject.layout.projectDirectory.dir(".caches/wasm-wheels").asFile.absolutePath) - -/** Downloads the pinned wheels into [wasmWheelsDir]. Network, a few MB; nothing depends on it. */ -val fetchWasmWheels by tasks.registering(Exec::class) { - group = "python" - description = "Downloads the pinned pyemscripten_2026_0 wheels the wasm suite loads into .caches/" - val script = rootProject.layout.projectDirectory.file("python-multiplatform/scripts/wasm/build-cpython.sh").asFile - environment("WASM_WHEELS_DIR", wasmWheelsDir) - commandLine("bash", script.absolutePath, "wheels") -} + ?: layout.projectDirectory.dir("src/wasmJsTest/resources/wheels").asFile.absolutePath) /** * The test-only tail of the test bundle's `cpython-config.mjs`: where the wheels were extracted, and @@ -2666,7 +2657,7 @@ tasks.withType().co onlyIf { wasmRuntimePresent(pythonDir.resolve("python.mjs")) } - // Fetching the wheels changes what WasmCompiledWheelTest can prove, so it re-runs the suite. + // Changing the wheels changes what WasmCompiledWheelTest can prove, so it re-runs the suite. inputs.files(fileTree(wasmWheelsDir) { include("*.whl") }) .withPropertyName("wasmWheels").optional() @@ -2704,7 +2695,7 @@ tasks.withType().co logger.lifecycle( "No wheels in $wasmWheelsDir -- WasmCompiledWheelTest will " + (if (requireWasmRuntime) "FAIL (-PrequireWasmRuntime)" else "skip") + - ". Fetch them with python-multiplatform/scripts/wasm/build-cpython.sh wheels (or :python-multiplatform:fetchWasmWheels)." + ". The fixtures live in python-multiplatform/src/wasmJsTest/resources/wheels (see its README)." ) } dir.resolve("cpython-config.mjs").appendText( diff --git a/python-multiplatform/scripts/wasm/build-cpython.sh b/python-multiplatform/scripts/wasm/build-cpython.sh index a02591f3..b4078334 100755 --- a/python-multiplatform/scripts/wasm/build-cpython.sh +++ b/python-multiplatform/scripts/wasm/build-cpython.sh @@ -9,7 +9,6 @@ # python-multiplatform/scripts/wasm/build-cpython.sh smoke run smoke.py (threads, upcalls, proxy slots) under the build tree's python.sh # python-multiplatform/scripts/wasm/build-cpython.sh stage copy python.wasm, python.mjs and the zip to the runtime dir # python-multiplatform/scripts/wasm/build-cpython.sh probe run embed-probe.mjs against the staged runtime (Python without main, as the library runs it) -# python-multiplatform/scripts/wasm/build-cpython.sh wheels download the pinned compiled wheels the wasm suite loads (none yet, see below) # python-multiplatform/scripts/wasm/build-cpython.sh stock build a STOCK interpreter (CPython's own driver defaults) as a negative control # # Which CPython, and why. Owner, 2026-10-04, on #175: "The wasm interpreter is also 3.15t, built by us @@ -27,7 +26,6 @@ # .caches/emsdk emsdk, pinned to 5.0.3 (override: EMSDK) # .caches/wasm-build/cpython315t CPython checkout + cross build (override: CPYTHON_CHECKOUT) # .caches/wasm-runtime the three files the library needs (override: WASM_RUNTIME_DIR) -# .caches/wasm-wheels pinned wheels (override: WASM_WHEELS_DIR) # .caches/wasm-build/cpython315-stock, .caches/wasm-runtime-stock the `stock` control # # `.caches/wasm-runtime` is the default `wasmPythonDir` in python-multiplatform/build.gradle.kts, so @@ -105,15 +103,6 @@ ABI_FLAGS="-fwasm-exceptions -sSUPPORT_LONGJMP=wasm" HOST_CFLAGS="-DPY_CALL_TRAMPOLINE -sUSE_BZIP2 $ABI_FLAGS -pthread" HOST_LDFLAGS="$ABI_FLAGS -pthread -sPTHREAD_POOL_SIZE=8 -sMAXIMUM_MEMORY=2GB" -# --- the wheels the suite loads ----------------------------------------------------------------------- -# `wasmJsTest/.../WasmCompiledWheelTest` imports a real compiled wheel and calls into it. Decision 10 -# (c) c1 (leader, 2026-11-26): it moves to a pypackpack-built cp315t wheel when pypackpack #82 produces -# one; until then the list is empty and the test reports a named skip, which fails under -# -PrequireWasmRuntime (never a silent pass). The cp314 pydantic-core wheel pinned for the 3.14.2 build -# cannot load into 3.15t. Format: " ", one per line. -WHEELS_DIR="${WASM_WHEELS_DIR:-$CACHES/wasm-wheels}" -WHEELS=() - die() { echo "build-cpython: $*" >&2; exit 1; } # --- toolchain -------------------------------------------------------------------------------------- @@ -492,38 +481,6 @@ do_stage() { echo "staged into $RUNTIME_DIR" } -# --- wheels ------------------------------------------------------------------------------------------ -sha256_of() { - if command -v sha256sum > /dev/null 2>&1; then sha256sum "$1" | cut -d' ' -f1 - else shasum -a 256 "$1" | cut -d' ' -f1; fi -} - -do_wheels() { - mkdir -p "$WHEELS_DIR" - local entry name url sha dest got - if [ "${#WHEELS[@]}" -eq 0 ]; then - echo "no wasm wheels pinned: WasmCompiledWheelTest waits on a pypackpack-built cp315t wheel (pypackpack #82, Decision 10 c1)" - return 0 - fi - for entry in "${WHEELS[@]}"; do - read -r name url sha <<< "$entry" - dest="$WHEELS_DIR/$name" - if [ -f "$dest" ] && [ "$(sha256_of "$dest")" = "$sha" ]; then - echo "wheel present: $name" - continue - fi - rm -f "$dest.part" - curl -fsSL --retry 3 "$url" -o "$dest.part" - got="$(sha256_of "$dest.part")" - if [ "$got" != "$sha" ]; then - rm -f "$dest.part" - die "$name: downloaded sha256 $got, pinned $sha -- refusing it" - fi - mv "$dest.part" "$dest" - echo "fetched $name" - done -} - # --- stock: the negative control --------------------------------------------------------------------- # CPython 3.15.0 built by its own driver's defaults (GIL, no pthreads), with exactly one addition: the # runtime methods the library binds through (patch_makefile_reachability). No unwinding ABI, no @@ -568,14 +525,13 @@ do_stock() { } case "${1:-all}" in - all) do_build; do_zip; do_verify; do_smoke; do_stage; do_probe; do_wheels ;; + all) do_build; do_zip; do_verify; do_smoke; do_stage; do_probe ;; build) do_build ;; zip) do_zip ;; verify) do_verify ;; smoke) do_smoke ;; stage) do_stage ;; probe) do_probe ;; - wheels) do_wheels ;; stock) do_stock ;; - *) die "unknown command '$1' (all | build | zip | verify | smoke | stage | probe | wheels | stock)" ;; + *) die "unknown command '$1' (all | build | zip | verify | smoke | stage | probe | stock)" ;; esac diff --git a/python-multiplatform/src/wasmJsMain/README.md b/python-multiplatform/src/wasmJsMain/README.md index 474a34e6..b4b59cfc 100644 --- a/python-multiplatform/src/wasmJsMain/README.md +++ b/python-multiplatform/src/wasmJsMain/README.md @@ -22,7 +22,7 @@ stands on is now a test in `wasmJsTest/.../emscripten/`, run against the real in | the shared memory survives CPython growing it | `WasmSharedMemoryGrowthTest` | | Kotlin-only work neither grows nor writes that memory | `WasmKotlinLeavesLinearMemoryAloneTest` | | the interpreter carries the `pyemscripten_2026_0` ABI | `WasmInterpreterAbiTest` | -| ... and a real compiled wheel loads and runs in it | `WasmCompiledWheelTest` (wheels: `python-multiplatform/scripts/wasm/build-cpython.sh wheels`) | +| ... and a real compiled wheel loads and runs in it | `WasmCompiledWheelTest` (wheels: `src/wasmJsTest/resources/wheels/`) | | direct calls beat a JS frame; hoisting beats a shim; strings and bulk reads | `WasmCrossingOverheadTest` | | `Table.set` beats `addFunction` + a JS closure for upcalls | `WasmUpcallRouteOverheadTest` | | `PY_CALL_TRAMPOLINE`'s JS fallback is live; `pmp_invoke` survives the wasm one | `WasmCallTrampolineTest` | diff --git a/python-multiplatform/src/wasmJsTest/kotlin/python/native/ffi/emscripten/TestWheelConfig.kt b/python-multiplatform/src/wasmJsTest/kotlin/python/native/ffi/emscripten/TestWheelConfig.kt index b53f2f7d..a48ef9ec 100644 --- a/python-multiplatform/src/wasmJsTest/kotlin/python/native/ffi/emscripten/TestWheelConfig.kt +++ b/python-multiplatform/src/wasmJsTest/kotlin/python/native/ffi/emscripten/TestWheelConfig.kt @@ -4,7 +4,7 @@ package python.native.ffi.emscripten /** * Where the `KotlinJsTest` `doFirst` in `python-multiplatform/build.gradle.kts` extracted the - * pinned wheels `python-multiplatform/scripts/wasm/build-cpython.sh wheels` downloads, or `null` when none were found. + * wheel fixtures in `src/wasmJsTest/resources/wheels/`, or `null` when none were found. * Test-only: appended to the test bundle's `cpython-config.mjs`, never to a consumer's. */ external val PMP_TEST_SITE_PACKAGES: JsString? diff --git a/python-multiplatform/src/wasmJsTest/kotlin/python/native/ffi/emscripten/WasmCompiledWheelTest.kt b/python-multiplatform/src/wasmJsTest/kotlin/python/native/ffi/emscripten/WasmCompiledWheelTest.kt index 9c5e55cf..4c76a75a 100644 --- a/python-multiplatform/src/wasmJsTest/kotlin/python/native/ffi/emscripten/WasmCompiledWheelTest.kt +++ b/python-multiplatform/src/wasmJsTest/kotlin/python/native/ffi/emscripten/WasmCompiledWheelTest.kt @@ -12,24 +12,24 @@ import python.multiplatform.ffi.PythonTestFixture * * `WasmInterpreterAbiTest` asserts the two properties of `python.wasm` that make this possible -- * the exported wasm exception tags, and the platform tag claim. This is the claim itself: a wheel - * built by someone else's toolchain against PEP 783's ABI (pydantic-core 2.48.0, Rust/PyO3, from - * PyPI) is `dlopen`ed as an Emscripten side module, links against `python.wasm`, and runs. + * built by another toolchain against that ABI is `dlopen`ed as an Emscripten side module, links + * against `python.wasm`, and runs. * - * Measured in the former `wasm-experiment/` (Test G) through CPython's own `python.sh`, with no - * Kotlin in the process. Against a stock PEP 776 build (`python-multiplatform/scripts/wasm/build-cpython.sh stock`) the same - * import fails at load: + * The wheel is `wasmdemo-0.1.0-cp315-cp315t-pyemscripten_2026_0_wasm32.whl`, built by pypackpack's + * Emscripten adapter (pypackpack #82, PR #180; handed over by toolchain 2026-11-27) with this + * repository's Emscripten 5.0.3 against the 3.15t headers, `-fwasm-exceptions -sSUPPORT_LONGJMP=wasm + * -pthread -fPIC -sSIDE_MODULE=1`. Its C module `wasmdemo.wmod` has `answer()` (returns 42) and + * `unwind()`, which returns 7 through `setjmp`/`longjmp` and so imports `python.wasm`'s `__c_longjmp` + * tag: a runtime without the pyemscripten_2026_0 unwinding ABI fails it at link time. It is C, so + * `__cpp_exception` is covered by the second fixture, `wasmcpp` ([aCompiledCppWheelThrowsAndCatchesInsideTheInterpreter]). + * This replaces the cp314 pydantic-core wheel the 3.14.2 runtime + * loaded (Decision 10 (c) c1, leader 2026-11-26). * - * LinkError: Import #204 "env" "__cpp_exception": tag import requires a WebAssembly.Tag - * - * Decision 10 (c) c1 (leader, 2026-11-26): the runtime is now 3.15t, so the cp314 wheel below no longer - * loads; this test moves to a pypackpack-built cp315t wheel when pypackpack #82 produces one (the body is - * then rewritten for that wheel). Until then it reports a named skip, and fails under - * `-PrequireWasmRuntime=true`, never a silent pass. - * - * The wheels are not in the repository. `python-multiplatform/scripts/wasm/build-cpython.sh wheels` downloads them by URL - * with pinned sha256 into `.caches/wasm-wheels`, and the test task extracts them next to the test - * bundle. Without them this test skips with that instruction, and under `-PrequireWasmRuntime=true` - * it fails instead -- the same contract every other wasm prerequisite has. + * The wheels are test fixtures checked in under `python-multiplatform/src/wasmJsTest/resources/wheels/` + * (leader, 2026-11-27), whose README records how each was built; [PINNED_WHEELS] pins their sha256 and + * [theCheckedInWheelsAreTheOnesTheReadmeDescribes] checks it. The test task extracts them next to the + * test bundle (`-PwasmWheelsDir` overrides the directory). Without them this test skips, and under + * `-PrequireWasmRuntime=true` it fails instead -- the same contract every other wasm prerequisite has. */ class WasmCompiledWheelTest { @@ -44,9 +44,7 @@ class WasmCompiledWheelTest { val site = PMP_TEST_SITE_PACKAGES?.toString() if (site == null) { val message = "no cp315t pyemscripten_2026_0 wheel in ${PMP_TEST_WHEELS_DIR?.toString()}: " + - "waiting on a pypackpack-built cp315t wheel (pypackpack #82, Decision 10 c1, leader " + - "2026-11-26). The cp314 pydantic-core wheel the 3.14.2 runtime loaded cannot load into " + - "3.15t, and no cp315t wheel is pinned in build-cpython.sh's WHEELS yet." + "the fixtures live in python-multiplatform/src/wasmJsTest/resources/wheels (pypackpack #82)." if (required.toBoolean()) { fail("$message -PrequireWasmRuntime=true was passed, so this is a failure rather than a skip.") } @@ -59,19 +57,62 @@ class WasmCompiledWheelTest { "import sys as _pmp_sys\n" + "_pmp_sys.path.insert(0, ${pyStr(site)})\n" + "try:\n" + - " import pydantic_core as _pmp_pc\n" + - " from pydantic_core import SchemaValidator as _pmp_SV, core_schema as _pmp_cs\n" + - " _pmp_v = _pmp_SV(_pmp_cs.int_schema())\n" + + " import wasmdemo.wmod as _pmp_m\n" + + " _pmp_wheel = [\n" + + " _pmp_m.__file__.rsplit('/', 1)[-1],\n" + + " repr(_pmp_m.answer()),\n" + + " repr(_pmp_m.unwind()),\n" + + " repr(_pmp_sys._is_gil_enabled()),\n" + + " ]\n" + + "except BaseException as e:\n" + + " _pmp_wheel = ['FAILED ' + type(e).__name__ + ': ' + str(e)]\n" + + "finally:\n" + + " _pmp_sys.path.remove(${pyStr(site)})\n", + ) + assertEquals(0, status) + val result = evalToString("' | '.join(_pmp_wheel)") + runInMain("del _pmp_wheel, _pmp_sys") + assertEquals( + "wmod.cpython-315t-wasm32-emscripten.so | 42 | 7 | False", + result, + "importing and calling the compiled wasmdemo wheel failed. A LinkError naming " + + "__c_longjmp means python.wasm lacks the pyemscripten_2026_0 unwinding ABI " + + "(see WasmInterpreterAbiTest); 'True' at the end means the import re-enabled the GIL.", + ) + } + } + } + + /** + * The C++ fixture: `wasmcpp.wcpp.catch_it()` throws `std::runtime_error("boom 3")` inside the + * side module and returns the message it caught. That imports `python.wasm`'s `__cpp_exception` + * tag and libc++abi's `__cxa_throw` / `__cxa_allocate_exception`, which the C fixture above never + * touches: a runtime built without `-fwasm-exceptions`, or one whose tag the side module cannot + * link against, fails here (a LinkError at import, or an abort at the throw) while `wasmdemo` + * still passes. Built by toolchain with the same adapter and flags (pypackpack 2f3ddd0, 2026-11-27). + */ + @Test + fun aCompiledCppWheelThrowsAndCatchesInsideTheInterpreter() { + val site = PMP_TEST_SITE_PACKAGES?.toString() + if (site == null) { + if (PMP_TEST_WHEELS_REQUIRED?.toBoolean() == true) { + fail("no wheels were staged although -PrequireWasmRuntime=true was passed") + } + println("SKIPPING aCompiledCppWheelThrowsAndCatchesInsideTheInterpreter: no wheels staged") + return + } + PythonTestFixture.withInterpreter { + Python3.withPython { + val status = runInMain( + "import sys as _pmp_sys\n" + + "_pmp_sys.path.insert(0, ${pyStr(site)})\n" + + "try:\n" + + " import wasmcpp.wcpp as _pmp_m\n" + " _pmp_wheel = [\n" + - " _pmp_pc.__version__,\n" + - " _pmp_pc._pydantic_core.__file__.rsplit('/', 1)[-1],\n" + - " repr(_pmp_v.validate_python('42')),\n" + + " _pmp_m.__file__.rsplit('/', 1)[-1],\n" + + " _pmp_m.catch_it(),\n" + + " repr(_pmp_sys._is_gil_enabled()),\n" + " ]\n" + - " try:\n" + - " _pmp_v.validate_python('not an int')\n" + - " _pmp_wheel.append('no exception')\n" + - " except _pmp_pc.ValidationError as e:\n" + - " _pmp_wheel.append(type(e).__name__)\n" + "except BaseException as e:\n" + " _pmp_wheel = ['FAILED ' + type(e).__name__ + ': ' + str(e)]\n" + "finally:\n" + @@ -81,11 +122,42 @@ class WasmCompiledWheelTest { val result = evalToString("' | '.join(_pmp_wheel)") runInMain("del _pmp_wheel, _pmp_sys") assertEquals( - "2.48.0 | _pydantic_core.cpython-314-wasm32-emscripten.so | 42 | ValidationError", + "wcpp.cpython-315t-wasm32-emscripten.so | boom 3 | False", result, - "importing and calling the compiled pydantic-core wheel failed. A LinkError naming " + - "__cpp_exception or __c_longjmp means python.wasm lacks the pyemscripten_2026_0 " + - "unwinding ABI (see WasmInterpreterAbiTest).", + "importing the compiled wasmcpp wheel or catching its C++ exception failed. A LinkError " + + "naming __cpp_exception means python.wasm does not export the C++ exception tag " + + "(see WasmInterpreterAbiTest).", + ) + } + } + } + + /** + * The fixtures are what their README says they are: every pinned wheel is present with its + * sha256, and nothing unpinned sits beside them. A rebuilt wheel (new emsdk or ABI) changes the + * hash, so this fails until the README and [PINNED_WHEELS] are updated with the new provenance. + */ + @Test + fun theCheckedInWheelsAreTheOnesTheReadmeDescribes() { + val dir = PMP_TEST_WHEELS_DIR?.toString() ?: fail("the test bundle's cpython-config.mjs carries no PMP_TEST_WHEELS_DIR") + PythonTestFixture.withInterpreter { + Python3.withPython { + assertEquals( + 0, + runInMain( + "import hashlib as _pmp_h, os as _pmp_os\n" + + "_pmp_d = ${pyStr(dir)}\n" + + "_pmp_found = sorted(n + ' ' + _pmp_h.sha256(open(_pmp_os.path.join(_pmp_d, n), 'rb').read()).hexdigest()\n" + + " for n in _pmp_os.listdir(_pmp_d) if n.endswith('.whl'))\n", + ), + ) + val found = evalToString("'\\n'.join(_pmp_found)") + runInMain("del _pmp_h, _pmp_os, _pmp_d, _pmp_found") + assertEquals( + PINNED_WHEELS.entries.sortedBy { it.key }.joinToString("\n") { "${it.key} ${it.value}" }, + found, + "the wheels in $dir are not the pinned fixtures; update resources/wheels/README.md and " + + "PINNED_WHEELS together when a fixture is rebuilt", ) } } @@ -93,4 +165,14 @@ class WasmCompiledWheelTest { private fun pyStr(value: String): String = "'" + value.replace("\\", "\\\\").replace("'", "\\'") + "'" + + private companion object { + /** File name to sha256; the same values as `resources/wheels/README.md`. */ + val PINNED_WHEELS = mapOf( + "wasmdemo-0.1.0-cp315-cp315t-pyemscripten_2026_0_wasm32.whl" to + "df57a28e3a61f4eb8bc5fe84e4a09bdc76e8e720bd6c348345c3fb86c772298a", + "wasmcpp-0.1.0-cp315-cp315t-pyemscripten_2026_0_wasm32.whl" to + "6a41eb2a1be0421fcf35c862aefeacb11bbdbfc80f34ac2881d739df9a3c96ef", + ) + } } diff --git a/python-multiplatform/src/wasmJsTest/resources/wheels/README.md b/python-multiplatform/src/wasmJsTest/resources/wheels/README.md new file mode 100644 index 00000000..09462fca --- /dev/null +++ b/python-multiplatform/src/wasmJsTest/resources/wheels/README.md @@ -0,0 +1,36 @@ +# Compiled wasm wheel fixtures + +`WasmCompiledWheelTest` loads these wheels into the wasm interpreter (CPython 3.15t, Emscripten) +to prove that a wheel another toolchain compiled for `pyemscripten_2026_0` links against +`python.wasm` and runs. They are test fixtures, checked in so the test needs no download (leader, +2026-11-27). The test task extracts every `.whl` here into one `site-packages` next to the test +bundle; `-PwasmWheelsDir=` points it at another directory. + +| Wheel | sha256 | Module | Expected | +|---|---|---|---| +| `wasmdemo-0.1.0-cp315-cp315t-pyemscripten_2026_0_wasm32.whl` (1892 bytes) | `df57a28e3a61f4eb8bc5fe84e4a09bdc76e8e720bd6c348345c3fb86c772298a` | `wasmdemo.wmod` (C) | `answer()` is 42; `unwind()` is 7 through `setjmp`/`longjmp`, so it imports the `__c_longjmp` tag | +| `wasmcpp-0.1.0-cp315-cp315t-pyemscripten_2026_0_wasm32.whl` (2213 bytes) | `6a41eb2a1be0421fcf35c862aefeacb11bbdbfc80f34ac2881d739df9a3c96ef` | `wasmcpp.wcpp` (C++) | `catch_it()` throws `std::runtime_error("boom 3")` inside the module and returns `"boom 3"`, so it imports the `__cpp_exception` tag and libc++abi's `__cxa_throw` | + +`theCheckedInWheelsAreTheOnesTheReadmeDescribes` fails when a wheel here is not in the table above +(through `PINNED_WHEELS` in the test) or its hash differs. Update this table and `PINNED_WHEELS` +together. + +## How they were built + +Both by pypackpack's Emscripten adapter (pypackpack #82, PR #180), at pypackpack commit `2f3ddd0` +(branch `feat/82-wasm-compile`), built and handed over by the toolchain teammate on 2026-11-27: + +```bash +PPP_WASM_REAL_BUILD=1 \ +EMSDK= \ +PPP_WASM_RUNTIME_MANIFEST= \ +PPP_WASM_WHEEL_OUT= \ +./gradlew :packpack:test --tests '*EmscriptenRealBuildTest*' +``` + +- Emscripten 5.0.3, this repository's pin. +- Against the 3.15t headers of this repository's wasm build at `e5c4a058` (CPython `d220409a`). +- Flags: `-fwasm-exceptions -sSUPPORT_LONGJMP=wasm -pthread -fPIC -sSIDE_MODULE=1`. + +Rebuilding the C wheel at that commit gave a byte-identical file. A new Emscripten or ABI changes +the hashes; ask for a rebuild with the same command and update the table. diff --git a/python-multiplatform/src/wasmJsTest/resources/wheels/wasmcpp-0.1.0-cp315-cp315t-pyemscripten_2026_0_wasm32.whl b/python-multiplatform/src/wasmJsTest/resources/wheels/wasmcpp-0.1.0-cp315-cp315t-pyemscripten_2026_0_wasm32.whl new file mode 100644 index 00000000..f93625ad Binary files /dev/null and b/python-multiplatform/src/wasmJsTest/resources/wheels/wasmcpp-0.1.0-cp315-cp315t-pyemscripten_2026_0_wasm32.whl differ diff --git a/python-multiplatform/src/wasmJsTest/resources/wheels/wasmdemo-0.1.0-cp315-cp315t-pyemscripten_2026_0_wasm32.whl b/python-multiplatform/src/wasmJsTest/resources/wheels/wasmdemo-0.1.0-cp315-cp315t-pyemscripten_2026_0_wasm32.whl new file mode 100644 index 00000000..45e130ed Binary files /dev/null and b/python-multiplatform/src/wasmJsTest/resources/wheels/wasmdemo-0.1.0-cp315-cp315t-pyemscripten_2026_0_wasm32.whl differ