-
Notifications
You must be signed in to change notification settings - Fork 130
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
Various improvements to ament_python_install_package
#372
base: rolling
Are you sure you want to change the base?
Changes from 5 commits
d6c749a
a786aa2
321105d
fe6b3a3
d29798e
cc7ad4e
30db879
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -29,7 +29,7 @@ | |||||||||||||||||||||||
# directory (default: PYTHON_INSTALL_DIR) | ||||||||||||||||||||||||
# :type DESTINATION: string | ||||||||||||||||||||||||
# :param SCRIPTS_DESTINATION: the path to the Python package scripts' | ||||||||||||||||||||||||
# installation directory, scripts (if any) will be ignored if not set | ||||||||||||||||||||||||
# installation directory (default: lib/${PROJECT_NAME}) | ||||||||||||||||||||||||
# :type SCRIPTS_DESTINATION: string | ||||||||||||||||||||||||
# :param SKIP_COMPILE: if set do not byte-compile the installed package | ||||||||||||||||||||||||
# :type SKIP_COMPILE: option | ||||||||||||||||||||||||
|
@@ -41,7 +41,7 @@ endmacro() | |||||||||||||||||||||||
|
||||||||||||||||||||||||
function(_ament_cmake_python_install_package package_name) | ||||||||||||||||||||||||
cmake_parse_arguments( | ||||||||||||||||||||||||
ARG "SKIP_COMPILE" "PACKAGE_DIR;VERSION;SETUP_CFG;DESTINATION;SCRIPTS_DESTINATION" "" ${ARGN}) | ||||||||||||||||||||||||
ARG "SKIP_COMPILE" "PACKAGE_DIR;VERSION;SETUP_CFG;DESTINATION" "SCRIPTS_DESTINATION" ${ARGN}) | ||||||||||||||||||||||||
if(ARG_UNPARSED_ARGUMENTS) | ||||||||||||||||||||||||
message(FATAL_ERROR "ament_python_install_package() called with unused " | ||||||||||||||||||||||||
"arguments: ${ARG_UNPARSED_ARGUMENTS}") | ||||||||||||||||||||||||
|
@@ -83,6 +83,10 @@ function(_ament_cmake_python_install_package package_name) | |||||||||||||||||||||||
set(ARG_DESTINATION ${PYTHON_INSTALL_DIR}) | ||||||||||||||||||||||||
endif() | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if(NOT ARG_SCRIPTS_DESTINATION) | ||||||||||||||||||||||||
set(ARG_SCRIPTS_DESTINATION "lib/${PROJECT_NAME}") | ||||||||||||||||||||||||
endif() | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/ament_cmake_python/${package_name}") | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
string(CONFIGURE "\ | ||||||||||||||||||||||||
|
@@ -156,28 +160,18 @@ setup( | |||||||||||||||||||||||
DESTINATION "${ARG_DESTINATION}/${egg_install_name}.egg-info" | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if(ARG_SCRIPTS_DESTINATION) | ||||||||||||||||||||||||
file(MAKE_DIRECTORY "${build_dir}/scripts") # setup.py may or may not create it | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
add_custom_target( | ||||||||||||||||||||||||
ament_cmake_python_build_${package_name}_scripts ALL | ||||||||||||||||||||||||
COMMAND ${python_interpreter} setup.py install_scripts -d scripts | ||||||||||||||||||||||||
WORKING_DIRECTORY "${build_dir}" | ||||||||||||||||||||||||
DEPENDS ${egg_dependencies} | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if(NOT AMENT_CMAKE_SYMLINK_INSTALL) | ||||||||||||||||||||||||
# Not needed for nor supported by symlink installs | ||||||||||||||||||||||||
set(_extra_install_args USE_SOURCE_PERMISSIONS) | ||||||||||||||||||||||||
endif() | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
install( | ||||||||||||||||||||||||
DIRECTORY "${build_dir}/scripts/" | ||||||||||||||||||||||||
DESTINATION "${ARG_SCRIPTS_DESTINATION}/" | ||||||||||||||||||||||||
${_extra_install_args} | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
if(POLICY CMP0087) | ||||||||||||||||||||||||
# Allow generator expressions in install(CODE...) | ||||||||||||||||||||||||
cmake_policy(SET CMP0087 NEW) | ||||||||||||||||||||||||
endif() | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
# generate/install entry-point console scripts | ||||||||||||||||||||||||
foreach(_dest ${ARG_SCRIPTS_DESTINATION}) | ||||||||||||||||||||||||
get_filename_component(ABS_SCRIPTS_DESTINATION "${_dest}" ABSOLUTE BASE_DIR "${CMAKE_INSTALL_PREFIX}") | ||||||||||||||||||||||||
install(CODE "execute_process(COMMAND ${python_interpreter} setup.py install_scripts --install-dir \"${ABS_SCRIPTS_DESTINATION}\" | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The
A workaround to make the get_executable_path(python_interpreter_config Python3::Interpreter CONFIGURE)
# ...
install(CODE "execute_process(COMMAND ${python_interpreter} setup.py ...
The same workaround is already used a little lower in the file ament_cmake/ament_cmake_python/cmake/ament_python_install_package.cmake Lines 189 to 197 in 2bf27ce
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks a lot for this valuable hint. I adapted the code accordingly - sorry for the long delay. |
||||||||||||||||||||||||
WORKING_DIRECTORY \"${build_dir}\")") | ||||||||||||||||||||||||
endforeach() | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
install( | ||||||||||||||||||||||||
DIRECTORY "${ARG_PACKAGE_DIR}/" | ||||||||||||||||||||||||
DESTINATION "${ARG_DESTINATION}/${package_name}" | ||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhaschke which generator expressions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use generator expressions, but cmake complains about the unset CMP otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning is even reported by CI: https://ci.ros2.org/job/ci_linux/16094/cmake/NORMAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I wonder if a generator expression is introduced by
build_dir
. Anyways, we need to cap that warning.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's what I did. How do you trigger Full CI on this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using our
ci_launcher
with a customros2.repos
file (see https://ci.ros2.org/job/ci_launcher/9781).What's funny is that I run CI yesterday and there have not been changes to this PR in weeks. Maybe fe6b3a3 was not enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really puzzled. Indeed, the previous builds didn't show the warning - although
install(CODE ...)
was already used:ament_cmake/ament_cmake_python/cmake/ament_python_install_package.cmake
Lines 190 to 191 in 3fc4db9
However, locally, the suggested change exactly silences the warning for me. I have no clue, why it fails on CI.
My suggestion is to drop it and retry.