-
Notifications
You must be signed in to change notification settings - Fork 132
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
Conversation
The existing find_package(Python3) call will locate the Python interpreter with the latest version number. However, this may not be the system's default Python interpreter for which our dependencies have been installed. If Python3_EXECUTABLE is not explicitly specified, use find_program to locate the Python interpreter behind the "python3" command, which is likely the system's default and the one that we want. If no executable can be found by the name "python3", the find_program call will silently fail and the existing behavior will manifest. Signed-off-by: Scott K Logan <logans@cottsay.net>
I do not know how to fix this, but note that this may be problematic on Windows as on Windows official Python binaries and in conda python packages there is no python3 executable. That would be ok if there was no python3 executable in the system, but unfortunately that is not the case as there is a python3 executable installed by Windows itself that is just a shortcut that try to open the Windows store and install python, see python/cpython#99185 . I do not know if there is a smarter solution, but perhaps it could make sense to use this workaround only on platforms different from Windows? |
Thanks, @traversaro. It was pointed out in discussion that Windows used "python" and not "python3", but I hadn't thought about the python installer thing. We could make the Either way, I'll do some poking around tomorrow and see how CMake acts in the presence of the "python3" installer executable. |
Just to understand, did you considered as an alternative to |
I'm about to open a set of PRs to Unfortunately, there are 2 problems with it. The first is that But the second problem comes from that second hint. That hint is only available in CMake 3.20 plus, and humble needs to target earlier versions (including 3.16.3 on Ubuntu 20.04). So I think that going forward in |
Thanks, crystal clear! |
So I did some testing around this. First of all, if I open a command prompt and type Second, if I build Humble from current sources, I don't get any pop-up. This isn't surprising, but is the baseline. Third, if I put this PR and ros2/geometry2#650 , I can also build Humble with no problems, and with no pop-ups. So it seems like the pop-up doesn't happen when it is invoked via colcon/ament/cmake. If I print out the result of Given that, this leaves us with 3 possibilities:
My suggestion is 2. Thoughts? |
Regarding the Windows-debug CI.
|
Signed-off-by: Scott K Logan <logans@cottsay.net>
bc552d2
to
a219d07
Compare
@traversaro, we did some digging regarding the Windows Store python executables. I can hardly believe it, but It looks like there is explicit logic in CMake to ignore those Python executables during a call to We're concluding that the |
Co-authored-by: Chris Lalancette <clalancette@gmail.com> Signed-off-by: Scott K Logan <logans@cottsay.net>
Signed-off-by: Scott K Logan <logans@cottsay.net>
038d27c
to
31ab2b1
Compare
Should I take the part from #515 and dump it in the non-windows condition here on |
The call to That said, updating the minimum version is probably still a candidate for backport IMO. |
The existing find_package(Python3) call will locate the Python interpreter with the latest version number. However, this may not be the system's default Python interpreter for which our dependencies have been installed. If Python3_EXECUTABLE is not explicitly specified, use find_program to locate the Python interpreter behind the "python3" command, which is likely the system's default and the one that we want. If no executable can be found by the name "python3", the find_program call will silently fail and the existing behavior will manifest. Signed-off-by: Scott K Logan <logans@cottsay.net>
The existing find_package(Python3) call will locate the Python interpreter with the latest version number. However, this may not be the system's default Python interpreter for which our dependencies have been installed.
If Python3_EXECUTABLE is not explicitly specified, use find_program to locate the Python interpreter behind the "python3" command, which is likely the system's default and the one that we want.
If no executable can be found by the name "python3", the find_program call will silently fail and the existing behavior will manifest.