Skip to content

REL scikit-learn 1.5.2 for Python 3.13 #29987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ jobs:
- os: windows-latest
python: 312
platform_id: win_amd64
- os: windows-latest
python: 313
platform_id: win_amd64
# TODO: remove next line when Python 3.13 is released
prerelease_pythons: True

# Linux 64 bit manylinux2014
- os: ubuntu-latest
Expand All @@ -86,6 +91,10 @@ jobs:
python: 312
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python: 313
platform_id: manylinux_x86_64
manylinux_image: manylinux2014

# MacOS x86_64
- os: macos-12
Expand All @@ -100,6 +109,9 @@ jobs:
- os: macos-12
python: 312
platform_id: macosx_x86_64
- os: macos-12
python: 313
platform_id: macosx_x86_64

# MacOS arm64
- os: macos-14
Expand All @@ -114,6 +126,9 @@ jobs:
- os: macos-14
python: 312
platform_id: macosx_arm64
- os: macos-14
python: 313
platform_id: macosx_arm64

steps:
- name: Checkout scikit-learn
Expand Down Expand Up @@ -154,7 +169,8 @@ jobs:

- name: Build and test wheels
env:
CIBW_PRERELEASE_PYTHONS: ${{ matrix.prerelease }}
CIBW_PRERELEASE_PYTHONS: ${{ matrix.prerelease_pythons }}
CIBW_FREE_THREADED_SUPPORT: ${{ matrix.free_threaded_support }}
CIBW_ENVIRONMENT: SKLEARN_SKIP_NETWORK_TESTS=1
SKLEARN_BUILD_PARALLEL=3
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
Expand All @@ -167,7 +183,12 @@ jobs:
CIBW_CONFIG_SETTINGS_WINDOWS: "setup-args=--vsenv"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: bash build_tools/github/repair_windows_wheels.sh {wheel} {dest_dir}
CIBW_BEFORE_TEST_WINDOWS: bash build_tools/github/build_minimal_windows_image.sh ${{ matrix.python }}
CIBW_TEST_REQUIRES: pytest pandas ${{ matrix.python == 312 && 'numpy>=2.0.0rc2' || '' }}
CIBW_BEFORE_TEST: bash {project}/build_tools/wheels/cibw_before_test.sh
CIBW_TEST_REQUIRES: pytest pandas
# On Windows, we use a custom Docker image and CIBW_TEST_REQUIRES_WINDOWS
# does not make sense because it would install dependencies in the host
# rather than inside the Docker image
CIBW_TEST_REQUIRES_WINDOWS: ""
CIBW_TEST_COMMAND: bash {project}/build_tools/wheels/test_wheels.sh
CIBW_TEST_COMMAND_WINDOWS: bash {project}/build_tools/github/test_windows_wheels.sh ${{ matrix.python }}
CIBW_BUILD_VERBOSITY: 1
Expand Down
5 changes: 5 additions & 0 deletions build_tools/cirrus/arm_wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ linux_arm64_wheel_task:
CIBW_TEST_SKIP: "*_aarch64"
- env:
CIBW_BUILD: cp312-manylinux_aarch64
- env:
CIBW_BUILD: cp313-manylinux_aarch64
# TODO remove next line when Python 3.13 is relased and add
# CIBW_TEST_SKIP for Python 3.12 above
CIBW_TEST_SKIP: "*_aarch64"

cibuildwheel_script:
- apt install -y python3 python-is-python3
Expand Down
13 changes: 0 additions & 13 deletions build_tools/github/Windows

This file was deleted.

42 changes: 32 additions & 10 deletions build_tools/github/build_minimal_windows_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,37 @@ 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})
# Dot the Python version for identifying the base Docker image
PYTHON_DOCKER_IMAGE_PART=$(echo ${PYTHON_VERSION:0:1}.${PYTHON_VERSION:1:2})

if [[ "$CIBW_PRERELEASE_PYTHONS" == "True" ]]; then
PYTHON_VERSION="$PYTHON_VERSION-rc"
if [[ "$CIBW_PRERELEASE_PYTHONS" =~ [tT]rue ]]; then
PYTHON_DOCKER_IMAGE_PART="${PYTHON_DOCKER_IMAGE_PART}-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 build_tools/github/Windows \
-t scikit-learn/minimal-windows .

# We could have all of the following logic in a Dockerfile but it's a lot
# easier to do it in bash rather than figure out how to do it in Powershell
# inside the Dockerfile ...
DOCKER_IMAGE="winamd64/python:${PYTHON_DOCKER_IMAGE_PART}-windowsservercore"
MNT_FOLDER="C:/mnt"
CONTAINER_ID=$(docker run -it -v "$(cygpath -w $PWD):$MNT_FOLDER" -d $DOCKER_IMAGE)

function exec_inside_container() {
docker exec $CONTAINER_ID powershell -Command $1
}

exec_inside_container "python -m pip install $MNT_FOLDER/$WHEEL_NAME"

if [[ "$PYTHON_VERSION" == "313" ]]; then
# TODO: remove when pandas has a release with python 3.13 wheels
# First install numpy release
exec_inside_container "python -m pip install numpy"
# Then install pandas-dev
exec_inside_container "python -m pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas --only-binary :all:"
fi

exec_inside_container "python -m pip install $CIBW_TEST_REQUIRES"

# Save container state to scikit-learn/minimal-windows image. On Windows the
# container needs to be stopped first.
docker stop $CONTAINER_ID
docker commit $CONTAINER_ID scikit-learn/minimal-windows
7 changes: 7 additions & 0 deletions build_tools/wheels/build_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ if [[ "$CIBW_FREE_THREADED_SUPPORT" =~ [tT]rue ]]; then
export CIBW_BUILD_FRONTEND='pip; args: --pre --extra-index-url "https://pypi.anaconda.org/scientific-python-nightly-wheels/simple" --only-binary :all:'
fi

if [[ "$CIBW_FREE_THREADED_SUPPORT" =~ [tT]rue ]]; then
# Numpy, scipy, Cython only have free-threaded wheels on scientific-python-nightly-wheels
# TODO: remove this after CPython 3.13 is released (scheduled October 2024)
# and our dependencies have free-threaded wheels on PyPI
export CIBW_BUILD_FRONTEND='pip; args: --pre --extra-index-url "https://pypi.anaconda.org/scientific-python-nightly-wheels/simple"'
fi

# The version of the built dependencies are specified
# in the pyproject.toml file, while the tests are run
# against the most recent version of the dependencies
Expand Down
19 changes: 19 additions & 0 deletions build_tools/wheels/cibw_before_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -e
set -x

FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))")"
PY_VERSION=$(python -c 'import sys; print(f"{sys.version_info.major}{sys.version_info.minor}")')

if [[ $FREE_THREADED_BUILD == "True" ]]; then
# TODO: remove when numpy, scipy and pandas have releases with free-threaded wheels
python -m pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy scipy pandas --only-binary :all:

elif [[ "$PY_VERSION" == "313" ]]; then
# TODO: remove when pandas has a release with python 3.13 wheels
# First install numpy release
python -m pip install numpy --only-binary :all:
# Then install pandas-dev
python -m pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas --only-binary :all:
fi
8 changes: 8 additions & 0 deletions build_tools/wheels/test_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ set -x
python -c "import joblib; print(f'Number of cores (physical): \
{joblib.cpu_count()} ({joblib.cpu_count(only_physical_cores=True)})')"

FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))")"
if [[ $FREE_THREADED_BUILD == "True" ]]; then
# TODO: delete when importing numpy no longer enables the GIL
# setting to zero ensures the GIL is disabled while running the
# tests under free-threaded python
export PYTHON_GIL=0
fi

# Test that there are no links to system libraries in the
# threadpoolctl output section of the show_versions output:
python -c "import sklearn; sklearn.show_versions()"
Expand Down