Files
sqlalchemy/.github/workflows/create-wheels.yaml
T
Federico Caselli 1f704fb682 use arm runnes on linux instead of emulation
Fixes: #12249
Change-Id: I4c56a10d09716aa5e1fc4a1688dbfdf7cfcfd2fb
2025-01-22 22:11:07 +01:00

126 lines
4.1 KiB
YAML

name: Create wheel
on:
# run when a release has been created
release:
types: [created]
# push:
# branches:
# - "go_wheel_*"
# env:
# # comment TWINE_REPOSITORY_URL to use the real pypi. NOTE: change also the secret used in TWINE_PASSWORD
# TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
jobs:
build_wheels:
name: ${{ matrix.wheel_mode }} wheels ${{ matrix.python }} on ${{ matrix.os }} ${{ matrix.os == 'ubuntu-22.04' && matrix.linux_archs || '' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# emulated wheels on linux take too much time, split wheels into multiple runs
python:
- "cp39-*"
- "cp310-* cp311-*"
- "cp312-* cp313-*"
wheel_mode:
- compiled
os:
- "windows-2022"
# TODO: macos-14 uses arm macs (only python 3.10+) - make arm wheel on it
- "macos-13"
- "ubuntu-22.04"
- "ubuntu-22.04-arm"
linux_archs:
# this is only meaningful on linux. windows and macos ignore exclude all but one arch
- "aarch64"
- "x86_64"
include:
# create pure python build
- os: ubuntu-22.04
wheel_mode: pure-python
python: "cp-312*"
exclude:
- os: "windows-2022"
linux_archs: "aarch64"
- os: "macos-13"
linux_archs: "aarch64"
- os: "ubuntu-22.04"
linux_archs: "aarch64"
- os: "ubuntu-22.04-arm"
linux_archs: "x86_64"
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Remove tag-build from pyproject.toml
# sqlalchemy has `tag-build` set to `dev` in pyproject.toml. It needs to be removed before creating the wheel
# otherwise it gets tagged with `dev0`
shell: pwsh
# This is equivalent to the sed commands:
# `sed -i '/tag-build="dev"/d' pyproject.toml`
# `sed -i '/tag-build = "dev"/d' pyproject.toml`
# `-replace` uses a regexp match
run: |
(get-content pyproject.toml) | %{$_ -replace 'tag-build.?=.?"dev"',""} | set-content pyproject.toml
# See details at https://cibuildwheel.readthedocs.io/en/stable/faq/#emulation
# no longer needed since arm runners are now available
# - name: Set up QEMU on linux
# if: ${{ runner.os == 'Linux' }}
# uses: docker/setup-qemu-action@v3
# with:
# platforms: all
- name: Build compiled wheels
if: ${{ matrix.wheel_mode == 'compiled' }}
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_ARCHS_LINUX: ${{ matrix.linux_archs }}
CIBW_BUILD: ${{ matrix.python }}
# setting it here does not work on linux
# PYTHONNOUSERSITE: "1"
- name: Set up Python for twine and pure-python wheel
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build pure-python wheel
if: ${{ matrix.wheel_mode == 'pure-python' && runner.os == 'Linux' }}
run: |
python -m pip install --upgrade pip
pip --version
pip install build
pip list
DISABLE_SQLALCHEMY_CEXT=y python -m build --wheel --outdir ./wheelhouse
# - uses: actions/upload-artifact@v3
# with:
# path: ./wheelhouse/*.whl
- name: Upload wheels to release
# upload the generated wheels to the github release
uses: sqlalchemyorg/upload-release-assets@sa
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
files: './wheelhouse/*.whl'
- name: Publish wheel
# the action https://github.com/marketplace/actions/pypi-publish runs only on linux and we cannot specify
# additional options
env:
TWINE_USERNAME: __token__
# replace TWINE_PASSWORD with token for real pypi
# TWINE_PASSWORD: ${{ secrets.test_pypi_token }}
TWINE_PASSWORD: ${{ secrets.pypi_token }}
run: |
pip install -U twine
twine upload --skip-existing ./wheelhouse/*