| 1 |
name: Wheel build |
| 2 |
|
| 3 |
on: |
| 4 |
release: |
| 5 |
types: [created] |
| 6 |
schedule: |
| 7 |
# ┌───────────── minute (0 - 59) |
| 8 |
# │ ┌───────────── hour (0 - 23) |
| 9 |
# │ │ ┌───────────── day of the month (1 - 31) |
| 10 |
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) |
| 11 |
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) |
| 12 |
# │ │ │ │ │ |
| 13 |
- cron: "42 3 * * 4" |
| 14 |
push: |
| 15 |
paths: |
| 16 |
- .github/workflows/wheels.yml |
| 17 |
- requirements.txt |
| 18 |
- pyproject.toml |
| 19 |
- MANIFEST.in |
| 20 |
- Makefile |
| 21 |
- setup* |
| 22 |
- build* |
| 23 |
pull_request: |
| 24 |
types: [opened, synchronize, reopened] |
| 25 |
paths: |
| 26 |
- .github/workflows/wheels.yml |
| 27 |
- requirements.txt |
| 28 |
- pyproject.toml |
| 29 |
- MANIFEST.in |
| 30 |
- Makefile |
| 31 |
- setup* |
| 32 |
- build* |
| 33 |
workflow_dispatch: |
| 34 |
|
| 35 |
concurrency: |
| 36 |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} |
| 37 |
cancel-in-progress: true |
| 38 |
|
| 39 |
permissions: {} |
| 40 |
|
| 41 |
env: |
| 42 |
ZLIB_VERSION: "1.3.2" |
| 43 |
LIBICONV_VERSION: "1.18" |
| 44 |
LIBXML2_VERSION: "2.14.6" |
| 45 |
LIBXSLT_VERSION: "1.1.43" |
| 46 |
|
| 47 |
|
| 48 |
jobs: |
| 49 |
|
| 50 |
cache_libs: |
| 51 |
strategy: |
| 52 |
fail-fast: false |
| 53 |
matrix: |
| 54 |
os: |
| 55 |
- "ubuntu-22.04" |
| 56 |
- "ubuntu-22.04-arm" |
| 57 |
- "macos-latest" |
| 58 |
- "windows-2022" # win32 |
| 59 |
- "windows-latest" # win_amd64 |
| 60 |
- "windows-11-arm" |
| 61 |
|
| 62 |
runs-on: ${{ matrix.os }} |
| 63 |
|
| 64 |
steps: |
| 65 |
- name: Check out the repo |
| 66 |
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 67 |
|
| 68 |
- name: Cache [libs] |
| 69 |
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 70 |
with: |
| 71 |
path: | |
| 72 |
libs/*.xz |
| 73 |
libs/*.gz |
| 74 |
libs/*.zip |
| 75 |
key: libs-${{ runner.os }}-${{ matrix.os == 'windows-2022' && 'i686' || runner.arch }}-${{ env.LIBXML2_VERSION }}-${{ env.LIBXSLT_VERSION }}-${{ env.LIBICONV_VERSION }}-${{ env.ZLIB_VERSION }} |
| 76 |
|
| 77 |
- name: Download latest libraries |
| 78 |
env: |
| 79 |
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 80 |
run: python3 buildlibxml.py --download-only ${{ matrix.os == 'windows-2022' && 'win32' || '' }} |
| 81 |
|
| 82 |
sdist: |
| 83 |
runs-on: ubuntu-24.04 |
| 84 |
|
| 85 |
permissions: |
| 86 |
contents: write |
| 87 |
|
| 88 |
steps: |
| 89 |
- name: Check out the repo |
| 90 |
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 91 |
|
| 92 |
- name: Set up Python |
| 93 |
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 |
| 94 |
with: |
| 95 |
python-version: "3.x" |
| 96 |
|
| 97 |
- name: Install lib dependencies |
| 98 |
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 |
| 99 |
|
| 100 |
- name: Install Python dependencies |
| 101 |
run: python -m pip install -U pip setuptools && python -m pip install -U docutils pygments sphinx sphinx-rtd-theme -r requirements.txt |
| 102 |
|
| 103 |
- name: Build docs and sdist |
| 104 |
run: make html sdist |
| 105 |
env: { STATIC_DEPS: false; CFLAGS="-Og" } # it's run-once, so build more quickly |
| 106 |
|
| 107 |
- name: Upload sdist |
| 108 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 109 |
with: |
| 110 |
name: sdist |
| 111 |
path: dist/*.tar.gz |
| 112 |
|
| 113 |
- name: Upload website |
| 114 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 115 |
with: |
| 116 |
name: website |
| 117 |
path: doc/html |
| 118 |
|
| 119 |
generate-wheels-matrix: |
| 120 |
# Create a matrix of all architectures & versions to build. |
| 121 |
# This enables the next step to run cibuildwheel in parallel. |
| 122 |
# From https://iscinumpy.dev/post/cibuildwheel-2-10-0/#only-210 |
| 123 |
name: Generate wheels matrix |
| 124 |
runs-on: ubuntu-24.04 |
| 125 |
outputs: |
| 126 |
include: ${{ steps.set-matrix.outputs.include }} |
| 127 |
steps: |
| 128 |
- name: Check out the repo |
| 129 |
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 130 |
|
| 131 |
- name: Install cibuildwheel |
| 132 |
# Nb. keep cibuildwheel version pin consistent with job below |
| 133 |
run: pipx install cibuildwheel==4.2.0 |
| 134 |
|
| 135 |
- id: set-matrix |
| 136 |
run: | |
| 137 |
MATRIX=$( |
| 138 |
{ |
| 139 |
cibuildwheel --print-build-identifiers --platform linux \ |
| 140 |
| jq -nRc '{"only": inputs, "os": "ubuntu-22.04"}' \ |
| 141 |
| sed -e '/aarch64\|armv7l/s|ubuntu-22.04|ubuntu-22.04-arm|' \ |
| 142 |
&& cibuildwheel --print-build-identifiers --platform macos \ |
| 143 |
| jq -nRc '{"only": inputs, "os": "macos-latest"}' \ |
| 144 |
&& cibuildwheel --print-build-identifiers --platform windows \ |
| 145 |
| jq -nRc '{"only": inputs, "os": "windows-2022"}' \ |
| 146 |
&& cibuildwheel --print-build-identifiers --platform windows --archs ARM64 \ |
| 147 |
| jq -nRc '{"only": inputs, "os": "windows-11-arm"}' |
| 148 |
} | jq -sc |
| 149 |
) |
| 150 |
echo "include=$MATRIX" |
| 151 |
echo "include=$MATRIX" >> $GITHUB_OUTPUT |
| 152 |
|
| 153 |
build_wheels: |
| 154 |
name: Build for ${{ matrix.only }} |
| 155 |
needs: [ cache_libs, generate-wheels-matrix ] |
| 156 |
runs-on: ${{ matrix.os }} |
| 157 |
|
| 158 |
strategy: |
| 159 |
fail-fast: false |
| 160 |
matrix: |
| 161 |
include: ${{ fromJson(needs.generate-wheels-matrix.outputs.include) }} |
| 162 |
|
| 163 |
steps: |
| 164 |
- name: Check out the repo |
| 165 |
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 166 |
|
| 167 |
- name: Cache [libs] |
| 168 |
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 169 |
with: |
| 170 |
path: | |
| 171 |
libs/*.xz |
| 172 |
libs/*.gz |
| 173 |
libs/*.zip |
| 174 |
key: libs-${{ runner.os }}-${{ contains(matrix.only, 'win32') && 'i686' || runner.arch }}-${{ env.LIBXML2_VERSION }}-${{ env.LIBXSLT_VERSION }}-${{ env.LIBICONV_VERSION }}-${{ env.ZLIB_VERSION }} |
| 175 |
|
| 176 |
- name: Set up QEMU |
| 177 |
if: runner.os == 'Linux' |
| 178 |
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 |
| 179 |
with: |
| 180 |
platforms: all |
| 181 |
|
| 182 |
- name: Build wheels |
| 183 |
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 184 |
env: |
| 185 |
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 186 |
with: |
| 187 |
only: ${{ matrix.only }} |
| 188 |
|
| 189 |
- name: Build Py3.8 wheels |
| 190 |
if: startsWith(matrix.only, 'cp39-macos') || matrix.only == 'cp39-musllinux_x86_64' || matrix.only == 'cp39-win_amd64' |
| 191 |
# Keep cibuildwheel at 3.4.1 here. |
| 192 |
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1 |
| 193 |
env: |
| 194 |
CIBW_BUILD: "cp38*" |
| 195 |
|
| 196 |
- name: Build old Linux wheels |
| 197 |
if: matrix.only == 'cp39-manylinux_x86_64' || matrix.only == 'cp39-manylinux_aarch64' |
| 198 |
# Keep cibuildwheel at 3.4.1 here. |
| 199 |
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1 |
| 200 |
env: |
| 201 |
CIBW_BUILD: "${{ contains(matrix.only, 'x86_64') && '*-manylinux_i686 *-manylinux_x86_64' || '*-manylinux_aarch64' }}" |
| 202 |
CIBW_MANYLINUX_i686_IMAGE: manylinux2014 |
| 203 |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 |
| 204 |
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014 |
| 205 |
|
| 206 |
- name: Upload wheels |
| 207 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 208 |
with: |
| 209 |
path: ./wheelhouse/*.whl |
| 210 |
name: lxml-wheel-${{ matrix.only }} |
| 211 |
|
| 212 |
upload_release_assets: |
| 213 |
name: Upload Release Assets |
| 214 |
needs: [ sdist, build_wheels ] |
| 215 |
runs-on: ubuntu-latest |
| 216 |
|
| 217 |
permissions: |
| 218 |
contents: write |
| 219 |
|
| 220 |
defaults: |
| 221 |
run: |
| 222 |
shell: bash |
| 223 |
|
| 224 |
steps: |
| 225 |
- name: Download artifacts |
| 226 |
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 227 |
with: |
| 228 |
path: ./release_upload |
| 229 |
pattern: lxml-wheel-* |
| 230 |
merge-multiple: true |
| 231 |
|
| 232 |
- name: Upload wheels |
| 233 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 234 |
with: |
| 235 |
path: ./release_upload/*.whl |
| 236 |
name: all_wheels |
| 237 |
|
| 238 |
- name: List downloaded artifacts |
| 239 |
run: | |
| 240 |
cd ./release_upload |
| 241 |
ls -la |
| 242 |
echo; echo "Wheels built: "; ls *.whl | wc -l |
| 243 |
echo; echo "Validating wheel success…" |
| 244 |
RESULT_CODE=0 |
| 245 |
for PYVERSION in 38 39 310 311 312 313 314 315 ; do \ |
| 246 |
for WHEEL_ARCH in "win32" "win_amd64" "win_arm64" "manylinux*i686" "manylinux*x86_64" "musllinux*x86_64" "macosx"; do \ |
| 247 |
[[ "${PYVERSION}-${WHEEL_ARCH}" == "315"*"i686" ]] && continue; \ |
| 248 |
[[ "${PYVERSION}-${WHEEL_ARCH}" == "38-win_arm64" ]] && continue; \ |
| 249 |
ls *-cp${PYVERSION}-*${WHEEL_ARCH}*.whl >/dev/null 2>&1 || { echo "MISSING WHEEL: cp${PYVERSION}-${WHEEL_ARCH}" ; RESULT_CODE=1; } ; \ |
| 250 |
done; \ |
| 251 |
done; \ |
| 252 |
exit ${RESULT_CODE} |
| 253 |
|
| 254 |
- name: Release |
| 255 |
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1 |
| 256 |
if: github.ref_type == 'tag' |
| 257 |
with: |
| 258 |
files: | |
| 259 |
./release_upload/*.whl |
| 260 |
./release_upload/*.tar.gz |