diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 179400490..f6676952a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,16 +4,22 @@ name: Build and test on: [push, pull_request] env: CIBW_ENABLE: pypy - CIBW_ENVIRONMENT_PASS_LINUX: PYTEST_TIMEOUT + CIBW_ENVIRONMENT_PASS_LINUX: PYTEST_TIMEOUT PIP_PREFER_BINARY CIBW_PROJECT_REQUIRES_PYTHON: ">=3.11" - CIBW_TEST_COMMAND: "cd {project} && pip install --prefer-binary '.[test]' && python -m pytest -v tests" + # Install the test dependencies next to the built wheel. Do not run + # "pip install ." in the test command: it would rebuild igraph from source + # and replace the wheel under test. + CIBW_TEST_EXTRAS: test + CIBW_TEST_COMMAND: "cd {project} && python -m pytest -v tests" # Free-threaded builds excluded because they do not support the limited API CIBW_SKIP: "*t-*" PYTEST_TIMEOUT: 60 + # Prefer binary wheels of test dependencies over building them from source + PIP_PREFER_BINARY: 1 jobs: - build_wheel_linux: - name: Build wheels on Linux (x86_64) + build_wheel_linux_manylinux: + name: Build wheels on Linux (x86_64/manylinux) runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v7 @@ -27,16 +33,30 @@ jobs: CIBW_BEFORE_BUILD: "yum install -y flex bison libxml2-devel zlib-devel cairo-devel && pip install -U cmake pip setuptools wheel && python setup.py build_c_core" CIBW_BUILD: "*-manylinux_x86_64" + - uses: actions/upload-artifact@v7 + with: + name: wheels-linux-x86_64-manylinux + path: ./wheelhouse/*.whl + + build_wheel_linux_musllinux: + name: Build wheels on Linux (x86_64/musllinux) + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v7 + with: + submodules: true + fetch-depth: 0 + - name: Build wheels (musllinux) uses: pypa/cibuildwheel@v4.3.5 env: CIBW_BEFORE_BUILD: "apk add flex bison libxml2-dev zlib-dev cairo-dev && pip install -U cmake pip setuptools wheel && python setup.py build_c_core" CIBW_BUILD: "*-musllinux_x86_64" - CIBW_TEST_COMMAND: "cd {project} && pip install --prefer-binary '.[test-musl]' && python -m pytest -v tests" + CIBW_TEST_EXTRAS: test-musl - uses: actions/upload-artifact@v7 with: - name: wheels-linux-x86_64 + name: wheels-linux-x86_64-musllinux path: ./wheelhouse/*.whl build_wheel_linux_aarch64_manylinux: @@ -75,7 +95,7 @@ jobs: CIBW_BEFORE_BUILD: "apk add flex bison libxml2-dev zlib-dev cairo-dev && pip install -U cmake pip setuptools 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" + CIBW_TEST_EXTRAS: test-musl - uses: actions/upload-artifact@v7 with: @@ -108,7 +128,7 @@ jobs: uses: actions/cache@v5 with: path: vendor/install - key: C-core-cache-${{ runner.os }}-${{ matrix.cmake_arch }}-llvm${{ env.LLVM_VERSION }}-${{ hashFiles('.git/modules/**/HEAD') }} + key: C-core-cache-${{ runner.os }}-${{ matrix.cmake_arch }}-llvm${{ env.LLVM_VERSION }}-${{ hashFiles('.git/modules/vendor/source/igraph/HEAD') }} - name: Cache C core dependencies id: cache-c-deps @@ -146,8 +166,12 @@ jobs: path: ./wheelhouse/*.whl build_wheel_wasm: - name: Build wheels for WebAssembly + name: Build wheels for WebAssembly (${{ matrix.python }}) runs-on: ubuntu-22.04 + strategy: + matrix: + # One job per Pyodide version, because each one builds its own C core + python: [cp313, cp314, cp315] steps: - uses: actions/checkout@v7 @@ -159,6 +183,7 @@ jobs: uses: pypa/cibuildwheel@v4.3.5 env: CIBW_PLATFORM: pyodide + CIBW_BUILD: "${{ matrix.python }}-pyodide_wasm32" # Each Pyodide version uses a different Emscripten version and exception # model, so the C core must not be reused between builds CIBW_BEFORE_BUILD: "rm -rf vendor/build vendor/install" @@ -166,7 +191,7 @@ jobs: - uses: actions/upload-artifact@v7 with: - name: wheels-wasm + name: wheels-wasm-${{ matrix.python }} path: ./wheelhouse/*.whl if-no-files-found: error @@ -203,7 +228,7 @@ jobs: uses: actions/cache@v5 with: path: vendor/install - key: C-core-cache-${{ runner.os }}-${{ matrix.cmake_arch }}-${{ hashFiles('.git/modules/**/HEAD') }} + key: C-core-cache-${{ runner.os }}-${{ matrix.cmake_arch }}-${{ hashFiles('.git/modules/vendor/source/igraph/HEAD') }} - name: Cache VCPKG uses: actions/cache@v5 @@ -226,7 +251,8 @@ jobs: env: CIBW_BEFORE_BUILD: "pip install -U setuptools && python setup.py build_c_core" CIBW_BUILD: "*-${{ matrix.wheel_arch }}" - CIBW_TEST_COMMAND: 'cd /d {project} && pip install --prefer-binary ".[${{ matrix.test_extra }}]" && python -m pytest tests' + CIBW_TEST_EXTRAS: ${{ matrix.test_extra }} + CIBW_TEST_COMMAND: "cd /d {project} && python -m pytest tests" # Skip tests on 32-bit Windows because SciPy does not have # 32-bit wheels for Windows any more CIBW_TEST_SKIP: "*-win32" @@ -254,13 +280,15 @@ jobs: id: os-version run: echo "version=$(lsb_release -rs)" >> "$GITHUB_OUTPUT" - - name: Cache installed C core + # sdist needs the parser sources generated in vendor/build, so cache that too + - name: Cache C core build id: cache-c-core uses: actions/cache@v5 with: path: | + vendor/build vendor/install - key: C-core-cache-${{ runner.os }}-${{ steps.os-version.outputs.version }}-${{ hashFiles('.git/modules/**/HEAD') }} + key: C-core-build-sdist-v1-${{ runner.os }}-${{ steps.os-version.outputs.version }}-${{ 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