Skip to content

Commit fbf9365

Browse files
tejlmandhakehuang
authored andcommitted
cmake: now using find_package(python3) from CMake to located python3
Fixes: zephyrproject-rtos#23922, zephyrproject-rtos#24252, zephyrproject-rtos#11103 This commit switches to use the find_package(Python3) introduced with CMake 3.12. This removes the need for a Zephyr backport of Python detection module. The search order for Python3 is following CMake search order and can be controlled through CMake flags (See CMake documentation). Default it will use the Python version found in PATH. If multiple Python3 versions are found in PATH, the newest version will be selected (Can be controlled using `Python3_FIND_STRATEGY`) Using find_package(Python3) also ensures Python2.7 will never be selected, issue zephyrproject-rtos#11103, which was re-introduced in Zephyr. Signed-off-by: Torsten Rasmussen <[email protected]>
1 parent d77cfa2 commit fbf9365

File tree

2 files changed

+2
-187
lines changed

2 files changed

+2
-187
lines changed

cmake/backports/FindPythonInterp.cmake

Lines changed: 0 additions & 176 deletions
This file was deleted.

cmake/python.cmake

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,5 @@ if (WIN32)
99
set(ENV{PYTHONIOENCODING} "utf-8")
1010
endif()
1111

12-
# The 'FindPythonInterp' that is distributed with CMake 3.8 has a bug
13-
# that we need to work around until we upgrade to 3.13. Until then we
14-
# maintain a patched copy in our repo. Bug:
15-
# https://github.com/zephyrproject-rtos/zephyr/issues/11103
16-
set(PythonInterp_FIND_VERSION 3.6)
17-
set(PythonInterp_FIND_VERSION_COUNT 2)
18-
set(PythonInterp_FIND_VERSION_MAJOR 3)
19-
set(PythonInterp_FIND_VERSION_MINOR 6)
20-
set(PythonInterp_FIND_VERSION_EXACT 0)
21-
set(PythonInterp_FIND_REQUIRED 1)
22-
include(${ZEPHYR_BASE}/cmake/backports/FindPythonInterp.cmake)
12+
find_package(Python3 3.6 REQUIRED)
13+
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})

0 commit comments

Comments
 (0)