Build CPython #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Python | |
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,macos,windows" | |
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 | |
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 }} | |
image_map: '{"x86_64": "amd64/centos:7", "i386": "i386/centos:7", "aarch64": "arm64v8/centos:7", "arm": "arm32v7/debian:bullseye", "riscv64": "riscv64/debian:sid"}' | |
jobs: | |
build_linux: | |
name: Linux ${{ inputs.python_version }} ${{ matrix.arch }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [x86_64, i386, aarch64, arm, riscv64] | |
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' || '' }} | |
steps: | |
- name: Parse image | |
if: ${{ matrix.arch }} | |
id: parse_image | |
run: | | |
IMAGE=$(echo ${{ toJSON(env.image_map) }} | jq -r '.["${{ matrix.arch }}"]') | |
echo "image=$IMAGE" >> "$GITHUB_OUTPUT" | |
- name: Set up zig | |
if: ${{ matrix.arch }} | |
uses: goto-bus-stop/setup-zig@v2 | |
with: | |
version: 0.12.0-dev.3097+5c0766b6c | |
- name: Checkout | |
if: ${{ matrix.arch }} | |
uses: actions/checkout@v4 | |
- name: Build | |
if: ${{ matrix.arch }} | |
run: | | |
./scripts/build_linux_zig.sh ${{ matrix.arch }} ${{ inputs.python_version }} | |
- name: Interactive debugging | |
if: ${{ always() && matrix.arch && inputs.debug_interactive }} | |
uses: fawazahmed0/action-debug@v2 | |
- name: Upload artifacts | |
if: ${{ matrix.arch }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-linux-${{ matrix.arch }}-${{ inputs.python_version }} | |
path: ./python*.zip | |
- name: Upload artifacts | |
if: ${{ always() && matrix.arch && inputs.debug }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-python-linux-${{ matrix.arch }}-${{ inputs.python_version }} | |
path: ./*python*.tar.gz | |
- name: Test python in clean environment | |
if: ${{ matrix.arch }} | |
uses: addnab/docker-run-action@v3 | |
with: | |
image: ${{ steps.parse_image.outputs.image }} | |
options: -v ${{ github.workspace }}:/work --workdir /tmp | |
shell: bash | |
run: | | |
set -e | |
uname -a | |
if [ "${{ matrix.arch }}" == "arm" ] || [ "${{ matrix.arch }}" == "riscv64" ]; then | |
apt update | |
apt -y install unzip | |
else | |
yum -y install unzip | |
fi | |
cp /work/python*.zip . | |
unzip ./python*.zip | |
cd python-${{ inputs.python_version }}-linux-${{ matrix.arch }} | |
chmod +x ./bin/python | |
ldd -v -r ./bin/python | |
./bin/python --version | |
./bin/python -m sysconfig | |
./bin/python -c "import ssl; import urllib.request; urllib.request.urlopen('https://github.com')" | |
if [[ "${{ inputs.run_tests }}" == "true" ]]; then | |
./bin/python -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata | |
fi | |
build_windows: | |
name: Windows ${{ inputs.python_version }} x86_64 (build) | |
if: ${{ contains(inputs.platforms, 'windows') }} | |
runs-on: windows-latest | |
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 }} | |
- name: Interactive debugging | |
uses: fawazahmed0/action-debug@v2 | |
if: ${{ always() && inputs.debug_interactive }} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-windows-x86_64-${{ 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-${{ inputs.python_version }} | |
path: ./*python*.tar.gz | |
test_windows: | |
name: Windows ${{ inputs.python_version }} x86_64 (test) | |
needs: build_windows | |
runs-on: windows-latest | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-windows-x86_64-${{ inputs.python_version }} | |
path: ./python/ | |
- name: Test python in clean environment | |
shell: bash | |
run: | | |
7z.exe x python/python-${{ inputs.python_version }}-windows-x86_64.zip | |
cd python-${{ inputs.python_version }}-windows-x86_64 | |
./bin/python --version | |
./bin/python -m sysconfig | |
./bin/python -c "import ssl; import urllib.request; urllib.request.urlopen('https://github.com')" | |
if [[ "${{ inputs.run_tests }}" == "true" ]]; then | |
./bin/python -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata | |
fi | |
build_macos: | |
name: MacOS ${{ inputs.python_version }} universal2 (build) | |
if: ${{ contains(inputs.platforms, 'macos') }} | |
runs-on: macos-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install coreutils | |
run: brew install coreutils | |
- name: Install gpatch | |
run: | | |
brew install gpatch | |
- name: Build | |
run: | | |
set -ex | |
./scripts/build_macos.sh universal2 ${{ inputs.python_version }} | |
- name: Interactive debugging | |
uses: fawazahmed0/action-debug@v2 | |
if: ${{ always() && inputs.debug_interactive }} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-darwin-universal2-${{ inputs.python_version }} | |
path: ./python*.zip | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
if: ${{ always() && inputs.debug }} | |
with: | |
name: build-python-darwin-universal2-${{ inputs.python_version }} | |
path: ./*python*.tar.gz | |
test_macos: | |
name: MacOS ${{ inputs.python_version }} ${{ matrix.arch }} (test) | |
needs: build_macos | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ macos-11, macos-14 ] | |
include: | |
- os: macos-11 | |
arch: x86_64 | |
- os: macos-14 | |
arch: arm64 | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-darwin-universal2-${{ inputs.python_version }} | |
path: ./python/ | |
- name: Test python in clean environment | |
shell: bash | |
run: | | |
unzip python/python-${{ inputs.python_version }}-darwin-universal2.zip | |
cd python-${{ inputs.python_version }}-darwin-universal2 | |
chmod +x ./bin/python | |
./bin/python --version | |
./bin/python -m sysconfig | |
./bin/python -c "import ssl; import urllib.request; urllib.request.urlopen('https://github.com')" | |
if [[ "${{ inputs.run_tests }}" == "true" ]]; then | |
./bin/python -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata | |
fi |