From 9017c21bdc69c7d36461f7235fef6951c227f86e Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 6 Jan 2024 15:38:55 +0530 Subject: [PATCH] #3646 set CMake parallelism for Windows wheels --- .github/workflows/publish_pypi.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 10b318b9ed..556ffd1a1f 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -37,6 +37,16 @@ jobs: with: python-version: 3.8 + - name: Get number of cores on Windows + id: get_num_cores + shell: python + run: | + from os import environ, sched_getaffinity + num_cpus = len(sched_getaffinity(0)) + output_file = environ['GITHUB_OUTPUT'] + with open(output_file, "a", encoding="utf-8") as output_stream: + output_stream.write(f"count={num_cpus}\n") + - name: Clone pybind11 repo (no history) run: git clone --depth 1 --branch v2.11.1 https://github.com/pybind/pybind11.git @@ -64,7 +74,14 @@ jobs: - name: Build 64-bit wheels on Windows run: pipx run cibuildwheel --output-dir wheelhouse env: - CIBW_ENVIRONMENT: 'PYBAMM_USE_VCPKG=ON VCPKG_ROOT_DIR=C:\vcpkg VCPKG_DEFAULT_TRIPLET=x64-windows-static-md VCPKG_FEATURE_FLAGS=manifests,registries CMAKE_GENERATOR="Visual Studio 17 2022" CMAKE_GENERATOR_PLATFORM=x64' + CIBW_ENVIRONMENT: > + PYBAMM_USE_VCPKG=ON + VCPKG_ROOT_DIR=C:\vcpkg + VCPKG_DEFAULT_TRIPLET=x64-windows-static-md + VCPKG_FEATURE_FLAGS=manifests,registries + CMAKE_GENERATOR="Visual Studio 17 2022" + CMAKE_GENERATOR_PLATFORM=x64' + CMAKE_BUILD_PARALLEL_LEVEL: ${{ steps.get_num_cores.outputs.num_cpus }} CIBW_ARCHS: "AMD64" CIBW_BEFORE_BUILD: python -m pip install setuptools wheel # skip CasADi and CMake CIBW_TEST_COMMAND: python -c "import pybamm; pybamm.IDAKLUSolver()"