Skip to content

ci: use Python 3.11.2 for Webassembly build #1434

ci: use Python 3.11.2 for Webassembly build

ci: use Python 3.11.2 for Webassembly build #1434

Workflow file for this run

name: Build and test, upload to PyPI on release
on: [push, pull_request]
env:
CIBW_ENVIRONMENT_PASS_LINUX: PYTEST_TIMEOUT
CIBW_TEST_COMMAND: "cd {project} && pip install --prefer-binary '.[test]' && python -m pytest -v tests"
CIBW_SKIP: "cp36-* cp37-* pp37-*"
PYTEST_TIMEOUT: 60
MACOSX_DEPLOYMENT_TARGET: "10.9"
jobs:
build_wheel_linux:
name: Build wheels on Linux (${{ matrix.wheel_arch }})
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
wheel_arch: [x86_64, i686]
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.8'
- name: Build wheels (manylinux)
uses: pypa/[email protected]
env:
CIBW_BEFORE_BUILD: "yum install -y flex bison libxml2-devel zlib-devel cairo-devel && pip install -U cmake pip wheel && python setup.py build_c_core"
CIBW_BUILD: "*-manylinux_${{ matrix.wheel_arch }}"
# Skip tests for Python 3.10 onwards because SciPy does not have
# 32-bit wheels for Linux
CIBW_TEST_SKIP: "cp310-manylinux_i686 cp311-manylinux_i686 cp312-manylinux_i686"
- name: Build wheels (musllinux)
uses: pypa/[email protected]
env:
CIBW_BEFORE_BUILD: "apk add flex bison libxml2-dev zlib-dev cairo-dev && pip install -U cmake pip wheel && python setup.py build_c_core"
CIBW_BUILD: "*-musllinux_${{ matrix.wheel_arch }}"
CIBW_TEST_COMMAND: "cd {project} && pip install --prefer-binary '.[test-musl]' && python -m pytest -v tests"
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
build_wheel_linux_aarch64_manylinux:
name: Build wheels on Linux (aarch64/manylinux)
runs-on: ubuntu-20.04
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
- name: Build wheels (manylinux)
uses: pypa/[email protected]
env:
CIBW_BEFORE_BUILD: "yum install -y flex bison libxml2-devel zlib-devel cairo-devel && pip install -U cmake pip wheel && python setup.py build_c_core"
CIBW_ARCHS_LINUX: aarch64
CIBW_BUILD: "*-manylinux_aarch64"
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
build_wheel_linux_aarch64_musllinux:
name: Build wheels on Linux (aarch64/musllinux)
runs-on: ubuntu-20.04
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
- name: Build wheels (musllinux)
uses: pypa/[email protected]
env:
CIBW_BEFORE_BUILD: "apk add flex bison libxml2-dev zlib-dev cairo-dev && pip install -U cmake pip wheel && python setup.py build_c_core"
CIBW_ARCHS_LINUX: aarch64
CIBW_BUILD: "*-musllinux_aarch64"
CIBW_TEST_COMMAND: "cd {project} && pip install --prefer-binary '.[test-musl]' && python -m pytest -v tests"
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
build_wheel_macos:
name: Build wheels on macOS (${{ matrix.wheel_arch }})
runs-on: macos-latest
env:
LLVM_VERSION: "14.0.5"
strategy:
matrix:
include:
- cmake_arch: x86_64
wheel_arch: x86_64
- cmake_arch: arm64
cmake_extra_args: -DF2C_EXTERNAL_ARITH_HEADER=../../../etc/arith_apple_m1.h -DIEEE754_DOUBLE_ENDIANNESS_MATCHES=ON
wheel_arch: arm64
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Cache installed C core
id: cache-c-core
uses: actions/cache@v3
with:
path: vendor/install
key: C-core-cache-${{ runner.os }}-${{ matrix.cmake_arch }}-llvm${{ env.LLVM_VERSION }}-${{ hashFiles('.git/modules/**/HEAD') }}
- name: Cache C core dependencies
id: cache-c-deps
uses: actions/cache@v3
with:
path: ~/local
key: deps-cache-v2-${{ runner.os }}-${{ matrix.cmake_arch }}-llvm${{ env.LLVM_VERSION }}
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.8'
- name: Install OS dependencies
if: steps.cache-c-core.outputs.cache-hit != 'true' || steps.cache-c-deps.outputs.cache-hit != 'true' # Only needed when building the C core or libomp
run:
brew install ninja autoconf automake libtool cmake
- name: Install OpenMP library
if: steps.cache-c-deps.outputs.cache-hit != 'true'
run: |
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/openmp-$LLVM_VERSION.src.tar.xz
tar xf openmp-$LLVM_VERSION.src.tar.xz
cd openmp-$LLVM_VERSION.src
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/local -DLIBOMP_ENABLE_SHARED=OFF -DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_arch }}
cmake --build .
cmake --install .
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_MACOS: "${{ matrix.wheel_arch }}"
CIBW_BEFORE_BUILD: "python setup.py build_c_core"
CIBW_ENVIRONMENT: "LDFLAGS=-L$HOME/local/lib"
IGRAPH_CMAKE_EXTRA_ARGS: -DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_arch }} ${{ matrix.cmake_extra_args }} -DCMAKE_PREFIX_PATH=$HOME/local
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
build_wheel_wasm:
name: Build wheels for WebAssembly
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.11.2'
- uses: mymindstorm/setup-emsdk@v12
with:
version: '3.1.45'
actions-cache-folder: 'emsdk-cache'
- name: Build wheel
run: |
pip install pyodide-build==0.24.1
pyodide build
- uses: actions/upload-artifact@v3
with:
path: ./dist/*.whl
build_wheel_win:
name: Build wheels on Windows (${{ matrix.cmake_arch }})
runs-on: windows-2019
strategy:
matrix:
include:
- cmake_arch: Win32
wheel_arch: win32
vcpkg_arch: x86
- cmake_arch: x64
wheel_arch: win_amd64
vcpkg_arch: x64
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.8'
- name: Cache installed C core
id: cache-c-core
uses: actions/cache@v3
with:
path: vendor/install
key: C-core-cache-${{ runner.os }}-${{ matrix.cmake_arch }}-${{ hashFiles('.git/modules/**/HEAD') }}
- name: Cache VCPKG
uses: actions/cache@v3
with:
path: C:/vcpkg/installed/
key: vcpkg-${{ runner.os }}-${{ matrix.vcpkg_arch }}
- name: Install build dependencies
if: steps.cache-c-core.outputs.cache-hit != 'true' # Only needed when building the C core
run: choco install winflexbison3 ninja
- name: Install VCPKG libraries
run: |
%VCPKG_INSTALLATION_ROOT%\vcpkg.exe integrate install
%VCPKG_INSTALLATION_ROOT%\vcpkg.exe install libxml2:${{ matrix.vcpkg_arch }}-windows-static-md
shell: cmd
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BEFORE_BUILD: "python setup.py build_c_core"
CIBW_BUILD: "*-${{ matrix.wheel_arch }}"
CIBW_TEST_COMMAND: "cd /d {project} && pip install --prefer-binary \".[test]\" && python -m pytest tests"
# Skip tests for Python 3.10 onwards because SciPy does not have
# 32-bit wheels for Windows
CIBW_TEST_SKIP: "cp310-win32 cp311-win32 cp312-win32"
IGRAPH_CMAKE_EXTRA_ARGS: -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_arch }}-windows-static-md -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake -A ${{ matrix.cmake_arch }}
IGRAPH_EXTRA_LIBRARY_PATH: C:/vcpkg/installed/${{ matrix.vcpkg_arch }}-windows-static-md/lib/
IGRAPH_STATIC_EXTENSION: True
IGRAPH_EXTRA_LIBRARIES: libxml2,lzma,zlib,iconv,charset
IGRAPH_EXTRA_DYNAMIC_LIBRARIES: wsock32,ws2_32
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
build_sdist:
name: Build sdist and test extra dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Cache installed C core
id: cache-c-core
uses: actions/cache@v3
with:
path: |
vendor/install
key: C-core-cache-${{ runner.os }}-${{ hashFiles('.git/modules/**/HEAD') }}
- name: Install OS dependencies
if: steps.cache-c-core.outputs.cache-hit != 'true' # Only needed when building the C core
run:
sudo apt install ninja-build cmake flex bison
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.8'
- name: Build sdist
run: |
python setup.py build_c_core
python setup.py sdist
python setup.py install
- name: Test
run: |
pip install --prefer-binary cairocffi numpy scipy pandas networkx pytest pytest-timeout
python -m pytest -v tests
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
# When updating 'runs-on', the ASan/UBSan library paths/versions must also be updated for LD_PRELOAD
# for the "Test" step below.
build_with_sanitizer:
name: Build with sanitizers for debugging purposes
runs-on: ubuntu-20.04
env:
IGRAPH_CMAKE_EXTRA_ARGS: -DFORCE_COLORED_OUTPUT=ON
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Cache installed C core
id: cache-c-core
uses: actions/cache@v3
with:
path: |
vendor/build
vendor/install
key: C-core-build-sanitizer-v1-${{ runner.os }}-${{ hashFiles('.git/modules/vendor/source/igraph/HEAD') }}
- name: Install OS dependencies
if: steps.cache-c-core.outputs.cache-hit != 'true' # Only needed when building the C core
run:
sudo apt install ninja-build cmake flex bison
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.12'
- name: Install test dependencies
run: |
pip install --prefer-binary pytest pytest-timeout setuptools
- name: Build C core
env:
IGRAPH_USE_SANITIZERS: 1
run: |
python setup.py build_c_core
- name: Build and install Python extension
env:
IGRAPH_USE_SANITIZERS: 1
run: |
# NOTE: install calls "build" first
python setup.py install
# Only pytest, and nothing else should be run in this section due to the presence of LD_PRELOAD.
# The ASan/UBSan library versions need to be updated when switching to a newer Ubuntu/GCC.
# LD_PRELOAD needs to be specified in the "run" section to ensure that we
# do not pick up memory leaks in the wrapper shell (e.g., /bin/bash)
- name: Test
env:
ASAN_OPTIONS: "detect_stack_use_after_return=1"
LSAN_OPTIONS: "suppressions=etc/lsan-suppr.txt:print_suppressions=false"
run: |
LD_PRELOAD=/lib/x86_64-linux-gnu/libasan.so.5:/lib/x86_64-linux-gnu/libubsan.so.1 python -m pytest --capture=sys tests