Skip to content

Commit

Permalink
cmake: now using find_package(python3) from CMake to located python3
Browse files Browse the repository at this point in the history
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 <Torsten.Rasmussen@nordicsemi.no>
  • Loading branch information
tejlmand authored and avisconti committed Apr 15, 2020
1 parent cc5365a commit 03ee38a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 187 deletions.
176 changes: 0 additions & 176 deletions cmake/backports/FindPythonInterp.cmake

This file was deleted.

13 changes: 2 additions & 11 deletions cmake/python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,5 @@ if (WIN32)
set(ENV{PYTHONIOENCODING} "utf-8")
endif()

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

0 comments on commit 03ee38a

Please sign in to comment.