Skip to content

gh-144533: Use pybuilddir.txt to find _sysconfigdata for WASI#144535

Open
therohityadav wants to merge 1 commit intopython:mainfrom
therohityadav:fix-wasi-build-144533
Open

gh-144533: Use pybuilddir.txt to find _sysconfigdata for WASI#144535
therohityadav wants to merge 1 commit intopython:mainfrom
therohityadav:fix-wasi-build-144533

Conversation

@therohityadav
Copy link

Use pybuilddir.txt to find _sysconfigdata for the WASI build script.

The previous implementation hardcoded the path pattern to build/lib.wasi-wasm32-{python_version}. This change makes the script more robust by reading the exact build directory from pybuilddir.txt if it exists. It falls back to the hardcoded path if the file is missing to ensure backward compatibility during early build stages.

@python-cla-bot
Copy link

python-cla-bot bot commented Feb 6, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Feb 6, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@therohityadav therohityadav force-pushed the fix-wasi-build-144533 branch 2 times, most recently from 035c77e to b64935a Compare February 6, 2026 08:59
Comment on lines 320 to 326
@@ -324,9 +324,16 @@ def configure_wasi_python(context, working_dir):
)
lib_dir = os.fsdecode(lib_dirs[0])
python_version = lib_dir.rpartition("-")[-1]
Copy link
Member

Choose a reason for hiding this comment

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

I think we'd want to move this into the else case as well so we don't leave dead code in the path where we are using pybuilddir.txt. This code is only used for the fallback now.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the review mam. I have moved the logic into the else block so those variables are only calculated in the fallback path. This should prevent any dead code execution when pybuilddir.txt is present.

@bedevere-app
Copy link

bedevere-app bot commented Feb 6, 2026

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants