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

Use FindPython3 explicitly instead of FindPythonInterp implicitly #345

Merged
merged 1 commit into from
Aug 6, 2021
Merged
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
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.12)

project(rcutils)

@@ -16,6 +16,8 @@ include(CheckLibraryExists)
find_package(ament_cmake_python REQUIRED)
find_package(ament_cmake_ros REQUIRED)

find_package(Python3 REQUIRED COMPONENTS Interpreter)
Copy link
Contributor

Choose a reason for hiding this comment

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

So this is great that we are making this an explicit dependency in CMakeLists.txt.

I wonder if we should also make python3 an explicit build_depend/buildtool_depend in the package.xml. It will always implicitly get pulled in because of the buildtool_depend on python3-empy, but it is a little weird to find_package something that doesn't have an entry in the package.xml. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's reasonable to add python3 as the buildtool_depend. This is getting that for free from ament_cmake, so adding it to the package.xml fits the theme of being explicit. It seems unlikely to have an impact in the future as I imagine ament_cmake will always depend on Python.

it is a little weird to find_package something that doesn't have an entry in the package.xml

The FindPython3 module is provided by CMake, so this is find_packaging() is a module from CMake itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, that's a fair point. In that case, I don't feel strongly about whether we have a package.xml depends on python or not. I'm going to go ahead and approve this, and let you decide whether to add the depends.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll leave the package.xml as is for expediency.


ament_python_install_package(${PROJECT_NAME})

if(UNIX AND NOT APPLE)
@@ -102,7 +104,7 @@ em.invoke( \
string(REPLACE ";" "$<SEMICOLON>" python_code "${python_code}")
add_custom_command(OUTPUT include/rcutils/logging_macros.h
COMMAND ${CMAKE_COMMAND} -E make_directory "include/rcutils"
COMMAND ${PYTHON_EXECUTABLE} ARGS -c "${python_code}"
COMMAND Python3::Interpreter ARGS -c "${python_code}"
DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/logging_macros.h.em.watch"
"${CMAKE_CURRENT_BINARY_DIR}/logging.py.watch"