Skip to content

Commit 39f8f67

Browse files
committed
use temporary pyo3 config with correct version
1 parent 08ff34e commit 39f8f67

2 files changed

Lines changed: 30 additions & 26 deletions

File tree

emscripten/pyo3_config.ini

Lines changed: 0 additions & 7 deletions
This file was deleted.

noxfile.py

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import shutil
77
import sys
88
import json
9+
import tempfile
910

1011
import nox
1112
import nox.command
@@ -272,25 +273,35 @@ def test_examples_emscripten(session: nox.Session):
272273
examples_dir / "html-py-ever",
273274
examples_dir / "namespace_package",
274275
]
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)
294305

295306

296307
@nox.session(name="bump-version")

0 commit comments

Comments
 (0)