Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 27 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# Dummy tag; version does not matter.
TAG: cpython-devcontainer:1.0.0-${{ github.run_id }}
steps:
- name: Checkout Push to Registry action
- name: Checkout
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -32,6 +32,31 @@ jobs:
- name: Test clang
run: docker run --rm ${{ env.TAG }} clang --version

build_wasi_container:
name: Build and test (WASI container)
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm]
runs-on: ${{ matrix.os }}
env:
TAG: cpython-wasicontainer:1.0.0-${{ github.run_id }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Dockerfile
uses: docker/build-push-action@v6
with:
context: ./wasicontainer
load: true
tags: ${{ env.TAG }}
- name: Test WASI SDK
run: docker run --rm ${{ env.TAG }} /opt/wasi-sdk/bin/clang --version
- name: Test Wasmtime
run: docker run --rm ${{ env.TAG }} wasmtime --version

build_autoconf:
name: Build and test (Autoconf)
strategy:
Expand All @@ -43,7 +68,7 @@ jobs:
env:
TAG: autoconf:${{ matrix.autoconf_version }}-${{ github.run_id }}
steps:
- name: Checkout Push to Registry action
- name: Checkout
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
options:
- autoconf
- devcontainer
- wasicontainer

run-name: "Release: ${{ inputs.package }}"

Expand Down
20 changes: 20 additions & 0 deletions wasicontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ghcr.io/python/devcontainer:latest

LABEL org.opencontainers.image.base.name="ghcr.io/python/wasicontainer:latest"
LABEL org.opencontainers.image.source="https://github.com/python/cpython-devcontainers"
LABEL org.opencontainers.image.title="CPython WASI development container"
LABEL org.opencontainers.image.description="CPython development container with the tooling to work on WASI builds."
LABEL org.opencontainers.image.authors="Brett Cannon"

ARG TARGETARCH

# WASI SDK versions are controlled in install-wasi.sh.
ENV WASI_SDK_ROOT=/opt

ENV WASMTIME_VERSION=36.0.2
ENV WASMTIME_HOME=/opt/wasmtime

RUN mkdir -p /opt/cpython-devcontainer/bin
COPY --chmod=755 install-wasi.sh /opt/cpython-devcontainer/bin/

RUN /opt/cpython-devcontainer/bin/install-wasi.sh
3 changes: 3 additions & 0 deletions wasicontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
A container for developing CPython for WASI.

It is based on the dev container, and thus includes the same common utilities.
45 changes: 45 additions & 0 deletions wasicontainer/install-wasi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#! /bin/bash -ex

mkdir --parents ${WASI_SDK_ROOT}

# For 3.11, 3.12.
# There is no Arm support for WASI SDK < 23.
if [ "${TARGETARCH}" = "amd64" ]; then
URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-linux.tar.gz
curl --location $URL | tar --directory ${WASI_SDK_ROOT} --extract --gunzip
fi

case "${TARGETARCH}" in
amd64) WASI_ARCH="x86_64" ;;
arm64) WASI_ARCH="arm64" ;;
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;;
esac && \

# 24: 3.13, 3.14
# The URL format only works for WASI SDK >= 23.
WASI_SDK_VERSIONS=(24)
for VERSION in "${WASI_SDK_VERSIONS[@]}"; do
URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${VERSION}/wasi-sdk-${VERSION}.0-${WASI_ARCH}-linux.tar.gz
curl --location $URL | tar --directory ${WASI_SDK_ROOT} --extract --gunzip
done

# For Python 3.13 as Tools/wasm/wasi.py expects /opt/wasi-sdk by default.
ln -s ${WASI_SDK_ROOT}/wasi-sdk-24.0*/ /opt/wasi-sdk


mkdir --parents ${WASMTIME_HOME}

case "${TARGETARCH}" in
amd64) WASMTIME_ARCH="x86_64" ;;
arm64) WASMTIME_ARCH="aarch64" ;;
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;;
esac

URL="https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION}/wasmtime-v${WASMTIME_VERSION}-${WASMTIME_ARCH}-linux.tar.xz"

curl --location $URL |
xz --decompress |
tar --strip-components 1 --directory ${WASMTIME_HOME} -x

# Put `wasmtime` on $PATH.
ln -s ${WASMTIME_HOME}/wasmtime* /usr/local/bin
Loading