def emscripten(session: nox.Session, runner: str) -> None:
    """Test on Emscripten with Pyodide & Chrome / Firefox / Node.js"""
    session.env["UV_PROJECT_ENVIRONMENT"] = session.virtualenv.location
    if runner == "node":
        print(
            "Node version:",
            session.run("node", "--version", silent=True, external=True),
        )
    # make sure we have a dist dir for pyodide
    dist_dir = None
    if "PYODIDE_ROOT" in os.environ:
        # we have a pyodide build tree checked out
        # use the dist directory from that
        dist_dir = Path(os.environ["PYODIDE_ROOT"]) / "dist"
    else:
        # we don't have a build tree
        pyodide_version = "0.27.1"

        pyodide_artifacts_path = Path(session.cache_dir) / f"pyodide-{pyodide_version}"
        if not pyodide_artifacts_path.exists():
            print("Fetching pyodide build artifacts")
            session.run(
                "curl",
                "-L",
                f"https://github.com/pyodide/pyodide/releases/download/{pyodide_version}/pyodide-{pyodide_version}.tar.bz2",
                "--output-dir",
                session.cache_dir,
                "-O",
                external=True,
            )
            pyodide_artifacts_path.mkdir(parents=True)
            session.run(
                "tar",
                "-xjf",
                f"{pyodide_artifacts_path}.tar.bz2",
                "-C",
                str(pyodide_artifacts_path),
                "--strip-components",
                "1",
                external=True,
            )

        dist_dir = pyodide_artifacts_path
    session.run("uv", "run", "-m", "build")
    assert dist_dir is not None
    assert dist_dir.exists()
    tests_impl(
        session,
        extras="",
        pytest_extra_args=[
            "-x",
            "--runtime",
            f"{runner}-no-host",
            "--dist-dir",
            str(dist_dir),
            "test/contrib/emscripten",
            "-v",
        ],
        dependency_group="emscripten",
    )
Test on Emscripten with Pyodide & Chrome / Firefox / Node.js
noxfile.py