@@ -9,68 +9,14 @@ compilation of CPython to WebAssembly (WASM). Python supports Emscripten
99run in modern browsers and JavaScript runtimes like * Node.js* . WASI builds
1010use WASM runtimes such as * wasmtime* .
1111
12- Users and developers are encouraged to use the script
13- ` Tools/wasm/wasm_build.py ` . The tool automates the build process and provides
14- assistance with installation of SDKs, running tests, etc.
12+ ** NOTE** : If you are looking for general information about WebAssembly that is
13+ not directly related to CPython, please see https://github.com/psf/webassembly .
1514
16- ** NOTE** : If you are looking for information that is not directly related to
17- building CPython for WebAssembly (or the resulting build), please see
18- https://github.com/psf/webassembly  for more information.
19- 
20- ## wasm32-emscripten  
15+ ## Emscripten (wasm32-emscripten)  
2116
2217### Build  
2318
24- To cross compile to the `` wasm32-emscripten ``  platform you need
25- [ the Emscripten compiler toolchain] ( https://emscripten.org/ ) ,
26- a Python interpreter, and an installation of Node version 18 or newer.
27- Emscripten version 4.0.2 is recommended; newer versions may also work, but all
28- official testing is performed with that version. All commands below are relative
29- to a checkout of the Python repository.
30- 
31- #### Install [ the Emscripten compiler toolchain] ( https://emscripten.org/docs/getting_started/downloads.html )   
32- 
33- You can install the Emscripten toolchain as follows:
34- ``` shell 
35- git clone https://github.com/emscripten-core/emsdk.git --depth 1
36- ./emsdk/emsdk install latest
37- ./emsdk/emsdk activate latest
38- ``` 
39- To add the Emscripten compiler to your path:
40- ``` shell 
41- source  ./emsdk/emsdk_env.sh
42- ``` 
43- This adds ` emcc `  and ` emconfigure `  to your path.
44- 
45- ##### Optionally: enable ccache for EMSDK  
46- 
47- The `` EM_COMPILER_WRAPPER ``  must be set after the EMSDK environment is
48- sourced. Otherwise the source script removes the environment variable.
49- 
50- ``` shell 
51- export  EM_COMPILER_WRAPPER=ccache
52- ``` 
53- 
54- #### Compile and build Python interpreter  
55- 
56- You can use ` python Tools/wasm/emscripten `  to compile and build targeting
57- Emscripten. You can do everything at once with:
58- ``` shell 
59- python Tools/wasm/emscripten build
60- ``` 
61- or you can break it out into four separate steps:
62- ``` shell 
63- python Tools/wasm/emscripten configure-build-python
64- python Tools/wasm/emscripten make-build-python
65- python Tools/wasm/emscripten make-libffi
66- python Tools/wasm/emscripten configure-host
67- python Tools/wasm/emscripten make-host
68- ``` 
69- Extra arguments to the configure steps are passed along to configure. For
70- instance, to do a debug build, you can use:
71- ``` shell 
72- python Tools/wasm/emscripten build --with-py-debug
73- ``` 
19+ See [ the devguide instructions for building for Emscripten] ( https://devguide.python.org/getting-started/setup-building/#emscripten ) .
7420
7521### Running from node  
7622
@@ -97,8 +43,8 @@ You can run the browser smoke test with:
9743
9844### The Web Example  
9945
100- When building for Emscripten, the  web example will be built automatically. It 
101- is  in the `` web_example ``  directory. To run the web example, `` cd ``  into the
46+ When building for Emscripten, a small  web example will be built automatically
47+ in the `` web_example ``  directory. To run the web example, `` cd ``  into the
10248`` web_example ``  directory, then run `` python server.py `` . This will start a web
10349server; you can then visit `` http://localhost:8000/ ``  in a browser to see a
10450simple REPL example.
0 commit comments