Skip to content

Commit

Permalink
ENH: Specify minimum allowed python version
Browse files Browse the repository at this point in the history
When searching for python installation, ensure that a supported
version is found.
  • Loading branch information
hjmjohnson authored and dzenanz committed Aug 21, 2022
1 parent 278129b commit 211c66d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions CMake/ITKSetPython3Vars.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@
# implementation gives preference to active virtualenvs.

cmake_policy(SET CMP0094 NEW) # makes FindPython3 prefer activated virtualenv Python to latest version
set(PYTHON_REQUIRED_VERSION 3.7)
set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7)
if(PYTHON_DEVELOPMENT_REQUIRED)
if(DEFINED Python3_EXECUTABLE) # if already specified
set(_specified_Python3_EXECUTABLE ${Python3_EXECUTABLE})
endif()
# set(Python3_FIND_REGISTRY LAST) # default is FIRST. Do we need/want this?
find_package(Python3 COMPONENTS Interpreter Development)
find_package(Python3 ${PYTHON_REQUIRED_VERSION} COMPONENTS Interpreter Development)
if(DEFINED _specified_Python3_EXECUTABLE)
set(Python3_EXECUTABLE ${_specified_Python3_EXECUTABLE} CACHE INTERNAL
"Path to the Python interpreter" FORCE)
endif()
else() # if not PYTHON_DEVELOPMENT_REQUIRED, just find some version of Python (don't need to be as specific)
find_package(Python3 COMPONENTS Interpreter)
find_package(Python3 ${PYTHON_REQUIRED_VERSION} COMPONENTS Interpreter)
endif()
if(ITK_WRAP_PYTHON)
set(ITK_WRAP_PYTHON_VERSION "${Python3_VERSION}")
Expand Down

0 comments on commit 211c66d

Please sign in to comment.