laser_geometry icon indicating copy to clipboard operation
laser_geometry copied to clipboard

Stop using python_cmake_module.

Open clalancette opened this issue 1 year ago • 5 comments

We really don't need it anymore, and can just use the builtin find_package(Python3).

This must be merged before https://github.com/ros2/ros2/pull/1524 ; see that pull request for more information about this change.

clalancette avatar Feb 15 '24 22:02 clalancette

@clalancette thank you for doing this! It looks like this PR removes the usage of python_cmake_module but doesn't add find_package(Python3). Is that because that is handled by find_package(ament_cmake_pytest REQUIRED)?

jonbinney avatar Feb 16 '24 17:02 jonbinney

@clalancette thank you for doing this! It looks like this PR removes the usage of python_cmake_module but doesn't add find_package(Python3). Is that because that is handled by find_package(ament_cmake_pytest REQUIRED)?

That's a really good question. Most of the other places I did this already had separate calls to find_package(Python3), but this one didn't. I did run some preliminary CI on this, and that seemed to pass. But I'll take a closer look to see what is happening here.

clalancette avatar Feb 16 '24 17:02 clalancette

Ah, I see. So it turns out that deep in the bowels of ament_cmake_core, we do a find_package(Python3), which the rest of the CMakeLists.txt is inheriting. So that makes it work in my testing.

But it doesn't seem right to depend on that; theoretically, someday ament_cmake_core could remove it. I'll discuss with some others and see if we should add it to ament_cmake_install_python or something like that.

Relatedly, I realize that this package is missing a dependency on ament_cmake_python, so I'll add that as well.

clalancette avatar Feb 16 '24 17:02 clalancette

So we discussed this.

First, it is our feeling that downstream packages that just depend on ament_cmake_python should not have to call find_package(Python3) themselves, unless they directly reference it. Given that this package does not directly reference any of the Python3 things from CMake, this PR is correct as-is.

The other question had to do about whether we should explicitly do find_package(Python3) within ament_cmake_python. At the end of the day, we decided not to mess with what is working, and so we compromised and just added a comment in https://github.com/ament/ament_cmake/pull/510 that explains that we expect it to be there via ament_cmake_core.

So I think this PR is generally ready to go. It still needs CI run on it, and we'll almost certainly have to merge in https://github.com/ros2/ci/pull/755 first, but I think it is otherwise OK. @jonbinney let me know what you think.

clalancette avatar Feb 16 '24 19:02 clalancette

@clalancette that sounds good to me and this seems mergeable, but I realized this isn't actually one of the packages I maintain so @mabelzhang should make the call on merging.

jonbinney avatar Feb 16 '24 21:02 jonbinney