From 21911d4261e4bb73723f66ee0fddea829cb73d03 Mon Sep 17 00:00:00 2001 From: Mizux Seiha Date: Fri, 6 Oct 2023 00:43:20 +0200 Subject: [PATCH] python: Add python 3.12 support --- .github/workflows/amd64_linux_bazel.yml | 2 +- .github/workflows/amd64_macos_bazel.yml | 2 +- .../workflows/amd64_macos_cmake_python.yml | 2 +- .github/workflows/amd64_windows_bazel.yml | 2 +- ortools/python/setup.py.in | 1 + tools/release/build_delivery_macos.sh | 4 +-- tools/release/build_delivery_win.cmd | 4 +-- tools/release/test_delivery_macos.sh | 4 +-- tools/release/test_delivery_win.cmd | 33 +++++++++++++++++++ 9 files changed, 44 insertions(+), 10 deletions(-) diff --git a/.github/workflows/amd64_linux_bazel.yml b/.github/workflows/amd64_linux_bazel.yml index c01257d85e..ff833c6de6 100644 --- a/.github/workflows/amd64_linux_bazel.yml +++ b/.github/workflows/amd64_linux_bazel.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11', '3.12'] fail-fast: false env: CC: gcc-12 diff --git a/.github/workflows/amd64_macos_bazel.yml b/.github/workflows/amd64_macos_bazel.yml index 8462b8c2f5..8836fb9e0a 100644 --- a/.github/workflows/amd64_macos_bazel.yml +++ b/.github/workflows/amd64_macos_bazel.yml @@ -9,7 +9,7 @@ jobs: runs-on: macos-latest strategy: matrix: - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11', '3.12'] fail-fast: false steps: - name: Check out repository code diff --git a/.github/workflows/amd64_macos_cmake_python.yml b/.github/workflows/amd64_macos_cmake_python.yml index 38416f0270..441e4c765b 100644 --- a/.github/workflows/amd64_macos_cmake_python.yml +++ b/.github/workflows/amd64_macos_cmake_python.yml @@ -26,7 +26,7 @@ jobs: - name: Check swig run: swig -version - name: Update Path - run: echo "$HOME/Library/Python/3.11/bin" >> $GITHUB_PATH + run: echo "$HOME/Library/Python/3.12/bin" >> $GITHUB_PATH - name: Check cmake run: cmake --version - name: Configure diff --git a/.github/workflows/amd64_windows_bazel.yml b/.github/workflows/amd64_windows_bazel.yml index 1d4a6f5ed5..bcae3645cb 100644 --- a/.github/workflows/amd64_windows_bazel.yml +++ b/.github/workflows/amd64_windows_bazel.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: runner: [windows-2022, windows-2019] - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11', '3.12'] fail-fast: false # Don't cancel all jobs if one fails. runs-on: ${{ matrix.runner }} #runs-on: windows-latest diff --git a/ortools/python/setup.py.in b/ortools/python/setup.py.in index b80cee0c1c..05a0b056eb 100644 --- a/ortools/python/setup.py.in +++ b/ortools/python/setup.py.in @@ -102,6 +102,7 @@ setup( 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Programming Language :: C++', 'Programming Language :: Python :: Implementation :: CPython', 'Topic :: Office/Business :: Scheduling', diff --git a/tools/release/build_delivery_macos.sh b/tools/release/build_delivery_macos.sh index 0f20256de8..eeef039657 100755 --- a/tools/release/build_delivery_macos.sh +++ b/tools/release/build_delivery_macos.sh @@ -212,9 +212,9 @@ function build_python() { command -v swig | xargs echo "swig: " | tee -a build.log if [[ ${PLATFORM} == "arm64" ]]; then - local -r PY=(3.8 3.9 3.10 3.11) + local -r PY=(3.8 3.9 3.10 3.11 3.12) else - local -r PY=(3.8 3.9 3.10 3.11) + local -r PY=(3.8 3.9 3.10 3.11 3.12) fi for PY_VERSION in "${PY[@]}"; do diff --git a/tools/release/build_delivery_win.cmd b/tools/release/build_delivery_win.cmd index e8c66af9cd..044e31e232 100644 --- a/tools/release/build_delivery_win.cmd +++ b/tools/release/build_delivery_win.cmd @@ -272,7 +272,7 @@ echo Python build seems up to date, skipping exit /B 0 ) -for %%v in (8 9 10 11) do ( +for %%v in (8 9 10 11 12) do ( title Build Python 3.%%v :: Check Python which.exe C:\python3%%v-64\python.exe || exit 1 @@ -312,7 +312,7 @@ del /s /f /q temp_dotnet rmdir /s /q temp_dotnet del /s /f /q temp_java rmdir /s /q temp_java -for %%v in (8 9 10 11) do ( +for %%v in (8 9 10 11 12) do ( del /s /f /q temp_python3%%v rmdir /s /q temp_python3%%v ) diff --git a/tools/release/test_delivery_macos.sh b/tools/release/test_delivery_macos.sh index bd5fc4b85c..ad2a069b0a 100755 --- a/tools/release/test_delivery_macos.sh +++ b/tools/release/test_delivery_macos.sh @@ -23,9 +23,9 @@ command -v make | xargs echo "make: " | tee -a test.log command -v swig | xargs echo "swig: " | tee -a test.log # python if [[ ${PLATFORM} == "arm64" ]]; then - local -r PY=(3.8 3.9 3.10 3.11) + local -r PY=(3.8 3.9 3.10 3.11 3.12) else - local -r PY=(3.8 3.9 3.10 3.11) + local -r PY=(3.8 3.9 3.10 3.11 3.12) fi for i in "${PY[@]}"; do diff --git a/tools/release/test_delivery_win.cmd b/tools/release/test_delivery_win.cmd index 5fdf51b219..0e3fd13ab1 100755 --- a/tools/release/test_delivery_win.cmd +++ b/tools/release/test_delivery_win.cmd @@ -153,3 +153,36 @@ echo Testing ortools Python3.11... | tee.exe -a test.log echo Testing ortools Python3.11...DONE | tee.exe -a test.log FOR %%i IN (%TEMP_DIR%\ortools\dist\*.whl) DO copy %%i . + +REM ################### +REM ## PYTHON 3.12 ## +REM ################### +echo Cleaning Python... | tee.exe -a test.log +make.exe clean_python WINDOWS_PATH_TO_PYTHON=c:\python312-64 +echo Cleaning Python...DONE | tee.exe -a test.log + +REM make.exe python WINDOWS_PATH_TO_PYTHON=c:\python312-64 || exit 1 +REM echo make python3.12: DONE | tee.exe -a build.log +REM make.exe test_python WINDOWS_PATH_TO_PYTHON=c:\python312-64 || exit 1 +REM echo make test_python3.12: DONE | tee.exe -a build.log +echo Rebuild Python3.12 pypi archive... | tee.exe -a test.log +make.exe package_python WINDOWS_PATH_TO_PYTHON=c:\python312-64 || exit 1 +echo Rebuild Python3.12 pypi archive...DONE | tee.exe -a test.log + +echo Creating Python3.12 venv... | tee.exe -a test.log +set PATH=c:\python312-64;c:\python312-64\Scripts;%PATH% +python -m pip install virtualenv +set TEMP_DIR=temp_python312 +python -m virtualenv %TEMP_DIR%\venv +set PATH=%LOCAL_PATH% +echo Creating Python3.12 venv...DONE | tee.exe -a test.log + +echo Installing ortools Python3.12 venv... | tee.exe -a test.log +FOR %%i IN (%TEMP_DIR%\ortools\dist\*.whl) DO %TEMP_DIR%\venv\Scripts\python -m pip install %%i +echo Installing ortools Python3.12 venv...DONE | tee.exe -a test.log + +echo Testing ortools Python3.12... | tee.exe -a test.log +%TEMP_DIR%\venv\Scripts\python cmake\samples\python\sample.py 2>&1 | tee.exe -a test.log +echo Testing ortools Python3.12...DONE | tee.exe -a test.log + +FOR %%i IN (%TEMP_DIR%\ortools\dist\*.whl) DO copy %%i .