Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add section on building for Emscripten #1533

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

hoodmane
Copy link

@hoodmane hoodmane commented Mar 20, 2025

Heavily copied from Brett's WASI guide.


📚 Documentation preview 📚: https://cpython-devguide--1533.org.readthedocs.build/getting-started/setup-building/#emscripten

Heavily copied from Brett's WASI guide.
@hoodmane hoodmane requested review from brettcannon and hugovk March 20, 2025 10:02
Comment on lines 490 to 494
Building for Emscripten requires doing a cross-build where you have a *build*
Python to help produce a Emscripten build of CPython. This means you build
CPython twice: once to have a version of Python for the build system to use and
another that's the build you ultimately care about (that is, the build Python is
not meant for use by you directly, only the build system).
Copy link
Member

Choose a reason for hiding this comment

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

Instead of (almost) duplicating things, maybe this could refer (and link) to the section above, e.g.:
"Like WASI, you will have to build Python twice."

I haven't looked at them side-by-side to see how similar they are, but if they are quite similar another option is merging the two sections and using tabs where they are different.

Copy link
Author

Choose a reason for hiding this comment

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

I think it's better to duplicate since there's no reason to think they won't diverge in the future. And I don't want to cause trouble for @brettcannon. Let's see what he thinks.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with duplication to avoid issues for accidental divergence.

@brettcannon
Copy link
Member

Do note that I didn't add the WASI docs until WASI explicitly reached tier 2. I don't know if we have a defined policy around this, though, beyond me just wanting to personally wait until I reached the tier 2 milestone.

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@hoodmane
Copy link
Author

Thanks for the edits @hugovk!

# Install Emscripten
git clone emscripten/emsdk
./emsdk/emsdk install 4.0.5
./emsdk/emsdk activate 4.0.5
Copy link
Contributor

Choose a reason for hiding this comment

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

As a safety catch for the future - do we want to flag that this version number is significant, and you should be using the version that Python is targeting?

Copy link
Author

Choose a reason for hiding this comment

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

How do people figure out which version Python is targeting?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess that's the question for the documentation to resolve :-)

Right now, I'd say it's a case of "check the Emscripten README to find the version you need".

Longer term, maybe it would be worth adding a helper entry point to the Tools/wasm/emscripten script that will print/verify the required emscripten version? That would mean the emscripten version is defined in code, and can be checked at runtime.

Copy link
Member

Choose a reason for hiding this comment

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

You could also define a container in https://github.com/python/cpython-devcontainers/ and somehow specify which build that branch of CPython is tied to.

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants