Skip to content

Commit b64935a

Browse files
committed
gh-144533: Use pybuilddir.txt to find _sysconfigdata for WASI
1 parent 957f9fe commit b64935a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use ``pybuilddir.txt`` to find ``_sysconfigdata`` for the WASI build script.

Platforms/WASI/__main__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,16 @@ def configure_wasi_python(context, working_dir):
324324
)
325325
lib_dir = os.fsdecode(lib_dirs[0])
326326
python_version = lib_dir.rpartition("-")[-1]
327-
sysconfig_data_dir = (
328-
f"{wasi_build_dir}/build/lib.wasi-wasm32-{python_version}"
329-
)
327+
328+
pybuilddir = working_dir / "pybuilddir.txt"
329+
if pybuilddir.is_file():
330+
with pybuilddir.open("r", encoding="utf-8") as f:
331+
sysconfig_data_dir = f"{wasi_build_dir}/{f.read().strip()}"
332+
else:
333+
# Fallback if the build hasn't generated the file yet
334+
sysconfig_data_dir = (
335+
f"{wasi_build_dir}/build/lib.wasi-wasm32-{python_version}"
336+
)
330337

331338
# Use PYTHONPATH to include sysconfig data which must be anchored to the
332339
# WASI guest's `/` directory.

0 commit comments

Comments
 (0)