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

Fix handling of multiple namespaced python packages in devel space #1153

Open
wants to merge 2 commits into
base: noetic-devel
Choose a base branch
from
Open
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
14 changes: 10 additions & 4 deletions cmake/catkin_python_setup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,17 @@ function(catkin_python_setup)
if(NOT ("${pkg}" STREQUAL "${name}"))
message(FATAL_ERROR "The package name '${pkg}' differs from the basename of the path '${pkg_dir}' in project '${PROJECT_NAME}'")
endif()
# Retrieve PACKAGE_PYTHONPATH from existing __init__.py
set(target_init_file ${CATKIN_DEVEL_PREFIX}/${PYTHON_INSTALL_DIR}/${pkg}/__init__.py)
if(EXISTS ${target_init_file})
file(READ ${target_init_file} file_content)
string(REGEX MATCH "__extended_path *= *'(.*)'\\.split" _ "${file_content}")
set(PACKAGE_PYTHONPATH ${CMAKE_MATCH_1})
endif()
# Extend PACKAGE_PYTHONPATH with current pkg's path
get_filename_component(path ${pkg_dir} PATH)
set(PACKAGE_PYTHONPATH ${CMAKE_CURRENT_SOURCE_DIR}/${path})
configure_file(${catkin_EXTRAS_DIR}/templates/__init__.py.in
${CATKIN_DEVEL_PREFIX}/${PYTHON_INSTALL_DIR}/${pkg}/__init__.py
@ONLY)
list_append_deduplicate(PACKAGE_PYTHONPATH ${CMAKE_CURRENT_SOURCE_DIR}/${path})
configure_file(${catkin_EXTRAS_DIR}/templates/__init__.py.in ${target_init_file} @ONLY)
endforeach()
endif()

Expand Down