From 3cc3d58d77678d52c4a4cb23ac5c1c1b3420d22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szabolcs=20Horv=C3=A1t?= Date: Sat, 28 Nov 2026 14:32:17 +0000 Subject: [PATCH 1/5] ci: test the built wheels instead of a fresh source build The test command ran "pip install '.[test]'" from the project directory. pip builds a local directory from source, so every test run uninstalled the repaired wheel, compiled the extension again and tested that build instead. The shipped wheels were never tested, and the rebuild took 45-100 s for each CPython version on each platform. Install the test dependencies with CIBW_TEST_EXTRAS instead, and keep preferring binary wheels for them with PIP_PREFER_BINARY. Assisted-by: Claude Opus 5.5 --- .github/workflows/build.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 179400490..403cd969d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,12 +4,18 @@ 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: @@ -32,7 +38,7 @@ jobs: 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: @@ -75,7 +81,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: @@ -226,7 +232,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" From 3214e9ed83ab38eb5f61408d33e1cd71017e1a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szabolcs=20Horv=C3=A1t?= Date: Sat, 28 Nov 2026 14:32:26 +0000 Subject: [PATCH 2/5] ci: fix C core cache keys that never matched The macOS, Windows and sdist cache keys hashed .git/modules/**/HEAD. That glob also matches the submodule reflog logs/HEAD, which contains checkout timestamps, so the key changed on every run: the C core was rebuilt each time and a new cache entry was saved. Hash only the submodule's HEAD file, as the sanitizer job already does. Assisted-by: Claude Opus 5.5 --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 403cd969d..c75c11b36 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -114,7 +114,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 @@ -209,7 +209,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 @@ -267,7 +267,7 @@ jobs: with: path: | vendor/install - key: C-core-cache-${{ runner.os }}-${{ steps.os-version.outputs.version }}-${{ hashFiles('.git/modules/**/HEAD') }} + key: C-core-cache-${{ 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 From 93a1e649c31011345d6137182fe902171aa4b06f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szabolcs=20Horv=C3=A1t?= Date: Sat, 28 Nov 2026 14:32:33 +0000 Subject: [PATCH 3/5] ci: build manylinux and musllinux x86_64 wheels in separate jobs The two cibuildwheel steps ran one after the other in one job, which made it the slowest job in the workflow. Split it in two, as the aarch64 builds already are. Assisted-by: Claude Opus 5.5 --- .github/workflows/build.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c75c11b36..9f74181a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,8 +18,8 @@ env: 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 @@ -33,6 +33,20 @@ 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: @@ -42,7 +56,7 @@ jobs: - 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: From 403e7f3b12b6d7dd8db58017306cf33863807015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szabolcs=20Horv=C3=A1t?= Date: Sat, 28 Nov 2026 14:32:39 +0000 Subject: [PATCH 4/5] ci: build each Pyodide wheel in its own job The three Pyodide wheels each rebuild the C core with their own Emscripten version and took about 6 minutes each, one after the other. Build them in parallel with a matrix over the CPython versions. Assisted-by: Claude Opus 5.5 --- .github/workflows/build.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9f74181a8..24ba92369 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -166,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 @@ -179,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" @@ -186,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 From 9028771a2c53ffe08141937c97a896cb6b57345f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szabolcs=20Horv=C3=A1t?= Date: Sat, 28 Nov 2026 19:19:56 +0000 Subject: [PATCH 5/5] ci: cache the C core build folder in the sdist job The sdist command copies the generated parser sources from vendor/build, but the sdist job only cached vendor/install. This went unnoticed because the cache key never matched before. Now that it does, a cache hit skipped the C core build and sdist failed. Cache vendor/build as well, under a new key, as the sanitizer job already does. Assisted-by: Claude Opus 5.5 --- .github/workflows/build.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 24ba92369..f6676952a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -280,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/vendor/source/igraph/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