MCPcopy Create free account
hub / github.com/PyO3/setuptools-rust / test_examples_emscripten

Function test_examples_emscripten

noxfile.py:264–315  ·  view source on GitHub ↗
(session: nox.Session)

Source from the content-addressed store, hash-verified

262
263@nox.session(name="test-examples-emscripten")
264def test_examples_emscripten(session: nox.Session):
265 session.install(".", "build")
266
267 session.run(
268 "rustup",
269 "component",
270 "add",
271 "rust-src",
272 "--toolchain",
273 "nightly",
274 external=True,
275 )
276 examples_dir = Path("examples").absolute()
277 test_crates = [
278 examples_dir / "html-py-ever",
279 examples_dir / "namespace_package",
280 ]
281
282 python_version = os.environ["PYTHON_VERSION"]
283 emscripten_version = os.environ["EMSCRIPTEN_VERSION"]
284
285 with tempfile.NamedTemporaryFile("w") as pyo3_config:
286 pyo3_config.write(f"""\
287implementation=CPython
288version={python_version}
289shared=true
290abi3=false
291pointer_width=32
292""")
293 pyo3_config.flush()
294
295 emscripten_version_joined = emscripten_version.replace(".", "_")
296
297 for example in test_crates:
298 env = os.environ.copy()
299 env.update(
300 RUSTUP_TOOLCHAIN="nightly",
301 PYTHONPATH=str(EMSCRIPTEN_DIR),
302 _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata__emscripten_wasm32-emscripten",
303 _PYTHON_HOST_PLATFORM=f"emscripten_{emscripten_version_joined}_wasm32",
304 CARGO_BUILD_TARGET="wasm32-unknown-emscripten",
305 CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_LINKER=str(
306 EMSCRIPTEN_DIR / "emcc_wrapper.py"
307 ),
308 PYO3_CONFIG_FILE=pyo3_config.name,
309 )
310 with session.chdir(example):
311 cmd = ["python", "-m", "build", "--wheel", "--no-isolation"]
312 session.run(*cmd, env=env, external=True)
313
314 with session.chdir(EMSCRIPTEN_DIR):
315 session.run("node", "runner.js", str(example), external=True)
316
317
318@nox.session(name="bump-version")

Callers

nothing calls this directly

Calls 1

runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…