Skip to content

Commit d783a4f

Browse files
committed
ENH: Python version exact match requested for range
When Python3_EXECUTABLE is specified, then the allowed range of versions that are searched for needs to exactly match that reported by Python3_EXECUTABLE. Could NOT find Python3: Found unsuitable version "3.11.13", required range is "3.11...3.11"
1 parent ac0bff8 commit d783a4f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

CMake/ITKSetPython3Vars.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ set(PYTHON_VERSION_MAX 3.999)
1212
if(DEFINED Python3_EXECUTABLE) # if already specified
1313
set(_specified_Python3_EXECUTABLE ${Python3_EXECUTABLE})
1414
# If a specific Python executable is provided, lock the Python version range
15-
# to the exact version of that executable so FindPython3 searches that version.
15+
# to the exact version down to the minor release of that executable so FindPython3 searches that version.
1616
execute_process(
1717
COMMAND
1818
"${_specified_Python3_EXECUTABLE}" -c
19-
"import sys; print('{}.{}'.format(sys.version_info[0], sys.version_info[1]))"
19+
"import sys; print('{}.{}.{}'.format(sys.version_info[0], sys.version_info[1], sys.version_info[2]))"
2020
OUTPUT_VARIABLE _specified_Python3_VERSION_MM
2121
ERROR_VARIABLE _specified_Python3_VERSION_MM_ERR
2222
OUTPUT_STRIP_TRAILING_WHITESPACE

0 commit comments

Comments
 (0)