Skip to content

Escape $ENV{DESTDIR} everywhere in ament_python_install_package()#324

Merged
clalancette merged 1 commit intomasterfrom
hidmic/missing-escape
Feb 26, 2021
Merged

Escape $ENV{DESTDIR} everywhere in ament_python_install_package()#324
clalancette merged 1 commit intomasterfrom
hidmic/missing-escape

Conversation

@hidmic
Copy link
Copy Markdown

@hidmic hidmic commented Feb 26, 2021

Follow up after #323. Massive 🤦

Follow up after f80071e

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic
Copy link
Copy Markdown
Author

hidmic commented Feb 26, 2021

Running CI up to ament_cmake_python (which exercises itself) only, as no CI job will really test this:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Applying this change to Rolling debian sources and running debuild locally works.

@hidmic hidmic added the bug Something isn't working label Feb 26, 2021
Comment on lines 141 to 147
install(CODE
"set(extra_install_args ${extra_install_args})
set(install_dir \"${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_DIR}\")
if(DEFINED ENV{DESTDIR} AND NOT \"$ENV{DESTDIR}\" STREQUAL \"\")
if(DEFINED ENV{DESTDIR} AND NOT \"\$ENV{DESTDIR}\" STREQUAL \"\")
list(APPEND extra_install_args --root \$ENV{DESTDIR})
file(TO_CMAKE_PATH \"\$ENV{DESTDIR}/\${install_dir}\" install_dir)
endif()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So just to make sure I understand what is going on here:

According to the install documentation, this form of install invokes the given CMake code during installation. Because of that, any cmake variables that you want expanded at install time need to be escaped. In this code snippet (and below) we are expecting that extra_install_args, CMAKE_INSTALL_PREFIX, PYTHON_INSTALL_DIR, package_name, PYTHON_EXECUTABLE, and build_dir are expanded at ament_python_install_package.cmake invocation time. We are expecting ENV{DESTDIR}, install_dir, and install_prefix to be expanded at install time. Is that correct?

Copy link
Copy Markdown
Author

@hidmic hidmic Feb 26, 2021

Choose a reason for hiding this comment

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

Exactly. Well, almost. There's scripts_install_dir and another extra_install_args being expanded at install time. The latter is perhaps a bit annoying, I'm not super creative with variable names.

Without this extra escape, one $ENV{DESTDIR} was resolved in CMake configuration time to nothing, which resulted in no --root given to python setup.py

@hidmic
Copy link
Copy Markdown
Author

hidmic commented Feb 26, 2021

CI's green, this is ready to roll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants