Skip to content

Build CPython

Build CPython #287

Workflow file for this run

name: Build CPython
on:
workflow_dispatch:
inputs:
python_version:
required: true
type: string
platforms:
required: true
type: string
default: "linux-x86_64,linux-aarch64,linux-i386,linux-arm,linux-riscv64,linux-loongarch64,linux-s390x,linux-powerpc64le,macos,windows,cosmo,freebsd13-x86_64,freebsd14-x86_64,freebsd15-x86_64,solaris11-x86_64"
buildsystem_branch:
required: false
type: string
default: "portable-python"
run_tests:
required: false
type: boolean
debug:
required: false
type: boolean
debug_interactive:
required: false
type: boolean
verbose:
required: false
type: boolean
workflow_call:
inputs:
python_version:
required: true
type: string
platforms:
required: true
type: string
buildsystem_branch:
required: false
type: string
run_tests:
required: false
type: boolean
debug:
required: false
type: boolean
verbose:
required: false
type: boolean
env:
RUN_TESTS: ${{ inputs.run_tests }}
DEBUG_CI: ${{ inputs.debug }}
VERBOSE_CI: ${{ inputs.verbose }}
PORTABLE_PYTHON_BUILDSYSTEM_BRANCH: ${{ inputs.buildsystem_branch || 'portable-python' }}
image_map: '{"x86_64": "amd64/ubuntu:18.04", "i386": "i386/ubuntu:18.04", "aarch64": "arm64v8/ubuntu:18.04", "arm": "arm32v7/debian:bullseye", "riscv64": "riscv64/debian:sid", "loongarch64": "loongarch64/debian:sid", "s390x": "s390x/debian:bullseye", "powerpc64le": "ppc64le/ubuntu:18.04"}'
platform_map: '{"x86_64": "linux/amd64", "i386": "linux/386", "aarch64": "linux/arm64/v8", "arm": "linux/arm/v7", "riscv64": "linux/riscv64", "loongarch64": "linux/loong64", "s390x": "linux/s390x", "powerpc64le": "linux/ppc64le"}'
freebsd_release_map: '{"15": "15.0", "14": "14.0", "13": "13.2"}'
solaris_release_map: '{"11": "11.4"}'
jobs:
build_linux:
name: Linux ${{ inputs.python_version }} ${{ matrix.arch }} ${{ matrix.distribution }}
if: ${{ contains(inputs.platforms, 'linux') }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
arch: [x86_64, i386, aarch64, arm, riscv64, s390x, loongarch64, powerpc64le]
distribution: [full, headless]
exclude:
- arch: ${{ !contains(inputs.platforms, 'linux-x86_64') && 'x86_64' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-i386') && 'i386' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-aarch64') && 'aarch64' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-arm') && 'arm' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-riscv64') && 'riscv64' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-loongarch64') && 'loongarch64' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-s390x') && 's390x' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-powerpc64le') && 'powerpc64le' || '' }}
steps:
- name: Parse image
id: parse_image
run: |
IMAGE=$(echo ${{ toJSON(env.image_map) }} | jq -r '.["${{ matrix.arch }}"]')
echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
- name: Parse platform
id: parse_platform
run: |
PLATFORM=$(echo ${{ toJSON(env.platform_map) }} | jq -r '.["${{ matrix.arch }}"]')
echo "platform=$PLATFORM" >> "$GITHUB_OUTPUT"
- name: Set up zig
uses: mlugg/setup-zig@v1
with:
version: 0.14.0-dev.2287+70ad7dcd4
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
./scripts/build_linux_zig.sh ${{ matrix.arch }} ${{ inputs.python_version }} ${{ matrix.distribution }}
- name: Interactive debugging
if: ${{ always() && inputs.debug_interactive }}
uses: fawazahmed0/action-debug-vscode@v3
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-linux-${{ matrix.arch }}-${{ matrix.distribution }}-${{ inputs.python_version }}
path: ./python*.zip
- name: Upload artifacts
if: ${{ always() && inputs.debug }}
uses: actions/upload-artifact@v4
with:
name: build-python-linux-${{ matrix.arch }}-${{ matrix.distribution }}-${{ inputs.python_version }}
path: ./*python*.tar.gz
- name: Test python in clean environment
uses: addnab/docker-run-action@v3
with:
image: ${{ steps.parse_image.outputs.image }}
options: --platform ${{ steps.parse_platform.outputs.platform }} -v ${{ github.workspace }}:/work --workdir /tmp
shell: bash
run: |
set -e
uname -a
apt update
apt -y install unzip
cp /work/python*.zip .
unzip ./python*.zip
cd python-${{ matrix.distribution }}-${{ inputs.python_version }}-linux-${{ matrix.arch }}
chmod +x ./bin/python
ldd -v -r ./bin/python
./bin/python --version
./bin/python -m sysconfig
./bin/python /work/scripts/test.py
./bin/pip3
if [[ "${{ inputs.run_tests }}" == "true" ]]; then
./bin/python -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata --timeout 60
fi
build_windows:
name: Windows ${{ inputs.python_version }} x86_64 ${{ matrix.distribution }} (build)
if: ${{ contains(inputs.platforms, 'windows') }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
distribution: [full, headless]
steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v4
- name: Configure build for x86_64
uses: ilammy/[email protected]
- name: Remove Strawberry
shell: pwsh
run: |
Rename-Item c:\strawberry strawberry2
- name: Build
shell: bash
run: |
set -ex
./scripts/build_windows.sh x86_64 ${{ inputs.python_version }} ${{ matrix.distribution }}
- name: Interactive debugging
uses: fawazahmed0/action-debug-vscode@v3
if: ${{ always() && inputs.debug_interactive }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-windows-x86_64-${{ matrix.distribution }}-${{ inputs.python_version }}
path: ./python*.zip
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: ${{ always() && inputs.debug }}
with:
name: build-python-windows-x86_64-${{ matrix.distribution }}-${{ inputs.python_version }}
path: ./*python*.tar.gz
test_windows:
name: Windows ${{ inputs.python_version }} x86_64 ${{ matrix.distribution }} (test)
needs: build_windows
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
distribution: [full, headless]
steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: python-windows-x86_64-${{ matrix.distribution }}-${{ inputs.python_version }}
path: ./python/
- name: Test python in clean environment
shell: bash
run: |
7z.exe x python/python-${{ matrix.distribution }}-${{ inputs.python_version }}-windows-x86_64.zip
cd python-${{ matrix.distribution }}-${{ inputs.python_version }}-windows-x86_64
./bin/python --version
./bin/python -m sysconfig
./bin/python ../scripts/test.py
if [[ "${{ inputs.run_tests }}" == "true" ]]; then
./bin/python -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata --timeout 60
fi
build_macos:
name: MacOS ${{ inputs.python_version }} universal2 ${{ matrix.distribution }} (build)
if: ${{ contains(inputs.platforms, 'macos') }}
runs-on: macos-13
strategy:
fail-fast: false
matrix:
distribution: [full, headless]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install tools
run: |
brew install coreutils gpatch autoconf automake libtool
# use gpatch's "patch" executable
echo "/usr/local/opt/gpatch/libexec/gnubin" >> $GITHUB_PATH
- name: Build
run: |
set -ex
./scripts/build_macos.sh universal2 ${{ inputs.python_version }} ${{ matrix.distribution }}
- name: Interactive debugging
uses: fawazahmed0/action-debug-vscode@v3
if: ${{ always() && inputs.debug_interactive }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-darwin-universal2-${{ matrix.distribution }}-${{ inputs.python_version }}
path: ./python*.zip
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: ${{ always() && inputs.debug }}
with:
name: build-python-darwin-universal2-${{ matrix.distribution }}-${{ inputs.python_version }}
path: ./*python*.tar.gz
test_macos:
name: MacOS ${{ inputs.python_version }} ${{ matrix.arch }} ${{ matrix.distribution }} (test)
needs: build_macos
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ macos-13, macos-14 ]
distribution: [full, headless]
include:
- os: macos-13
arch: x86_64
- os: macos-14
arch: arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: python-darwin-universal2-${{ matrix.distribution }}-${{ inputs.python_version }}
path: ./python/
- name: Test python in clean environment
shell: bash
run: |
unzip python/python-${{ matrix.distribution }}-${{ inputs.python_version }}-darwin-universal2.zip
cd python-${{ matrix.distribution }}-${{ inputs.python_version }}-darwin-universal2
chmod +x ./bin/python
./bin/python --version
./bin/python -m sysconfig
./bin/python ${{ github.workspace }}/scripts/test.py
./bin/pip3
if [[ "${{ inputs.run_tests }}" == "true" ]]; then
./bin/python -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata --timeout 60
fi
build_freebsd:
name: FreeBSD ${{ matrix.release }} ${{ inputs.python_version }} x86_64 ${{ matrix.distribution }} (build)
if: ${{ contains(inputs.platforms, 'freebsd') }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
release: [13, 14, 15]
distribution: [full, headless]
exclude:
- release: ${{ !contains(inputs.platforms, 'freebsd13-x86_64') && '13' || '' }}
- release: ${{ !contains(inputs.platforms, 'freebsd14-x86_64') && '14' || '' }}
- release: ${{ !contains(inputs.platforms, 'freebsd15-x86_64') && '15' || '' }}
steps:
- name: Parse release
id: parse_release
run: |
RELEASE=$(echo ${{ toJSON(env.freebsd_release_map) }} | jq -r '.["${{ matrix.release }}"]')
echo "release=$RELEASE" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4
- name: Start VM
uses: bjia56/freebsd-vm@nfs
with:
sync: nfs
release: ${{ steps.parse_release.outputs.release }}
prepare: |
pkg install -y cmake bash wget patch git zip python3 autoconf automake libtool gettext bison pkgconf gmake gperf patchelf texinfo
chsh -s /usr/local/bin/bash root
- name: Build in VM
shell: freebsd {0}
run: |
cd ${{ github.workspace }}
export RUN_TESTS="${{ env.RUN_TESTS }}"
export DEBUG_CI="${{ env.DEBUG_CI }}"
export VERBOSE_CI="${{ env.VERBOSE_CI }}"
export PORTABLE_PYTHON_BUILDSYSTEM_BRANCH="${{ env.PORTABLE_PYTHON_BUILDSYSTEM_BRANCH }}"
export PLATFORM="freebsd${{ matrix.release }}"
bash ./scripts/build_freebsd.sh x86_64 ${{ inputs.python_version }} ${{ matrix.distribution }}
- name: Interactive debugging
if: ${{ always() && inputs.debug_interactive }}
uses: fawazahmed0/action-debug-vscode@v3
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-freebsd${{ matrix.release }}-x86_64-${{ matrix.distribution }}-${{ inputs.python_version }}
path: ./python*.zip
- name: Upload artifacts
if: ${{ always() && inputs.debug }}
uses: actions/upload-artifact@v4
with:
name: build-python-freebsd${{ matrix.release }}-x86_64-${{ matrix.distribution }}-${{ inputs.python_version }}
path: ./*python*.tar.gz
test_freebsd:
name: FreeBSD ${{ matrix.release }} ${{ inputs.python_version }} x86_64 ${{ matrix.distribution }} (test)
needs: build_freebsd
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
release: [13, 14, 15]
distribution: [full, headless]
exclude:
- release: ${{ !contains(inputs.platforms, 'freebsd13-x86_64') && '13' || '' }}
- release: ${{ !contains(inputs.platforms, 'freebsd14-x86_64') && '14' || '' }}
- release: ${{ !contains(inputs.platforms, 'freebsd15-x86_64') && '15' || '' }}
steps:
- name: Parse release
id: parse_release
run: |
RELEASE=$(echo ${{ toJSON(env.freebsd_release_map) }} | jq -r '.["${{ matrix.release }}"]')
echo "release=$RELEASE" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: python-freebsd${{ matrix.release }}-x86_64-${{ matrix.distribution }}-${{ inputs.python_version }}
path: ./python/
- name: Start VM
uses: bjia56/freebsd-vm@nfs
with:
sync: nfs
release: ${{ steps.parse_release.outputs.release }}
prepare: |
pkg install -y bash
chsh -s /usr/local/bin/bash root
- name: Test in VM
shell: freebsd {0}
run: |
cd ${{ github.workspace }}
unzip python/python-${{ matrix.distribution }}-${{ inputs.python_version }}-freebsd${{ matrix.release }}-x86_64.zip
cd python-${{ matrix.distribution }}-${{ inputs.python_version }}-freebsd${{ matrix.release }}-x86_64
chmod +x ./bin/python
./bin/python --version
./bin/python -m sysconfig
./bin/python ${{ github.workspace }}/scripts/test.py
./bin/pip3
if [[ "${{ inputs.run_tests }}" == "true" ]]; then
./bin/python -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata --timeout 60
fi
build_solaris:
name: Solaris ${{ matrix.release }} ${{ inputs.python_version }} x86_64 ${{ matrix.distribution }} (build)
if: ${{ contains(inputs.platforms, 'solaris') }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
release: [11]
distribution: [full, headless]
exclude:
- release: ${{ !contains(inputs.platforms, 'solaris11-x86_64') && '11' || '' }}
steps:
- name: Parse release
id: parse_release
run: |
RELEASE=$(echo ${{ toJSON(env.solaris_release_map) }} | jq -r '.["${{ matrix.release }}"]')
echo "release=$RELEASE" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4
- name: Start VM
uses: bjia56/solaris-vm@nfs
with:
sync: nfs
release: ${{ steps.parse_release.outputs.release }}
prepare: |
pkg install --accept cmake git autoconf automake libtool bison gperf gcc pkg-config python-39
ln -sf /usr/bin/python3.9 /usr/bin/python3
- name: Build in VM
shell: solaris {0}
run: |
cd ${{ github.workspace }}
export RUN_TESTS="${{ env.RUN_TESTS }}"
export DEBUG_CI="${{ env.DEBUG_CI }}"
export VERBOSE_CI="${{ env.VERBOSE_CI }}"
export PORTABLE_PYTHON_BUILDSYSTEM_BRANCH="${{ env.PORTABLE_PYTHON_BUILDSYSTEM_BRANCH }}"
export PLATFORM="solaris${{ matrix.release }}"
bash ./scripts/build_solaris.sh x86_64 ${{ inputs.python_version }} ${{ matrix.distribution }}
- name: Interactive debugging
if: ${{ always() && inputs.debug_interactive }}
uses: fawazahmed0/action-debug-vscode@v3
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-solaris${{ matrix.release }}-x86_64-${{ matrix.distribution }}-${{ inputs.python_version }}
path: ./python*.zip
- name: Upload artifacts
if: ${{ always() && inputs.debug }}
uses: actions/upload-artifact@v4
with:
name: build-python-solaris${{ matrix.release }}-x86_64-${{ matrix.distribution }}-${{ inputs.python_version }}
path: ./*python*.tar.gz
test_solaris:
name: Solaris ${{ matrix.release }} ${{ inputs.python_version }} x86_64 ${{ matrix.distribution }} (test)
needs: build_solaris
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
release: [11]
distribution: [full, headless]
exclude:
- release: ${{ !contains(inputs.platforms, 'solaris11-x86_64') && '11' || '' }}
steps:
- name: Parse release
id: parse_release
run: |
RELEASE=$(echo ${{ toJSON(env.solaris_release_map) }} | jq -r '.["${{ matrix.release }}"]')
echo "release=$RELEASE" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: python-solaris${{ matrix.release }}-x86_64-${{ matrix.distribution }}-${{ inputs.python_version }}
path: ./python/
- name: Start VM
uses: bjia56/solaris-vm@nfs
with:
sync: nfs
release: ${{ steps.parse_release.outputs.release }}
- name: Test in VM
shell: solaris {0}
run: |
cd ${{ github.workspace }}
cat > /tmp/test.sh <<EOF
unzip python/python-${{ matrix.distribution }}-${{ inputs.python_version }}-solaris${{ matrix.release }}-x86_64.zip
cd python-${{ matrix.distribution }}-${{ inputs.python_version }}-solaris${{ matrix.release }}-x86_64
chmod +x ./bin/python
./bin/python --version
./bin/python -m sysconfig
./bin/python ${{ github.workspace }}/scripts/test.py
./bin/pip3
if [[ "${{ inputs.run_tests }}" == "true" ]]; then
./bin/python -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata --timeout 60
fi
EOF
bash -e /tmp/test.sh
build_cosmo:
name: Cosmopolitan ${{ inputs.python_version }} (build)
if: ${{ contains(inputs.platforms, 'cosmo') }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Load cosmocc version
run: |
version=$(cat .github/cosmocc_version.txt)
echo "cosmocc_version=${version}" >> "$GITHUB_ENV"
- name: Set up cosmocc
uses: bjia56/[email protected]
with:
version: ${{ env.cosmocc_version }}
- name: Build
run: |
./scripts/build_cosmo.sh unknown ${{ inputs.python_version }}
- name: Interactive debugging
if: ${{ always() && inputs.debug_interactive }}
uses: fawazahmed0/action-debug-vscode@v3
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-cosmo-unknown-${{ inputs.python_version }}
path: ./python*.zip
- name: Upload artifacts
if: ${{ always() && inputs.debug }}
uses: actions/upload-artifact@v4
with:
name: build-python-cosmo-unknown-${{ inputs.python_version }}
path: ./*python*.tar.gz
test_cosmo:
name: Cosmopolitan ${{ inputs.python_version }} ${{ matrix.os }} ${{ matrix.arch }} (test)
needs: build_cosmo
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: macos-14
arch: arm64
os: MacOS
- runner: ubuntu-latest
arch: x86_64
os: Linux
- runner: windows-latest
arch: x86_64
os: Windows
- runner: ubuntu-latest
arch: x86_64
os: FreeBSD
- runner: ubuntu-latest
arch: x86_64
os: NetBSD
steps:
- name: Set up cosmocc
if: ${{ matrix.os == 'Linux' }}
uses: bjia56/[email protected]
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: python-cosmo-unknown-${{ inputs.python_version }}
path: ./python/
- name: Test python in clean environment
if: ${{ !contains(matrix.os, 'BSD') }}
shell: bash
run: |
if [[ "${{ matrix.os }}" == "Windows" ]]; then
7z.exe x python/python-${{ inputs.python_version }}-cosmo-unknown.zip
else
unzip python/python-${{ inputs.python_version }}-cosmo-unknown.zip
chmod +x python-${{ inputs.python_version }}-cosmo-unknown/bin/python.com
fi
cd python-${{ inputs.python_version }}-cosmo-unknown
./bin/python.com --version
./bin/python.com -m sysconfig
./bin/python.com ../scripts/test.py
./bin/pip3
if [[ "${{ inputs.run_tests }}" == "true" ]]; then
./bin/python.com -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata --timeout 60
fi
- name: Test in VM
if: ${{ matrix.os == 'FreeBSD' }}
uses: vmactions/freebsd-vm@v1
with:
envs: 'RUN_TESTS DEBUG_CI VERBOSE_CI PORTABLE_PYTHON_BUILDSYSTEM_BRANCH'
usesh: true
copyback: false
prepare: |
pkg install -y bash
run: |
cat > /tmp/test.sh <<EOF
unzip python/python-${{ inputs.python_version }}-cosmo-unknown.zip
cd python-${{ inputs.python_version }}-cosmo-unknown
chmod +x ./bin/python.com
./bin/python.com --version
./bin/python.com -m sysconfig
./bin/python.com ${{ github.workspace }}/scripts/test.py
./bin/pip3
if [[ "${{ inputs.run_tests }}" == "true" ]]; then
./bin/python.com -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata --timeout 60
fi
EOF
bash -e /tmp/test.sh
- name: Test in VM
if: ${{ matrix.os == 'NetBSD' }}
uses: vmactions/netbsd-vm@v1
with:
envs: 'RUN_TESTS DEBUG_CI VERBOSE_CI PORTABLE_PYTHON_BUILDSYSTEM_BRANCH'
usesh: true
copyback: false
run: |
cat > /tmp/test.sh <<EOF
unzip python/python-${{ inputs.python_version }}-cosmo-unknown.zip
cd python-${{ inputs.python_version }}-cosmo-unknown
chmod +x ./bin/python.com
./bin/python.com --version
./bin/python.com -m sysconfig
./bin/python.com ${{ github.workspace }}/scripts/test.py
./bin/pip3
if [[ "${{ inputs.run_tests }}" == "true" ]]; then
./bin/python.com -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata --timeout 60
fi
EOF
bash -e /tmp/test.sh