Skip to content

Support freethreading Python #669

Support freethreading Python

Support freethreading Python #669

Workflow file for this run

name: Wheel build
on:
release:
types: [created]
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
- cron: "42 3 * * 4"
push:
paths:
- .github/workflows/wheels.yml
- .github/workflows/cache_libs.yml
- requirements.txt
- pyproject.toml
- MANIFEST.in
- Makefile
- setup*
- build*
pull_request:
types: [opened, synchronize, reopened]
paths:
- .github/workflows/wheels.yml
- .github/workflows/cache_libs.yml
- requirements.txt
- pyproject.toml
- MANIFEST.in
- Makefile
- setup*
- build*
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
permissions: {}
jobs:
cache_libs:
uses: ./.github/workflows/cache_libs.yml
secrets: inherit
sdist:
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
- name: Set up Python
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: "3.x"
- name: Install lib dependencies
run: sudo apt-get update -y -q && sudo apt-get install -y -q "libxml2=2.9.14*" "libxml2-dev=2.9.14*" libxslt1.1 libxslt1-dev
- name: Install Python dependencies
run: python -m pip install -U pip setuptools && python -m pip install -U docutils pygments sphinx sphinx-rtd-theme -r requirements.txt
- name: Build docs and sdist
run: make html sdist
env: { STATIC_DEPS: false; CFLAGS="-Og" } # it's run-once, so build more quickly
- name: Upload sdist
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: sdist
path: dist/*.tar.gz
- name: Upload website
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: website
path: doc/html
generate-wheels-matrix:
# Create a matrix of all architectures & versions to build.
# This enables the next step to run cibuildwheel in parallel.
# From https://iscinumpy.dev/post/cibuildwheel-2-10-0/#only-210
name: Generate wheels matrix
runs-on: ubuntu-latest
outputs:
include: ${{ steps.set-matrix.outputs.include }}
steps:
- uses: actions/checkout@v6
- name: Install cibuildwheel
# Nb. keep cibuildwheel version pin consistent with job below
run: pipx install cibuildwheel==3.3.0
- id: set-matrix
run: |
MATRIX=$(
{
cibuildwheel --print-build-identifiers --platform linux \
| grep -v musllinux \
| jq -nRc '{"only": inputs, "os": "ubuntu-latest"}' \
| sed -e '/aarch64\|armv7l/s|ubuntu-latest|ubuntu-24.04-arm|' \
&& cibuildwheel --print-build-identifiers --platform macos \
| jq -nRc '{"only": inputs, "os": "macos-latest"}' \
&& cibuildwheel --print-build-identifiers --platform windows --archs AMD64,x86 \
| jq -nRc '{"only": inputs, "os": "windows-2022"}' \
&& cibuildwheel --print-build-identifiers --platform windows --archs ARM64 \
| jq -nRc '{"only": inputs, "os": "windows-11-arm"}'
} | jq -sc
)
echo "include=$MATRIX"
echo "include=$MATRIX" >> $GITHUB_OUTPUT
build_wheels:
name: Build for ${{ matrix.only }}
needs: [ cache_libs, generate-wheels-matrix ]
runs-on: ${{ matrix.os }}
env:
LXML_CSTD: "c11"
ZLIB_VERSION: ${{ needs.cache_libs.outputs.ZLIB_VERSION }}
LIBICONV_VERSION: ${{ needs.cache_libs.outputs.LIBICONV_VERSION }}
LIBXML2_VERSION: ${{ needs.cache_libs.outputs.LIBXML2_VERSION }}
LIBXSLT_VERSION: ${{ needs.cache_libs.outputs.LIBXSLT_VERSION }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.generate-wheels-matrix.outputs.include) }}
steps:
- name: Check out the repo
uses: actions/checkout@v6
- name: Cache [libs]
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
libs/*.xz
libs/*.gz
libs/*.zip
key: libs-${{ runner.os }}-${{ runner.arch }}-${{ env.LIBXML2_VERSION }}-${{ env.LIBXSLT_VERSION }}
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v3.3.0
with:
only: ${{ matrix.only }}
- name: Build old Linux wheels
if: >-
contains(matrix.only, '-manylinux_') &&
(contains(matrix.only, 'i686') || contains(matrix.only, 'x86_64') || contains(matrix.only, 'aarch64'))
uses: pypa/cibuildwheel@v3.3.0
env:
CIBW_MANYLINUX_i686_IMAGE: manylinux2014
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
with:
only: ${{ matrix.only }}
- name: Build faster Linux wheels
# also build wheels with the most recent manylinux images and gcc
if: runner.os == 'Linux' && (contains(matrix.only, 'x86_64') || contains(matrix.only, 'aarch64'))
uses: pypa/cibuildwheel@v3.3.0
env:
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
CIBW_MANYLINUX_PPC64LE_IMAGE: manylinux_2_28
CIBW_MANYLINUX_S390X_IMAGE: manylinux_2_28
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: manylinux_2_28
CIBW_MANYLINUX_PYPY_AARCH64_IMAGE: manylinux_2_28
CIBW_MUSLLINUX_X86_64_IMAGE: musllinux_1_2
CIBW_MUSLLINUX_AARCH64_IMAGE: musllinux_1_2
CIBW_MUSLLINUX_PPC64LE_IMAGE: musllinux_1_2
CIBW_MUSLLINUX_S390X_IMAGE: musllinux_1_2
with:
only: ${{ matrix.only }}
- name: Upload wheels
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
path: ./wheelhouse/*.whl
name: lxml-wheel-${{ matrix.only }}
build_abi3_wheels:
name: Build abi3 wheels on ${{ matrix.os == 'ubuntu-24.04' && 'ubuntu-qemu' || matrix.os }}
needs: [ cache_libs ]
runs-on: ${{ matrix.os }}
# The Limited API is not currently capable enough to support lxml's proxy back-references.
if: false
env:
ZLIB_VERSION: ${{ needs.cache_libs.outputs.ZLIB_VERSION }}
LIBICONV_VERSION: ${{ needs.cache_libs.outputs.LIBICONV_VERSION }}
LIBXML2_VERSION: ${{ needs.cache_libs.outputs.LIBXML2_VERSION }}
LIBXSLT_VERSION: ${{ needs.cache_libs.outputs.LIBXSLT_VERSION }}
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu-latest'
- 'ubuntu-24.04' # for emulated builds
- 'ubuntu-24.04-arm'
- 'windows-latest'
- 'windows-11-arm'
- 'macos-latest'
steps:
- name: Check out the repo
uses: actions/checkout@v6
- name: Cache [libs]
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
libs/*.xz
libs/*.gz
libs/*.zip
key: libs-${{ runner.os }}-${{ runner.arch }}-${{ env.LIBXML2_VERSION }}-${{ env.LIBXSLT_VERSION }}
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Build ABI3 wheels
uses: pypa/cibuildwheel@v3.3.0
env:
# Smaller set of platforms that we only provide Stable ABI wheels for
CIBW_BUILD: |
${{
matrix.os == 'ubuntu-latest' && 'cp312-*linux_i686 cp312-musllinux_x86_64' ||
matrix.os == 'ubuntu-24.04-arm' && 'cp312-*armv7l cp312-musllinux_aarch64' ||
matrix.os == 'ubuntu-24.04' && 'cp312-manylinux_ppc64le cp312-manylinux_riscv64' ||
matrix.os == 'windows-latest' && 'cp312-*win32' ||
matrix.os == 'windows-11-arm' && 'cp312-*win_arm64' ||
matrix.os == 'macos-latest' && 'cp312-*macosx_x86_64' ||
'' }}
- name: Upload wheels
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
path: ./wheelhouse/*.whl
name: lxml-wheel-abi3-${{ matrix.os }}
upload_release_assets:
name: Upload Release Assets
#needs: [ sdist, build_wheels, build_abi3_wheels ]
needs: [ sdist, build_wheels ]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
path: ./release_upload
merge-multiple: true
- name: List downloaded artifacts
run: ls -la ./release_upload
- name: Upload wheels
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
path: ./release_upload/*.whl
name: all_wheels
- name: Release
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag'
with:
files: |
./release_upload/*.whl
./release_upload/*.tar.gz