This is an experiment to build a Spin Python SDK using CPython, Wizer, and PyO3.
- WASI SDK v16 or later, installed in /opt/wasi-sdk
- CPython build prereqs (e.g. Make, Clang, etc.)
- Rust (including
wasm32-wasitarget) - Spin
- pipenv for installing Python project dependencies
First, build CPython for wasm32-wasi:
git submodule update --init --recursive
mkdir -p cpython/builddir/wasi
mkdir -p cpython/builddir/build
cd cpython/builddir/build
../../configure --prefix=$(pwd)/install --enable-optimizations
make
cd ../wasi
CONFIG_SITE=../../Tools/wasm/config.site-wasm32-wasi ../../Tools/wasm/wasi-env \
../../configure -C --host=wasm32-unknown-wasi --build=$(../../config.guess) \
--with-build-python=$(pwd)/../build/python --prefix=$(pwd)/install --disable-test-modules
make
make install
cd ../../..
Then, build the spin-python-cli:
make
Finally, build and run the example app:
cd examples/hello
pipenv install
spin build
spin up