Repository navigation
Remove python_cmake_module from ros2.repos. - #1524
Merged
Merged
Conversation
This was referenced Feb 15, 2024
Merged
|
Just wanted to say that if you have
This leads to a build failure on some ROS related packages even with this PR applied. BTW, my intention isn't using Python 3.12. I wan't to use 3.11, which is the system default. But CMake finds the latest development module. |
Contributor
Author
Yeah, there is just nothing we can do about that. That is a bug in the distribution. |
With all of the other changes that have gone in, the core no longer requires it. Signed-off-by: Chris Lalancette <[email protected]>
clalancette
force-pushed
the
clalancette/remove-python-cmake-module
branch
from
June 5, 2024 17:27
146d424 to
940b0e8
Compare
Contributor
Author
Contributor
Author
Contributor
Author
ahcorde
approved these changes
Sep 26, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR aims to remove
python_cmake_modulefrom the core ROS 2 repositories.The basic idea behind this is that
python_cmake_moduleis an unnecessary indirection tofind_package(Python3), which is a standard CMake feature. So we may as well remove it and save that additional layer of indirection.While we are doing this, we also notice that we can support venvs in ROS 2 much better by taking advantage of some newer features of
find_package(Python3). In particular, we can set CMP0094, which setsPython3_FIND_STRATEGYtoLOCATION. In short, this means thatfind_package(Python3)will stop searching after it finds the first python3 binary it can.However,
find_package(Python3), at least on Linux, will attempt to find the most specific version it can by default. That means that if bothpython3.11andpython3are on the PATH, it will by default choosepython3.11. We can also control that behavior by setting Python3_FIND_UNVERSIONED_NAMES toFIRST.The end result of all of this is that venvs on Linux should work properly, as long as the venv is activated. On Windows, due to different logic, this always worked properly. If all else fails, the user can always pass
--cmake-args -DPython3_EXECUTABLE=/path/to/python3, which will forcibly set the path to the python executable.Given the complexity of Python packaging, I don't expect it will fix all related problems, but it should improve many of our venv issues, like ros2/ros2cli#879 , ament/ament_cmake#502 , #1519 , #1094 , and #1430 .
Also note that this is not backportable to Humble, since it requires CMake 3.20 and Humble has to support CMake versions older than that. There we are using a simpler version of this, in ros2/geometry2#650 and ament/ament_cmake#507 . This might be backportable to Iron, but we'll have to see.
Note that this is a draft because we need to get all of the dependent PRs in first, and I still have to write up the documentation and CI code for this.