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

Migrate away from PythonInterp CMake module #1195

Open
wants to merge 1 commit into
base: noetic-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.12.0)

set(catkin_EXTRAS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

Expand Down
8 changes: 7 additions & 1 deletion cmake/python.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# the CMake variable PYTHON_INSTALL_DIR has the same value as the Python function catkin.builder.get_python_install_dir()

set(PYTHON_VERSION "$ENV{ROS_PYTHON_VERSION}" CACHE STRING "Specify specific Python version to use ('major.minor' or 'major')")
find_package(PythonInterp ${PYTHON_VERSION} REQUIRED)
find_package(Python ${PYTHON_VERSION} REQUIRED)

# Set these legacy variables for compatibility with what PythonInterp used to do
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's safe to just migrate to the new variable names— the ROS 1 codebase is pretty dependent on PYTHON_EXECUTABLE in particular existing, see for example the stuff around message generation:

Amusingly, dynamic_reconfigure does actually call find_package(PythonInterp), but does so after PYTHON_EXECUTABLE has already been used once already.

set(PYTHON_VERSION_MAJOR ${Python_VERSION_MAJOR})
set(PYTHON_VERSION_MINOR ${Python_VERSION_MINOR})
set(PYTHON_VERSION_PATCH ${Python_VERSION_PATCH})

message(STATUS "Using PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")

Expand Down