-
-
Notifications
You must be signed in to change notification settings - Fork 989
Minor improvements to the Emscripten instructions #1795
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
Merged
+38
−23
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
07b10cc
Minor improvements to the Emscripten instructions
hoodmane 3118b20
Remove incorrect statement about ccache
hoodmane 8138eed
Add note about nvm
hoodmane 48e1eb2
link to nvm
hoodmane f5faa02
Document `--host-runner` argument as alternative to nvm
hoodmane a8df476
lint
hoodmane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -522,39 +522,49 @@ The simplest way to build Emscripten is to run: | |
|
|
||
| .. code-block:: sh | ||
|
|
||
| python3 Platforms/emscripten build all --emsdk-cache=./cross-build/emsdk | ||
| export EMSDK_CACHE=$PWD/cross-build/emsdk | ||
| python3 Platforms/emscripten install-emscripten | ||
| python3 Platforms/emscripten build all | ||
|
|
||
| This will: | ||
| `install-emscripten` downloads and installs the version of the Emscripten SDK | ||
| required, placing it in the `EMSDK_CACHE` directory. | ||
| `build all` will: | ||
|
|
||
| 1. Build a copy of Python that can run on the host machine (the "build" python); | ||
| 2. Download a copy of the Emscripten SDK matching the version required by the | ||
| version of Python being compiled; | ||
| 3. Ensure that a required version of Node is installed; | ||
| 4. Download the code for all the binary dependencies of Python (such as | ||
| ``libFFI`` and ``xz``), and compile them for Emscripten; and | ||
| 5. Build a copy of Python that can run on Emscripten (the "host" python). | ||
|
|
||
| If you omit the ``--emsdk-cache`` environment variable, the build script will | ||
| 2. Use nvm_ to ensure that the needed version of Node is installed; | ||
| 3. Download the code for all the binary dependencies of Python (such as | ||
| ``libffi`` and ``mpdecimal``), and compile them for Emscripten; and | ||
| 4. Build a copy of Python that can run on Emscripten (the "host" python). | ||
|
|
||
| The built binary dependencies are cached inside the Emscripten cache directory. | ||
| Once built for a given Emscripten version, they will not be rebuilt on | ||
| subsequent runs unless there is a change in the version or build script for the | ||
| dependency. | ||
|
|
||
| It is assumed that nvm_ is installed in `${HOME}/.nvm`. | ||
|
|
||
| If you omit the ``EMSDK_CACHE`` environment variable, the build script will | ||
| assume that the current environment has the Emscripten tools available. You are | ||
| responsible for downloading and activating those tools in your environment. The | ||
| version of Emscripten and Node that is required to build Python is defined in | ||
| the :cpy-file:`Platforms/emscripten/config.toml` configuration file. | ||
|
|
||
| There are three environment variables that can be used to control the operation of | ||
| There are two environment variables that can be used to control the operation of | ||
| the ``Platforms/emscripten`` build script: | ||
|
|
||
| * ``EMSDK_CACHE`` controls the location of the emscripten SDK. You can use this instead | ||
| environment variable instead of passing the ``--emsdk-cache`` flag. | ||
| * ``CACHE_DIR`` defines the location where downloaded artefacts, such | ||
| as precompiled ``libFFI`` and ``xz`` binaries, will be stored. | ||
| * ``CROSS_BUILD_DIR`` defines the name of the ``cross-build`` directory | ||
| that will be used for builds. This can be useful if you need to maintain | ||
| builds of multiple versions of Python. | ||
| * ``EMSDK_CACHE`` (or the ``--emsdk-cache`` flag) controls the location of the | ||
| Emscripten SDK cache directory. You can use this environment variable instead | ||
| of passing the ``--emsdk-cache`` flag. When set, the build script will | ||
| validate that the required Emscripten version is present in the cache and will | ||
| exit with an error if it is not; run ``install-emscripten`` to populate the | ||
| cache. | ||
| * ``CROSS_BUILD_DIR`` (or the ``--cross-build-dir`` flag) defines the location | ||
| of the ``cross-build`` directory that will be used for builds. This can be | ||
| useful if you need to maintain builds of multiple versions of Python | ||
| side by side. | ||
|
|
||
| It is possible (but not necessary) to enable ``ccache`` for Emscripten builds | ||
| by setting the ``EM_COMPILER_WRAPPER`` environment, but this step will only | ||
| take effect if it is done **after** ``emsdk_env.sh`` is sourced (otherwise, the | ||
|
Comment on lines
-555
to
-556
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be difficult to do now since our script automatically sources |
||
| sourced script removes the environment variable): | ||
| by setting the ``EM_COMPILER_WRAPPER`` environment variable: | ||
|
|
||
| .. code-block:: sh | ||
|
|
||
|
|
@@ -571,8 +581,9 @@ Emscripten build in ``cross-build/build`` and | |
| ``cross-build/wasm32-emscripten/build/python/``, respectively. | ||
|
|
||
| The ``Platforms/emscripten`` script has a number of other entry points that allow for | ||
| fine-grained execution of each part of an iOS build; run ``python3 | ||
| Platforms/emscripten --help`` for more details. | ||
| fine-grained execution of each part of an Emscripten build; run | ||
| ``python3 Platforms/emscripten --help`` for more details. | ||
|
|
||
|
|
||
| Once the build is complete, you can run Python code using: | ||
|
|
||
|
|
@@ -592,6 +603,7 @@ through web browsers) are available in the CPython repository at | |
|
|
||
| .. _Emscripten: https://emscripten.org/ | ||
| .. _WebAssembly: https://webassembly.org | ||
| .. _nvm: https://github.com/nvm-sh/nvm#intro | ||
|
|
||
| Android | ||
| ------- | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we should search for nvm first in
NVM_DIRthen inXDG_CONFIG_HOMEand then inHOMEsince that's where nvm likes to install itself. But we don't currently do that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we should add a
HOST_RUNNERenvironment variable so people can setexport HOST_RUNNER=nodeif they don't want nvm to be used. Currently you can do that by passing--host-runner=nodeso I guess I can document that much.