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

cmake function of rosidl_adapter fails if is not defined the PYTHONPATH #847

Open
lepalom opened this issue Dec 11, 2024 · 0 comments
Open
Assignees

Comments

@lepalom
Copy link

lepalom commented Dec 11, 2024

Bug report

  • Operating System:
    Debian Bookworm

  • Installation type:
    Source

  • Version or commit hash:
    4.6.4

  • DDS implementation:
    Not applied

  • Client library (if applicable):
    Not applied

I'm trying to build the complete ROS Jazzy for Debian creating the deb packages. I'm using the base of the packages in Debian made by Debian Robotics Team, backported to bookworm.

I'm blocked building builtin_interfaces. Why? Because in the configure step, CMake gives this error:

-- Found rosidl_adapter: 4.6.4 (/opt/ros/jazzy/share/rosidl_adapter/cmake)
CMake Error at /opt/ros/jazzy/share/rosidl_adapter/cmake/rosidl_adapt_interfaces.cmake:57 (message):
  execute_process(/usr/bin/python3 -m rosidl_adapter --package-name
  builtin_interfaces --arguments-file
  /<<PKGBUILDDIR>>/.obj-x86_64-linux-gnu/rosidl_adapter__arguments__builtin_interfaces.json
  --output-dir
  /<<PKGBUILDDIR>>/.obj-x86_64-linux-gnu/rosidl_adapter/builtin_interfaces
  --output-file
  /<<PKGBUILDDIR>>/.obj-x86_64-linux-gnu/rosidl_adapter/builtin_interfaces.idls)
  returned error code 1:

  /usr/bin/python3: No module named rosidl_adapter

Call Stack (most recent call first):
  /opt/ros/jazzy/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:132 (rosidl_adapt_interfaces)
  CMakeLists.txt:19 (rosidl_generate_interfaces)

builtin-interface calls in CMakefile

# Depend on "core" generators instead of "default" generators
# because ROS actions depend on this package
find_package(rosidl_core_generators REQUIRED)

Then, rosidl_core_generators load rosidl_cmake-extras.cmake that has:

find_package(rosidl_adapter)  # not required, being used when available

rosidl_adapter has rosidl_adapt_interfaces.cmake that has:

function(rosidl_adapt_interfaces idl_var arguments_file)
  cmake_parse_arguments(ARG "" "TARGET" ""
    ${ARGN})
  if(ARG_UNPARSED_ARGUMENTS)
    message(FATAL_ERROR "rosidl_adapt_interfaces() called with unused "
      "arguments: ${ARG_UNPARSED_ARGUMENTS}")
  endif()

  find_package(Python3 REQUIRED COMPONENTS Interpreter)

  set(idl_output "${CMAKE_CURRENT_BINARY_DIR}/rosidl_adapter/${ARG_TARGET}.idls")
  set(cmd
    "${Python3_EXECUTABLE}" -m rosidl_adapter
    --package-name ${PROJECT_NAME}
    --arguments-file "${arguments_file}"
    --output-dir "${CMAKE_CURRENT_BINARY_DIR}/rosidl_adapter/${PROJECT_NAME}"
    --output-file "${idl_output}")
  execute_process(
    COMMAND ${cmd}
    OUTPUT_QUIET
    ERROR_VARIABLE error
    RESULT_VARIABLE result
  )

this function fails if rosidl_adapter is not in the PYTHONPATH.

In general it doesn't fails because we call this function with source /opt/ros/..... When we create a deb package, bloom insert in the rules:

override_dh_auto_configure:
        # In case we're installing to a non-standard location, look for a setup.sh
        # in the install tree and source it.  It will set things like
        # CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
        if [ -f "/opt/ros/jazzy/setup.sh" ]; then . "/opt/ros/jazzy/setup.sh"; fi && \
        dh_auto_configure -- \
                -DCMAKE_INSTALL_PREFIX="/opt/ros/jazzy" \
                -DAMENT_PREFIX_PATH="/opt/ros/jazzy" \
                -DCMAKE_PREFIX_PATH="/opt/ros/jazzy" \
                $(BUILD_TESTING_ARG)

However, building a package for debian with sbuild, we use a strict clean environment and /opt/ros/jazzy/setup.share not there, because they are not necessary.

If, I create a clean chroot replicating the same as sbuild and I make:
source /opt/ros/jazzy/share/rosidl_adapter/local_setup.bash

it builds without any problem.

So, any idea of how to patch this code to make it work?

@cottsay cottsay self-assigned this 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

No branches or pull requests

2 participants