Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When finding Python3, use python3 executable as a hint #650

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions tf2_geometry_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
find_package(PythonExtra REQUIRED)
# Force FindPython3 to use the debug interpretter where ROS 2 expects it
set(Python3_EXECUTABLE "${PYTHON_EXECUTABLE_DEBUG}")
elseif(NOT WIN32 AND NOT Python3_EXECUTABLE)
# We expect that Python dependencies are met for whatever Python interpreter
# is invoked by the "python3" executable, however this may not be the latest
# Python version installed on the system. The default behavior of
# find_package(Python3) is to use the latest version (e.x. python3.12), so we
# specifically look for a "python3" executable and if found, instruct
# find_package(Python3) to use that.
# On Windows, the find_package(Python3) logic is different and doesn't
# appear to prefer specific versions (e.x. python3.12) over plain
# "python.exe" so this extra logic is unnecessary there.
find_program(Python3_EXECUTABLE python3)
endif()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)

Expand Down
11 changes: 11 additions & 0 deletions tf2_py/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
find_package(PythonExtra REQUIRED)
# Force FindPython3 to use the debug interpretter where ROS 2 expects it
set(Python3_EXECUTABLE "${PYTHON_EXECUTABLE_DEBUG}")
elseif(NOT WIN32 AND NOT Python3_EXECUTABLE)
# We expect that Python dependencies are met for whatever Python interpreter
# is invoked by the "python3" executable, however this may not be the latest
# Python version installed on the system. The default behavior of
# find_package(Python3) is to use the latest version (e.x. python3.12), so we
# specifically look for a "python3" executable and if found, instruct
# find_package(Python3) to use that.
# On Windows, the find_package(Python3) logic is different and doesn't
# appear to prefer specific versions (e.x. python3.12) over plain
# "python.exe" so this extra logic is unnecessary there.
find_program(Python3_EXECUTABLE python3)
endif()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)

Expand Down