|
6 | 6 | import shutil |
7 | 7 | import sys |
8 | 8 | import json |
| 9 | +import tempfile |
9 | 10 |
|
10 | 11 | import nox |
11 | 12 | import nox.command |
@@ -272,25 +273,35 @@ def test_examples_emscripten(session: nox.Session): |
272 | 273 | examples_dir / "html-py-ever", |
273 | 274 | examples_dir / "namespace_package", |
274 | 275 | ] |
275 | | - for example in test_crates: |
276 | | - env = os.environ.copy() |
277 | | - env.update( |
278 | | - RUSTUP_TOOLCHAIN="nightly", |
279 | | - PYTHONPATH=str(EMSCRIPTEN_DIR), |
280 | | - _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata__emscripten_wasm32-emscripten", |
281 | | - _PYTHON_HOST_PLATFORM="emscripten_3_1_14_wasm32", |
282 | | - CARGO_BUILD_TARGET="wasm32-unknown-emscripten", |
283 | | - CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_LINKER=str( |
284 | | - EMSCRIPTEN_DIR / "emcc_wrapper.py" |
285 | | - ), |
286 | | - PYO3_CONFIG_FILE=str(EMSCRIPTEN_DIR / "pyo3_config.ini"), |
287 | | - ) |
288 | | - with session.chdir(example): |
289 | | - cmd = ["python", "-m", "build", "--wheel", "--no-isolation"] |
290 | | - session.run(*cmd, env=env, external=True) |
291 | | - |
292 | | - with session.chdir(EMSCRIPTEN_DIR): |
293 | | - session.run("node", "runner.js", str(example), external=True) |
| 276 | + |
| 277 | + with tempfile.NamedTemporaryFile() as pyo3_config: |
| 278 | + pyo3_config.write(f"""\ |
| 279 | +implementation=CPython |
| 280 | +version={PYTHON_VERSION} |
| 281 | +shared=true |
| 282 | +abi3=false |
| 283 | +pointer_width=32 |
| 284 | +""") |
| 285 | + |
| 286 | + for example in test_crates: |
| 287 | + env = os.environ.copy() |
| 288 | + env.update( |
| 289 | + RUSTUP_TOOLCHAIN="nightly", |
| 290 | + PYTHONPATH=str(EMSCRIPTEN_DIR), |
| 291 | + _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata__emscripten_wasm32-emscripten", |
| 292 | + _PYTHON_HOST_PLATFORM="emscripten_3_1_14_wasm32", |
| 293 | + CARGO_BUILD_TARGET="wasm32-unknown-emscripten", |
| 294 | + CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_LINKER=str( |
| 295 | + EMSCRIPTEN_DIR / "emcc_wrapper.py" |
| 296 | + ), |
| 297 | + PYO3_CONFIG_FILE=pyo3_config.name, |
| 298 | + ) |
| 299 | + with session.chdir(example): |
| 300 | + cmd = ["python", "-m", "build", "--wheel", "--no-isolation"] |
| 301 | + session.run(*cmd, env=env, external=True) |
| 302 | + |
| 303 | + with session.chdir(EMSCRIPTEN_DIR): |
| 304 | + session.run("node", "runner.js", str(example), external=True) |
294 | 305 |
|
295 | 306 |
|
296 | 307 | @nox.session(name="bump-version") |
|
0 commit comments