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

Conversation

mikepurvis
Copy link
Member

Without this change, every catkin package built spams this into the log:

CMake Warning (dev) at /home/mikepurvis/roslib_ws/install/share/catkin/cmake/python.cmake:4 (find_package):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
  /home/mikepurvis/roslib_ws/install/share/catkin/cmake/all.cmake:164 (include)
  /home/mikepurvis/roslib_ws/install/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:3 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

The new policy for CMake 3.27 is: https://cmake.org/cmake/help/latest/policy/CMP0148.html

The replacement FindPython module has been available since CMake 3.12, released in 2.18: https://cmake.org/cmake/help/latest/module/FindPython.html

ROS Noetic's stated minimum target is the CMake on Debian Buster, which is 3.13.4: https://www.ros.org/reps/rep-0003.html#noetic-ninjemys-may-2020-may-2025

@mikepurvis mikepurvis force-pushed the cmake-3.27-friendly branch from 71c2816 to 93deae8 Compare April 10, 2024 18:25
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.

@rhaschke
Copy link
Contributor

Doesn't this formally requires all packages to declare a minimum required cmake version of 3.12?
Most existing Noetic packages declare 3.0.2.

rhaschke pushed a commit to ros-o/catkin that referenced this pull request Nov 21, 2024
Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

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

With this PR I run into issues with pybind11: pybind/pybind11#5472
For this reason, I will revert the corresponding commit for ROS-O.

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the docs, you should specify both components, Interpreter and Development:

Suggested change
find_package(Python ${PYTHON_VERSION} REQUIRED)
find_package(Python ${PYTHON_VERSION} REQUIRED COMPONENTS Interpreter Development)

rhaschke added a commit to ros-o/catkin that referenced this pull request Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants