From 7875b3d7c2a10d28834684cafa6ebc066882611d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=86=8A=E6=94=80?= Date: Tue, 28 Oct 2025 10:59:21 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8Dpython3.12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmake/external_libs/pybind11.cmake | 20 +++++++++++++++++-- mindspore-lite/tools/converter/CMakeLists.txt | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/cmake/external_libs/pybind11.cmake b/cmake/external_libs/pybind11.cmake index e52de81fd..7c7d5e1a2 100644 --- a/cmake/external_libs/pybind11.cmake +++ b/cmake/external_libs/pybind11.cmake @@ -31,8 +31,18 @@ if(ENABLE_GITEE OR ENABLE_GITEE_EULER) # Channel GITEE_EULER is NOT supported no # Refer to: https://github.com/pybind/pybind11/pull/2701 # And: https://pybind11.readthedocs.io/en/stable/changelog.html#v2-6-2-jan-26-2021 set(PYBIND11_PATCH_FILE "pybind11.patch002") + elseif(PYTHON_VERSION MATCHES "3.12") + set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.13.1.tar.gz") + set(SHA256 "2200dda5c64ece586f537af8fd292103a3042cb40c443dde1b70fd1e419d8cb0") + set(PYBIND_VERSION 2.13.1) + set(PYBIND_DISABLE_GIL_CHECK TRUE) + # This patch reverts a PR introduced in pybind 2.6.2, as it causes many runtime exceptions in mindspore + # due to the type checking introduced in this PR. + # Refer to: https://github.com/pybind/pybind11/pull/2701 + # And: https://pybind11.readthedocs.io/en/stable/changelog.html#v2-6-2-jan-26-2021 + set(PYBIND11_PATCH_FILE "pybind11.patch002") else() - message("Could not find Python versions 3.7 - 3.11") + message("Could not find Python versions 3.7 - 3.12") return() endif() else() @@ -60,8 +70,14 @@ else() set(PYBIND_VERSION 2.13.1) set(PYBIND_DISABLE_GIL_CHECK TRUE) set(PYBIND11_PATCH_FILE "pybind11.patch002") + elseif(PYTHON_VERSION MATCHES "3.12") + set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.13.1.tar.gz") + set(SHA256 "51631e88960a8856f9c497027f55c9f2f9115cafb08c0005439838a05ba17bfc") + set(PYBIND_VERSION 2.13.1) + set(PYBIND_DISABLE_GIL_CHECK TRUE) + set(PYBIND11_PATCH_FILE "pybind11.patch002") else() - message("Could not find Python versions 3.7 - 3.11") + message("Could not find Python versions 3.7 - 3.12") return() endif() endif() diff --git a/mindspore-lite/tools/converter/CMakeLists.txt b/mindspore-lite/tools/converter/CMakeLists.txt index 8594bcc63..449af1e5a 100644 --- a/mindspore-lite/tools/converter/CMakeLists.txt +++ b/mindspore-lite/tools/converter/CMakeLists.txt @@ -415,7 +415,7 @@ target_link_libraries(mindspore_converter coder_mid mindir_serializer_mid ) -if(PYTHON_VERSION MATCHES "3.11") +if(PYTHON_VERSION MATCHES "3.11" OR PYTHON_VERSION MATCHES "3.12") target_link_libraries(mindspore_converter ${PYTHON_LIBRARIES}) endif() -- Gitee