From 81a2b98062568fc2ccfda8aed90ea5feaee65f38 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 8 Oct 2024 21:21:44 -0500 Subject: [PATCH 1/4] [python-package] support Python 3.13 --- .github/workflows/cuda.yml | 6 +++--- .github/workflows/linkchecker.yml | 2 +- .github/workflows/python_package.yml | 29 +++++++++++++++++---------- .github/workflows/static_analysis.yml | 2 +- .pre-commit-config.yaml | 4 ++-- .vsts-ci.yml | 28 +++++++++++++------------- docs/env.yml | 2 +- python-package/pyproject.toml | 1 + 8 files changed, 41 insertions(+), 33 deletions(-) diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index f6bb354bc5a9..9e6968ebcf96 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -81,19 +81,19 @@ jobs: include: - method: wheel compiler: gcc - python_version: "3.10" + python_version: "3.11" cuda_version: "12.6.1" linux_version: "ubuntu22.04" task: cuda - method: source compiler: gcc - python_version: "3.12" + python_version: "3.13" cuda_version: "12.2.2" linux_version: "ubuntu22.04" task: cuda - method: pip compiler: clang - python_version: "3.11" + python_version: "3.12" cuda_version: "11.8.0" linux_version: "ubuntu20.04" task: cuda diff --git a/.github/workflows/linkchecker.yml b/.github/workflows/linkchecker.yml index 42391bb31da0..4f9dc6dfb559 100644 --- a/.github/workflows/linkchecker.yml +++ b/.github/workflows/linkchecker.yml @@ -10,7 +10,7 @@ on: env: COMPILER: gcc OS_NAME: 'linux' - PYTHON_VERSION: '3.12' + PYTHON_VERSION: '3.13' TASK: 'check-links' jobs: diff --git a/.github/workflows/python_package.yml b/.github/workflows/python_package.yml index acc40026f9b8..0bd2ed3899a5 100644 --- a/.github/workflows/python_package.yml +++ b/.github/workflows/python_package.yml @@ -28,32 +28,32 @@ jobs: include: - os: macos-13 task: regular - python_version: '3.10' + python_version: '3.11' - os: macos-13 task: sdist - python_version: '3.11' + python_version: '3.12' - os: macos-13 task: bdist - python_version: '3.8' + python_version: '3.9' - os: macos-13 task: if-else - python_version: '3.9' + python_version: '3.10' - os: macos-14 task: bdist method: wheel - python_version: '3.10' + python_version: '3.11' - os: macos-13 task: mpi method: source - python_version: '3.11' + python_version: '3.12' - os: macos-13 task: mpi method: pip - python_version: '3.12' + python_version: '3.13' - os: macos-13 task: mpi method: wheel - python_version: '3.9' + python_version: '3.10' steps: - name: Checkout repository uses: actions/checkout@v4 @@ -113,12 +113,19 @@ jobs: --rm \ -v $(pwd):/opt/lgb-build \ -w /opt/lgb-build \ - python:3.12 \ + python:3.13 \ /bin/bash ./.ci/test-python-latest.sh - test-oldest-versions: + test-old-versions: name: Python - oldest supported versions (ubuntu-latest) runs-on: ubuntu-latest timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + # end-of-life Python versions + python_version: + - 3.7 + - 3.8 steps: - name: Checkout repository uses: actions/checkout@v4 @@ -140,7 +147,7 @@ jobs: --rm \ -v $(pwd):/opt/lgb-build \ -w /opt/lgb-build \ - python:3.7 \ + python:${{ matrix.python_version }} \ /bin/bash ./.ci/test-python-oldest.sh all-python-package-jobs-successful: if: always() diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index 34e573e0eea6..50c65ad0ce56 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -19,7 +19,7 @@ env: COMPILER: 'gcc' MAKEFLAGS: '-j4' OS_NAME: 'linux' - PYTHON_VERSION: '3.12' + PYTHON_VERSION: '3.13' jobs: test: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5d0a8f92968d..b00db8d8916b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ exclude: | repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace @@ -25,7 +25,7 @@ repos: args: ["--settings-path", "python-package/pyproject.toml"] - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.5.7 + rev: v0.6.9 hooks: # Run the linter. - id: ruff diff --git a/.vsts-ci.yml b/.vsts-ci.yml index 3a111e10898e..f00e95306cd4 100644 --- a/.vsts-ci.yml +++ b/.vsts-ci.yml @@ -92,19 +92,19 @@ jobs: matrix: regular: TASK: regular - PYTHON_VERSION: '3.10' + PYTHON_VERSION: '3.11' sdist: TASK: sdist - PYTHON_VERSION: '3.8' + PYTHON_VERSION: '3.9' bdist: TASK: bdist - PYTHON_VERSION: '3.9' + PYTHON_VERSION: '3.10' inference: TASK: if-else mpi_source: TASK: mpi METHOD: source - PYTHON_VERSION: '3.9' + PYTHON_VERSION: '3.10' gpu_source: TASK: gpu METHOD: source @@ -157,7 +157,7 @@ jobs: TASK: sdist bdist: TASK: bdist - PYTHON_VERSION: '3.10' + PYTHON_VERSION: '3.11' inference: TASK: if-else mpi_source: @@ -166,23 +166,23 @@ jobs: mpi_pip: TASK: mpi METHOD: pip - PYTHON_VERSION: '3.11' + PYTHON_VERSION: '3.12' mpi_wheel: TASK: mpi METHOD: wheel - PYTHON_VERSION: '3.9' + PYTHON_VERSION: '3.10' gpu_source: TASK: gpu METHOD: source - PYTHON_VERSION: '3.11' + PYTHON_VERSION: '3.12' gpu_pip: TASK: gpu METHOD: pip - PYTHON_VERSION: '3.10' + PYTHON_VERSION: '3.11' gpu_wheel: TASK: gpu METHOD: wheel - PYTHON_VERSION: '3.9' + PYTHON_VERSION: '3.10' cpp_tests: TASK: cpp-tests METHOD: with-sanitizers @@ -291,10 +291,10 @@ jobs: matrix: regular: TASK: regular - PYTHON_VERSION: '3.10' + PYTHON_VERSION: '3.11' sdist: TASK: sdist - PYTHON_VERSION: '3.9' + PYTHON_VERSION: '3.10' bdist: TASK: bdist swig: @@ -339,10 +339,10 @@ jobs: matrix: regular: TASK: regular - PYTHON_VERSION: '3.10' + PYTHON_VERSION: '3.11' sdist: TASK: sdist - PYTHON_VERSION: '3.9' + PYTHON_VERSION: '3.10' bdist: TASK: bdist swig: diff --git a/docs/env.yml b/docs/env.yml index 5c9c3dd73853..7e3db252faed 100644 --- a/docs/env.yml +++ b/docs/env.yml @@ -4,7 +4,7 @@ channels: - conda-forge dependencies: - breathe>=4.35 - - python=3.10 + - python=3.11 - r-base=4.3.2 - r-data.table=1.14.10 - r-jsonlite=1.8.8 diff --git a/python-package/pyproject.toml b/python-package/pyproject.toml index 2212347637e6..30aa98bf7297 100644 --- a/python-package/pyproject.toml +++ b/python-package/pyproject.toml @@ -16,6 +16,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Scientific/Engineering :: Artificial Intelligence" ] dependencies = [ From d9bab62bc064e845f25016d67cd4be785894b386 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Thu, 17 Oct 2024 16:12:56 -0500 Subject: [PATCH 2/4] update everything in the base conda environment, not just conda --- .ci/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/setup.sh b/.ci/setup.sh index e551b1683aef..8bb64342a89b 100755 --- a/.ci/setup.sh +++ b/.ci/setup.sh @@ -151,5 +151,5 @@ if [[ "${TASK}" != "r-package" ]] && [[ "${TASK}" != "r-rchk" ]]; then sh miniforge.sh -b -p "${CONDA}" fi conda config --set always_yes yes --set changeps1 no - conda update -q -y conda + conda update -q -y --all fi From 9cc314e832c98685fb02c117276f1fe2c6792fab Mon Sep 17 00:00:00 2001 From: James Lamb Date: Thu, 17 Oct 2024 21:34:41 -0500 Subject: [PATCH 3/4] python packages now use 'cp' instead of 'cpython' --- .ci/setup.sh | 2 +- .ci/test-windows.ps1 | 4 ++-- .ci/test.sh | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.ci/setup.sh b/.ci/setup.sh index 8bb64342a89b..e551b1683aef 100755 --- a/.ci/setup.sh +++ b/.ci/setup.sh @@ -151,5 +151,5 @@ if [[ "${TASK}" != "r-package" ]] && [[ "${TASK}" != "r-rchk" ]]; then sh miniforge.sh -b -p "${CONDA}" fi conda config --set always_yes yes --set changeps1 no - conda update -q -y --all + conda update -q -y conda fi diff --git a/.ci/test-windows.ps1 b/.ci/test-windows.ps1 index a2c498531262..ff4ad8cdcd55 100644 --- a/.ci/test-windows.ps1 +++ b/.ci/test-windows.ps1 @@ -58,7 +58,7 @@ if ($env:TASK -eq "swig") { conda init powershell conda activate conda config --set always_yes yes --set changeps1 no -conda update -q -y conda "python=$env:PYTHON_VERSION[build=*cpython]" +conda update -q -y conda "python=$env:PYTHON_VERSION=*_cp*" if ($env:PYTHON_VERSION -eq "3.7") { $env:CONDA_REQUIREMENT_FILE = "$env:BUILD_SOURCESDIRECTORY/.ci/conda-envs/ci-core-py37.txt" @@ -72,7 +72,7 @@ conda create ` -y ` -n $env:CONDA_ENV ` --file $env:CONDA_REQUIREMENT_FILE ` - "python=$env:PYTHON_VERSION[build=*cpython]" ; Check-Output $? + "python=$env:PYTHON_VERSION=*_cp*" ; Check-Output $? if ($env:TASK -ne "bdist") { conda activate $env:CONDA_ENV diff --git a/.ci/test.sh b/.ci/test.sh index 4bf44140dbfd..038bd389c7f3 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -64,8 +64,9 @@ if [[ "$TASK" == "cpp-tests" ]]; then exit 0 fi -# including python=version[build=*cpython] to ensure that conda doesn't fall back to pypy -CONDA_PYTHON_REQUIREMENT="python=${PYTHON_VERSION}[build=*cpython]" +# including python=version=*_cp* to ensure that conda prefers CPython and doesn't fall back to +# other implementations like pypy +CONDA_PYTHON_REQUIREMENT="python=${PYTHON_VERSION}=*_cp*" if [[ $TASK == "if-else" ]]; then conda create -q -y -n "${CONDA_ENV}" "${CONDA_PYTHON_REQUIREMENT}" numpy From 76f2b8df058b343a25ff2b7e0040d388337017fd Mon Sep 17 00:00:00 2001 From: James Lamb Date: Thu, 17 Oct 2024 22:49:57 -0500 Subject: [PATCH 4/4] fix python_package --- .github/workflows/python_package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python_package.yml b/.github/workflows/python_package.yml index 0bd2ed3899a5..1963fb01237c 100644 --- a/.github/workflows/python_package.yml +++ b/.github/workflows/python_package.yml @@ -152,7 +152,7 @@ jobs: all-python-package-jobs-successful: if: always() runs-on: ubuntu-latest - needs: [test, test-latest-versions, test-oldest-versions] + needs: [test, test-latest-versions, test-old-versions] steps: - name: Note that all tests succeeded uses: re-actors/alls-green@v1.2.2