Skip to content

Commit d4ca146

Browse files
authored
MAINT Add Python 3.13 wheels (scikit-learn#29789)
1 parent 0ff50b1 commit d4ca146

File tree

5 files changed

+65
-25
lines changed

5 files changed

+65
-25
lines changed

.github/workflows/wheels.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ jobs:
6565
- os: windows-latest
6666
python: 312
6767
platform_id: win_amd64
68+
- os: windows-latest
69+
python: 313
70+
platform_id: win_amd64
71+
# TODO: remove next line when Python 3.13 is released
72+
prerelease_pythons: True
6873

6974
# Linux 64 bit manylinux2014
7075
- os: ubuntu-latest
@@ -86,12 +91,14 @@ jobs:
8691
python: 312
8792
platform_id: manylinux_x86_64
8893
manylinux_image: manylinux2014
94+
- os: ubuntu-latest
95+
python: 313
96+
platform_id: manylinux_x86_64
97+
manylinux_image: manylinux2014
8998
- os: ubuntu-latest
9099
python: 313t
91100
platform_id: manylinux_x86_64
92101
manylinux_image: manylinux2014
93-
# TODO: remove next line when Python 3.13 is released
94-
prerelease_pythons: True
95102
free_threaded_support: True
96103

97104
# MacOS x86_64
@@ -107,6 +114,9 @@ jobs:
107114
- os: macos-12
108115
python: 312
109116
platform_id: macosx_x86_64
117+
- os: macos-12
118+
python: 313
119+
platform_id: macosx_x86_64
110120

111121
# MacOS arm64
112122
- os: macos-14
@@ -121,6 +131,9 @@ jobs:
121131
- os: macos-14
122132
python: 312
123133
platform_id: macosx_arm64
134+
- os: macos-14
135+
python: 313
136+
platform_id: macosx_arm64
124137

125138
steps:
126139
- name: Checkout scikit-learn
@@ -176,6 +189,10 @@ jobs:
176189
CIBW_BEFORE_TEST_WINDOWS: bash build_tools/github/build_minimal_windows_image.sh ${{ matrix.python }}
177190
CIBW_BEFORE_TEST: bash {project}/build_tools/wheels/cibw_before_test.sh
178191
CIBW_TEST_REQUIRES: pytest pandas
192+
# On Windows, we use a custom Docker image and CIBW_TEST_REQUIRES_WINDOWS
193+
# does not make sense because it would install dependencies in the host
194+
# rather than inside the Docker image
195+
CIBW_TEST_REQUIRES_WINDOWS: ""
179196
CIBW_TEST_COMMAND: bash {project}/build_tools/wheels/test_wheels.sh
180197
CIBW_TEST_COMMAND_WINDOWS: bash {project}/build_tools/github/test_windows_wheels.sh ${{ matrix.python }}
181198
CIBW_BUILD_VERBOSITY: 1

build_tools/cirrus/arm_wheel.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ linux_arm64_wheel_task:
2828
CIBW_TEST_SKIP: "*_aarch64"
2929
- env:
3030
CIBW_BUILD: cp312-manylinux_aarch64
31+
- env:
32+
CIBW_BUILD: cp313-manylinux_aarch64
33+
# TODO remove next line when Python 3.13 is relased and add
34+
# CIBW_TEST_SKIP for Python 3.12 above
35+
CIBW_TEST_SKIP: "*_aarch64"
3136

3237
cibuildwheel_script:
3338
- apt install -y python3 python-is-python3

build_tools/github/Windows

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

build_tools/github/build_minimal_windows_image.sh

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,37 @@ WHEEL_NAME=$(basename $WHEEL_PATH)
1111

1212
cp $WHEEL_PATH $WHEEL_NAME
1313

14-
# Dot the Python version for identyfing the base Docker image
15-
PYTHON_VERSION=$(echo ${PYTHON_VERSION:0:1}.${PYTHON_VERSION:1:2})
14+
# Dot the Python version for identifying the base Docker image
15+
PYTHON_DOCKER_IMAGE_PART=$(echo ${PYTHON_VERSION:0:1}.${PYTHON_VERSION:1:2})
1616

17-
if [[ "$CIBW_PRERELEASE_PYTHONS" == "True" ]]; then
18-
PYTHON_VERSION="$PYTHON_VERSION-rc"
17+
if [[ "$CIBW_PRERELEASE_PYTHONS" =~ [tT]rue ]]; then
18+
PYTHON_DOCKER_IMAGE_PART="${PYTHON_DOCKER_IMAGE_PART}-rc"
1919
fi
20-
# Build a minimal Windows Docker image for testing the wheels
21-
docker build --build-arg PYTHON_VERSION=$PYTHON_VERSION \
22-
--build-arg WHEEL_NAME=$WHEEL_NAME \
23-
--build-arg CIBW_TEST_REQUIRES="$CIBW_TEST_REQUIRES" \
24-
-f build_tools/github/Windows \
25-
-t scikit-learn/minimal-windows .
20+
21+
# We could have all of the following logic in a Dockerfile but it's a lot
22+
# easier to do it in bash rather than figure out how to do it in Powershell
23+
# inside the Dockerfile ...
24+
DOCKER_IMAGE="winamd64/python:${PYTHON_DOCKER_IMAGE_PART}-windowsservercore"
25+
MNT_FOLDER="C:/mnt"
26+
CONTAINER_ID=$(docker run -it -v "$(cygpath -w $PWD):$MNT_FOLDER" -d $DOCKER_IMAGE)
27+
28+
function exec_inside_container() {
29+
docker exec $CONTAINER_ID powershell -Command $1
30+
}
31+
32+
exec_inside_container "python -m pip install $MNT_FOLDER/$WHEEL_NAME"
33+
34+
if [[ "$PYTHON_VERSION" == "313" ]]; then
35+
# TODO: remove when pandas has a release with python 3.13 wheels
36+
# First install numpy release
37+
exec_inside_container "python -m pip install numpy"
38+
# Then install pandas-dev
39+
exec_inside_container "python -m pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas --only-binary :all:"
40+
fi
41+
42+
exec_inside_container "python -m pip install $CIBW_TEST_REQUIRES"
43+
44+
# Save container state to scikit-learn/minimal-windows image. On Windows the
45+
# container needs to be stopped first.
46+
docker stop $CONTAINER_ID
47+
docker commit $CONTAINER_ID scikit-learn/minimal-windows

build_tools/wheels/cibw_before_test.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@ set -e
44
set -x
55

66
FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))")"
7+
PY_VERSION=$(python -c 'import sys; print(f"{sys.version_info.major}{sys.version_info.minor}")')
8+
79
if [[ $FREE_THREADED_BUILD == "True" ]]; then
810
# TODO: remove when numpy, scipy and pandas have releases with free-threaded wheels
911
python -m pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy scipy pandas --only-binary :all:
12+
13+
elif [[ "$PY_VERSION" == "313" ]]; then
14+
# TODO: remove when pandas has a release with python 3.13 wheels
15+
# First install numpy release
16+
python -m pip install numpy --only-binary :all:
17+
# Then install pandas-dev
18+
python -m pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas --only-binary :all:
1019
fi

0 commit comments

Comments
 (0)