Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-102404, GH-100956: Document how to do a WASI build#105251

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
brettcannon merged 14 commits intopython:mainfrombrettcannon:document-wasi-build
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
14 commits
Select commitHold shift + click to select a range
5f0cb3c
Touch up Markdown sections
brettcannonMay 12, 2023
80361bd
Document getting a build Python
brettcannonMay 12, 2023
60cd12e
checkpoint
brettcannonMay 25, 2023
019dcb5
Document building the host/WASI Python
brettcannonJun 1, 2023
f399888
Fix a typo
brettcannonJun 2, 2023
df1cf20
Merge branch 'document-wasi-build' of https://github.com/brettcannon/…
brettcannonJun 2, 2023
70da5a2
Drop a TODO marker
brettcannonJun 2, 2023
851e3e9
Simplify instructions
brettcannonJun 2, 2023
827d1ec
Add a `build_wasi.sh` script
brettcannonJun 2, 2023
0c4e4c7
Add a news entry
brettcannonJun 2, 2023
dd7d405
Merge branch 'main' into document-wasi-build
brettcannonJun 2, 2023
2f8d525
Make all the paths in `build_wasi.sh` absolute
brettcannonJun 2, 2023
f13b10a
Merge branch 'document-wasi-build' of https://github.com/brettcannon/…
brettcannonJun 2, 2023
cf680c3
Address review comments
brettcannonJun 2, 2023
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
PrevPrevious commit
NextNext commit
Make all the paths inbuild_wasi.sh absolute
  • Loading branch information
@brettcannon
brettcannon committedJun 2, 2023
commit2f8d525b4628e53c755d6ff1a4e686a67251edf6
10 changes: 5 additions & 5 deletionsTools/wasm/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -299,7 +299,7 @@ AddType application/wasm wasm
## WASI (wasm32-wasi)

WASI builds require the [WASI SDK](https://github.com/WebAssembly/wasi-sdk) 16.0+.
See `.devcontainer/devcontainer.json` for an example of how to download and
See `.devcontainer/Dockerfile` for an example of how to download and
install the WASI SDK.

### Build
Expand All@@ -308,7 +308,7 @@ The script ``wasi-env`` sets necessary compiler and linker flags as well as
``pkg-config`` overrides. The script assumes that WASI-SDK is installed in
``/opt/wasi-sdk`` or ``$WASI_SDK_PATH``.

There are two scripts you can use to do a WASI build. You can either use:
There are two scripts you can use to do a WASI build from a source checkout. You can either use:

```shell
./Tools/wasm/wasm_build.py wasi build
Expand DownExpand Up@@ -341,7 +341,7 @@ The commands are equivalent to the following steps:
- `pushd builddir/wasi`
- `../../Tools/wasm/wasi-env ../../configure -C --host=wasm32-unknown-wasi --build=$(../../config.guess) --with-build-python=../build/python`
- `CONFIG_SITE=../../Tools/wasm/config.site-wasm32-wasi`
- `HOSTRUNNER="wasmtime run --mapdir /::../..--env PYTHONPATH=/builddir/wasi/build/lib.wasi-wasm32-$PYTHON_VERSION python.wasm --"`
- `HOSTRUNNER="wasmtime run --mapdir /::$(dirname $(dirname $(pwd)))--env PYTHONPATH=/builddir/wasi/build/lib.wasi-wasm32-$PYTHON_VERSION$(pwd)/python.wasm --"`
- Maps the source checkout to `/` in the WASI runtime
- Stdlib gets loaded from `/Lib`
- Gets `_sysconfigdata__wasi_wasm32-wasi.py` on to `sys.path` via `PYTHONPATH`
Expand All@@ -365,13 +365,13 @@ The commands are equivalent to the following steps:

### Running

If you followed the instructions above, you can run the interpreter via e.g., `wasmtime` (make sure tospecify/changethe`$PYTHON_VERSION`tothemajor.minor version that you just built):
If you followed the instructions above, you can run the interpreter via e.g., `wasmtime`from within the `Tools/wasi` directory(make sure toset/change `$PYTHON_VERSION`and do notethepaths are relative to running in`builddir/wasi` for simplicity only):

```shell
wasmtime run --mapdir /::../.. --env PYTHONPATH=/builddir/wasi/build/lib.wasi-wasm32-$PYTHON_VERSION python.wasm -- <args>
```

There are also helpers provided by `Tools/wasm/wasm_build.py` as listed below. Also, if you used `Tools/wasm/build_wasi.sh`, a `run_wasi.sh` file will be created in `builddir/wasi` which will run the above command for you.
There are also helpers provided by `Tools/wasm/wasm_build.py` as listed below. Also, if you used `Tools/wasm/build_wasi.sh`, a `run_wasi.sh` file will be created in `builddir/wasi` which will run the above command for you (it also uses absolute paths, so it can be executed from anywhere).

#### REPL

Expand Down
4 changes: 2 additions & 2 deletionsTools/wasm/build_wasi.sh
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,8 +17,8 @@ export PYTHON_VERSION=`./python -c 'import sys; print(f"{sys.version_info.major}
popd

# Create the host/WASI Python.
export CONFIG_SITE="../../Tools/wasm/config.site-wasm32-wasi"
export HOSTRUNNER="wasmtime run --mapdir /::../.. --env PYTHONPATH=/builddir/wasi/build/lib.wasi-wasm32-$PYTHON_VERSION python.wasm --"
export CONFIG_SITE="$(pwd)/Tools/wasm/config.site-wasm32-wasi"
export HOSTRUNNER="wasmtime run --mapdir /::$(pwd) --env PYTHONPATH=/builddir/wasi/build/lib.wasi-wasm32-$PYTHON_VERSION$(pwd)/builddir/wasi/python.wasm --"

mkdir -p builddir/wasi
pushd builddir/wasi
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp