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 #507

Merged
merged 4 commits into from Feb 16, 2024
Merged
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
12 changes: 12 additions & 0 deletions ament_cmake_core/cmake/core/python.cmake
Expand Up @@ -18,5 +18,17 @@
# find_package(Python3 3.8 REQUIRED)
# find_package(ament_cmake REQUIRED)
if(NOT TARGET Python3::Interpreter)
# 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.
if(NOT WIN32 AND NOT Python3_EXECUTABLE)
find_program(Python3_EXECUTABLE python3)
endif()
find_package(Python3 REQUIRED COMPONENTS Interpreter)
endif()