Skip to content

Commit 65393af

Browse files
authored
CI Simplify Windows cibuildwheel setup (#2)
1 parent d483da6 commit 65393af

5 files changed

Lines changed: 36 additions & 95 deletions

File tree

.github/workflows/wheels.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ jobs:
174174
uses: pypa/cibuildwheel@f03ac7617d6cff873ccf24cc0d567ef5ba5a9e6d # v4.0.0
175175
env:
176176
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
177-
CIBW_BEFORE_TEST_WINDOWS: bash tools/build_minimal_windows_image.sh ${{ matrix.python }} ${{ matrix.platform_id }}
178-
CIBW_TEST_COMMAND_WINDOWS: bash {project}/tools/test_windows_wheels.sh ${{ matrix.python }} {project} ${{ matrix.platform_id }}
179177
SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
180178
PYTHONHASHSEED: "0"
181179
CIBW_ENVIRONMENT_PASS_LINUX: SOURCE_DATE_EPOCH PYTHONHASHSEED RUNNER_OS
@@ -184,6 +182,15 @@ jobs:
184182
output-dir: dist
185183
config-file: cibuildwheel.toml
186184

185+
# Running in a minimal Docker image makes sure that we bundled correctly
186+
# the shared libraries for MSVC C++ runtime and OpenMP in the Windows
187+
# wheel
188+
- name: Test Windows wheel in a minimal Docker image
189+
# Currently Windows ARM64 runners do not have Docker support and there
190+
# is no Docker image with free-threaded
191+
if: ${{ matrix.platform_id == 'win_amd64' && !contains(matrix.python, 't') }}
192+
run: bash tools/test_windows_wheels_in_docker.sh ${{ matrix.python }}
193+
187194
- name: Store artifacts
188195
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
189196
with:

cibuildwheel.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,3 @@ test-command = "bash {project}/tools/test_wheels.sh {project}"
1515
# toolchain
1616
config-settings = "setup-args=--vsenv"
1717
repair-wheel-command = "bash tools/repair_windows_wheels.sh {wheel} {dest_dir}"
18-
# On Windows, we use a custom Docker image and the test dependencies are
19-
# installed inside the Docker image rather than on the host, so there are no
20-
# test requirements to install here.
21-
test-requires = []

tools/build_minimal_windows_image.sh

Lines changed: 0 additions & 48 deletions
This file was deleted.

tools/test_windows_wheels.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -x
5+
6+
PYTHON_VERSION=$1
7+
8+
WHEEL_PATH=$(ls dist/*.whl)
9+
10+
# Dot the Python version for identifying the base Docker image.
11+
PYTHON_DOCKER_IMAGE_PART="${PYTHON_VERSION:0:1}.${PYTHON_VERSION:1:2}"
12+
13+
DOCKER_IMAGE="winamd64/python:${PYTHON_DOCKER_IMAGE_PART}-windowsservercore"
14+
MNT_FOLDER="C:/mnt"
15+
CONTAINER_ID=$(docker run -it -v "$(cygpath -w "$PWD"):$MNT_FOLDER" -d "$DOCKER_IMAGE")
16+
17+
function exec_inside_container() {
18+
docker exec "$CONTAINER_ID" powershell -Command "$1"
19+
}
20+
21+
exec_inside_container "python -m venv C:/venv"
22+
exec_inside_container "C:/venv/Scripts/python -m pip install $MNT_FOLDER/$WHEEL_PATH"
23+
exec_inside_container "C:/venv/Scripts/python -c 'import sklearn; sklearn.show_versions()'"
24+
# Running the estimator checks is a good enough check to make sure we bundled
25+
# correctly the shared libraries on Windows, while still being reasonably fast
26+
# to run.
27+
exec_inside_container "C:/venv/Scripts/python -m sklearn.utils.tests.test_estimator_checks"

0 commit comments

Comments
 (0)