Support and build wheels for new python versions #258
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: Python wheels (& publish) | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
release: | |
types: [created] | |
jobs: | |
build_llvm_win: | |
name: Build LLVM release for Windows | |
runs-on: windows-latest | |
steps: | |
- name: Cache LLVM | |
id: cache-llvm | |
uses: actions/cache@v2 | |
with: | |
path: llvm/install | |
# TODO: would be really better to add the hash of the LLVM commit cloned | |
key: ${{ runner.os }}-llvm-release-13-msvc | |
- name: Get LLVM | |
if: steps.cache-llvm.outputs.cache-hit != 'true' | |
uses: actions/checkout@v2 | |
with: | |
repository: 'aguinet/llvm-project' | |
ref: 'release/13.x' | |
path: 'llvm' | |
- uses: ilammy/msvc-dev-cmd@v1 | |
if: steps.cache-llvm.outputs.cache-hit != 'true' | |
- name: Build LLVM | |
if: steps.cache-llvm.outputs.cache-hit != 'true' | |
run: | | |
choco install ninja | |
mkdir llvm/build | |
mkdir llvm/install | |
cd llvm/build | |
cmake ../llvm -DLLVM_BUILD_EXAMPLES=OFF -DCLANG_ENABLE_ARCMT=OFF -DCLANG_ENABLE_STATIC_ANALYZER=OFF -DLLVM_BUILD_TOOLS=ON -DCLANG_BUILD_TOOLS=OFF -DLLVM_INSTALL_UTILS=ON -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS=clang -DLLVM_ENABLE_BINDINGS=OFF -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PWD/../install" -DLLVM_ENABLE_THREADS=OFF -DLLVM_ENABLE_ZLIB=OFF -G Ninja | |
ninja install | |
build_llvm_manylinux: | |
name: Build LLVM release for Linux | |
strategy: | |
matrix: | |
include: | |
- image: "manylinux_2_28_x86_64" | |
runs: ubuntu-24.04 | |
- image: "manylinux_2_28_aarch64" | |
runs: ubuntu-24.04-arm | |
runs-on: ${{ matrix.runs }} | |
steps: | |
- name: Cache LLVM | |
id: cache-llvm | |
uses: actions/cache@v2 | |
with: | |
path: llvm/install | |
key: ${{ runner.os }}-llvm-release-13-${{ matrix.image }}-00 | |
- uses: actions/checkout@v2 | |
if: steps.cache-llvm.outputs.cache-hit != 'true' | |
- name: Get LLVM | |
if: steps.cache-llvm.outputs.cache-hit != 'true' | |
uses: actions/checkout@v2 | |
with: | |
repository: 'aguinet/llvm-project' | |
ref: 'release/13.x' | |
path: 'llvm' | |
- name: Build LLVM | |
if: steps.cache-llvm.outputs.cache-hit != 'true' | |
run: | | |
docker run -v $GITHUB_WORKSPACE:/pwd "quay.io/pypa/${{ matrix.image }}" /bin/bash /pwd/ci/build_llvm_manylinux.sh /pwd/llvm | |
build_manylinux: | |
needs: build_llvm_manylinux | |
# Split into multiple jobs to speed up the process. Let's compile two | |
# Python versions per job. | |
strategy: | |
matrix: | |
tag: | |
- image: "manylinux_2_28_x86_64" | |
runs: ubuntu-24.04 | |
- image: "manylinux_2_28_aarch64" | |
runs: ubuntu-24.04-arm | |
py_vers: | |
- "cp38-cp38" | |
- "cp39-cp39" | |
- "cp310-cp310" | |
- "cp311-cp311" | |
- "cp312-cp312" | |
- "cp313-cp313" | |
env: | |
PY_VERS: ${{ matrix.py_vers }} | |
runs-on: ${{ matrix.tag.runs }} | |
container: | |
image: quay.io/pypa/${{ matrix.tag.image }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Cache LLVM | |
id: cache-llvm | |
uses: actions/cache@v2 | |
with: | |
path: llvm/install | |
key: Linux-llvm-release-13-${{ matrix.tag.image }}-00 | |
- name: Build wheels & tests | |
run: | | |
/bin/bash ./ci/build_wheels_manylinux.sh "$PWD" "${PWD}/llvm/install" $PY_VERS | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: pydffi-wheels-linux-${{ matrix.tag.image }}-${{ matrix.py_vers }} | |
path: bindings/python/wheelhouse/ | |
build_osxwin: | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] | |
os: | |
#- macos-latest | |
- windows-latest | |
runs-on: ${{ matrix.os }} | |
needs: build_llvm_win | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: ilammy/msvc-dev-cmd@v1 | |
if: runner.os == 'Windows' | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache LLVM | |
if: runner.os == 'Windows' | |
id: cache-llvm | |
uses: actions/cache@v2 | |
with: | |
path: llvm/install | |
key: ${{ runner.os }}-llvm-release-13-msvc | |
- name: Python dependencies | |
run: | | |
pip install wheel setuptools | |
- name: Install Windows dependencies | |
run: | | |
choco install --accept-license ninja | |
echo LLVM_CONFIG=%GITHUB_WORKSPACE%/llvm/install/bin/llvm-config.exe >> %GITHUB_ENV% | |
echo MSSdk=1 >> %GITHUB_ENV% | |
echo DISTUTILS_USE_SDK=1 >> %GITHUB_ENV% | |
if: runner.os == 'Windows' | |
shell: cmd | |
- name: Setup Miniconda | |
uses: conda-incubator/setup-miniconda@v3.1.1 | |
if: runner.os == 'macOS' | |
- name: Install OSX dependencies | |
run: | | |
brew install cmake ninja | |
sudo conda install -c conda-forge llvmdev==13.0.0 clangdev==13.0.0 | |
echo "LLVM_CONFIG=$CONDA/bin/llvm-config" >> $GITHUB_ENV | |
if: runner.os == 'macOS' | |
- name: Build wheel | |
working-directory: bindings/python | |
run: | | |
python ./setup.py bdist_wheel | |
- name: Install Windows | |
if: runner.os == 'Windows' | |
working-directory: bindings/python | |
run: | | |
pip install (get-item ./dist/*.whl).FullName | |
- name: Install OSX | |
if: runner.os == 'macOS' | |
working-directory: bindings/python | |
run: | | |
pip install dist/*.whl | |
- name: Tests | |
run: | | |
# Do not set bindings/python as the working directory to make sure we | |
# use the generated wheel for tests. | |
pip install six purectypes==0.2 | |
python -m unittest discover bindings/python/tests | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: pydffi-wheels-${{ matrix.os }}-${{ matrix.python-version }} | |
path: bindings/python/dist/ | |
publish: | |
if: github.event.release | |
runs-on: ubuntu-latest | |
needs: [build_manylinux, build_osxwin] | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v1 | |
with: | |
python-version: 3.10 | |
- name: Install dependencies | |
run: | | |
pip install twine | |
- uses: actions/download-artifact@v1 | |
with: | |
name: pydffi-wheels | |
path: wheelhouse | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
twine upload wheelhouse/*.whl |