Skip to content

Commit

Permalink
(feat) Try cibuildwheels on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
MementoRC committed Jan 23, 2024
1 parent a295766 commit 557c783
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/scripts/Windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Get the Python version of the base image from a build argument
ARG PYTHON_VERSION
FROM winamd64/python:$PYTHON_VERSION-windowsservercore

ARG WHEEL_NAME
ARG CIBW_TEST_REQUIRES

# Copy and install the Windows wheel
COPY $WHEEL_NAME $WHEEL_NAME
RUN pip install $env:WHEEL_NAME

# Install the testing dependencies
RUN pip install $env:CIBW_TEST_REQUIRES.split(" ")
25 changes: 25 additions & 0 deletions .github/scripts/build-minimal-windows-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -e
set -x

PYTHON_VERSION=$1

TEMP_FOLDER="$HOME/AppData/Local/Temp"
WHEEL_PATH=$(ls -d $TEMP_FOLDER/**/*/repaired_wheel/*)
WHEEL_NAME=$(basename $WHEEL_PATH)

cp $WHEEL_PATH $WHEEL_NAME

# Dot the Python version for identyfing the base Docker image
PYTHON_VERSION=$(echo ${PYTHON_VERSION:0:1}.${PYTHON_VERSION:1:2})

if [[ "$CIBW_PRERELEASE_PYTHONS" == "True" ]]; then
PYTHON_VERSION="$PYTHON_VERSION-rc"
fi
# Build a minimal Windows Docker image for testing the wheels
docker build --build-arg PYTHON_VERSION=$PYTHON_VERSION \
--build-arg WHEEL_NAME=$WHEEL_NAME \
--build-arg CIBW_TEST_REQUIRES="$CIBW_TEST_REQUIRES" \
-f ./.github/Windows \
-t coincurve/minimal-windows .
9 changes: 9 additions & 0 deletions .github/scripts/test-windows-wheels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e
set -x

PYTHON_VERSION=$1

docker container run --rm scikit-learn/minimal-windows \
powershell -Command "pytest"
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,29 @@ jobs:
path: wheelhouse/*.whl
if-no-files-found: error

windows-wheels-standard:
name: Build Windows wheels
needs:
- test
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BEFORE_TEST_WINDOWS: bash {project}/.github/scripts/build-minimal-windows-image.sh 312
CIBW_TEST_COMMAND_WINDOWS: bash {project}/.github/scripts/test-windows-wheels.sh 312
CIBW_TEST_REQUIRES: pytest pytest-benchmark
CIBW_TEST_COMMAND: python -m pytest {project}/tests

- uses: actions/upload-artifact@v3
with:
name: artifacts
path: wheelhouse/*.whl
if-no-files-found: error

macos-wheels-x86-64:
name: Build macOS wheels
needs:
Expand Down

0 comments on commit 557c783

Please sign in to comment.