Skip to content

Build Python Runtime #152

Build Python Runtime

Build Python Runtime #152

name: Build Python Runtime
on: workflow_dispatch
jobs:
build:
runs-on: ubuntu-22.04
name: build Python runtime
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Setup Runner
uses: ./.github/actions/setup-runner
- name: Configure download mirrors
shell: bash
run: |
if [ ! -z "${{ secrets.WORKERS_MIRROR_URL }}" ] ; then
# Strip comment in front of WORKERS_MIRROR_URL, then substitute secret to use it.
sed -e '/WORKERS_MIRROR_URL/ { s@# *@@; s@WORKERS_MIRROR_URL@${{ secrets.WORKERS_MIRROR_URL }}@; }' -i.bak WORKSPACE
fi
- name: Build and upload Pyodide capnproto bundle
env:
R2_ACCOUNT_ID: ${{ secrets.PYODIDE_CAPNP_R2_ACCOUNT_ID }}
R2_ACCESS_KEY_ID: ${{ secrets.PYODIDE_CAPNP_R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.PYODIDE_CAPNP_R2_SECRET_ACCESS_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bazel build @workerd//src/pyodide:python_bundles @workerd//src/pyodide:bundle_version_info --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev
# boto3 v1.36.0 fails with:
# NotImplemented error occurred in CreateMultipartUpload operation: Header 'x-amz-checksum-algorithm' with value 'CRC32' not implemented
pip install 'boto3<1.36.0' requests
python3 src/pyodide/upload_bundles.py
- name: Check for open PR and commit changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Commit changes to python_metadata.bzl and push to branch
# Configure git
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# Get current branch name
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: $BRANCH_NAME"
# Check if there are changes to python_metadata.bzl
if git diff --quiet build/python_metadata.bzl; then
echo "No changes to python_metadata.bzl"
exit 0
fi
echo "Changes detected in python_metadata.bzl"
# Check if there's an open PR for this branch
PR_COUNT=$(gh pr list --head "$BRANCH_NAME" --state open --json number --jq length)
if [ "$PR_COUNT" -eq 0 ]; then
echo "No open PR found for branch $BRANCH_NAME, skipping commit"
exit 0
fi
echo "Found open PR for branch $BRANCH_NAME"
# Commit and push the changes
git add build/python_metadata.bzl
git commit -m "Update python_metadata.bzl with new bundle info
This commit updates the backport and integrity values in python_metadata.bzl
based on the latest Pyodide bundle upload.
🤖 Generated automatically by release-python-runtime workflow"
git push origin "$BRANCH_NAME"
echo "Changes committed and pushed to $BRANCH_NAME"