Commit 63c93565 authored by Marc Chevrier's avatar Marc Chevrier
Browse files

FindPython*: fix erroneous handling of virtual environments

fixes: #18408
parent 44de3428
......@@ -135,6 +135,12 @@ Hints
Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
.. note::
If a Python virtual environment is configured, set variable
``Python_FIND_REGISTRY`` (Windows) or ``CMAKE_FIND_FRAMEWORK`` (macOS) with
value ``LAST`` or ``NEVER`` to select it preferably.
Commands
^^^^^^^^
......
......@@ -355,20 +355,23 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
NAMES_PER_DIR
HINTS ${_${_PYTHON_PREFIX}_HINTS}
PATH_SUFFIXES bin
PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)
# try using standard paths.
# NAMES_PER_DIR is not defined on purpose to have a chance to find
# expected version.
# For example, typical systems have 'python' for version 2.* and 'python3'
# for version 3.*. So looking for names per dir will find, potentially,
# systematically 'python' (i.e. version 2) even if version 3 is searched.
find_program (${_PYTHON_PREFIX}_EXECUTABLE
NAMES python${_${_PYTHON_PREFIX}_VERSION}
python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
python
${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES})
if (WIN32)
find_program (${_PYTHON_PREFIX}_EXECUTABLE
NAMES python${_${_PYTHON_PREFIX}_VERSION}
python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
python
${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
NAMES_PER_DIR)
else()
find_program (${_PYTHON_PREFIX}_EXECUTABLE
NAMES python${_${_PYTHON_PREFIX}_VERSION}
python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
NAMES_PER_DIR)
endif()
# Apple frameworks handling
if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
......@@ -413,6 +416,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
python
${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
NAMES_PER_DIR
HINTS ${_${_PYTHON_PREFIX}_HINTS}
PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
NO_SYSTEM_ENVIRONMENT_PATH
......
......@@ -136,6 +136,12 @@ Hints
Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
.. note::
If a Python virtual environment is configured, set variable
``Python_FIND_REGISTRY`` (Windows) or ``CMAKE_FIND_FRAMEWORK`` (macOS) with
value ``LAST`` or ``NEVER`` to select it preferably.
Commands
^^^^^^^^
......
......@@ -136,6 +136,12 @@ Hints
Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
.. note::
If a Python virtual environment is configured, set variable
``Python_FIND_REGISTRY`` (Windows) or ``CMAKE_FIND_FRAMEWORK`` (macOS) with
value ``LAST`` or ``NEVER`` to select it preferably.
Commands
^^^^^^^^
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment