From 01e1a7144f66040b9de96ce946dcce31048dd87c Mon Sep 17 00:00:00 2001 From: Shenghang Tsai Date: Sat, 29 May 2021 01:57:49 +0800 Subject: [PATCH] Prevent CMake from using highest version of python3 (#5034) * Use conda python if available * refine * refine * refine Co-authored-by: oneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com> --- cmake/python.cmake | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmake/python.cmake b/cmake/python.cmake index 21d99a50be..720a95a8ac 100644 --- a/cmake/python.cmake +++ b/cmake/python.cmake @@ -1,3 +1,16 @@ +if (NOT DEFINED Python3_EXECUTABLE) + execute_process( + COMMAND which python3 + RESULT_VARIABLE STATUS + OUTPUT_VARIABLE OUTPUT + ERROR_QUIET + ) + if(STATUS EQUAL 0) + string(STRIP ${OUTPUT} STRIPPED) + message(STATUS "Using Python3 from 'which python3': ${STRIPPED}") + set(Python3_EXECUTABLE ${STRIPPED}) + endif() +endif() find_package(Python3 COMPONENTS Interpreter REQUIRED) message(STATUS "Python3 specified. Version found: " ${Python3_VERSION}) set(Python_EXECUTABLE ${Python3_EXECUTABLE}) -- GitLab