Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use ``pybuilddir.txt`` to find ``_sysconfigdata`` for the WASI build script.
13 changes: 10 additions & 3 deletions Platforms/WASI/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,16 @@ def configure_wasi_python(context, working_dir):
)
lib_dir = os.fsdecode(lib_dirs[0])
python_version = lib_dir.rpartition("-")[-1]
sysconfig_data_dir = (
f"{wasi_build_dir}/build/lib.wasi-wasm32-{python_version}"
)

pybuilddir = working_dir / "pybuilddir.txt"
if pybuilddir.is_file():
with pybuilddir.open("r", encoding="utf-8") as f:
sysconfig_data_dir = f"{wasi_build_dir}/{f.read().strip()}"
else:
# Fallback if the build hasn't generated the file yet
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something feels off. Why did I ever care about setting this when configuring the host? If I remember correctly it was because tests failed using the host runner if I didn't via make test. But that doesn't seem right since that would mean a WASI build was somehow special in regards to paths compared to any other build which it shouldn't be. Plus if the python.sh shell script works which doesn't make the change to PYTHONPATH then it really feels weird that this is even here.

Can someone test what happens if you just take out the environment updates?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's right. I tested removing the environment updates. Without PYTHONPATH, tests fail with ModuleNotFoundError: No module named '_sysconfigdata__wasi_wasm32-wasi' (because this lives in the build dir and not in Lib/, I think).

python.sh does include PYTHONPATH. It's just passed in via --env in the wasmtime command.

sysconfig_data_dir = (
f"{wasi_build_dir}/build/lib.wasi-wasm32-{python_version}"
)

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