From cc2f22162ab9a9e7ff977010abac8f70972c9b6f Mon Sep 17 00:00:00 2001 From: Guilherme Amadio Date: Tue, 8 Nov 2022 17:12:34 +0100 Subject: [PATCH] [Python] Show install command and error out when pip install fails Issue: #1768 --- bindings/python/CMakeLists.txt | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index 0207a0bfa43..cf866f25e01 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -80,23 +80,25 @@ if ( NOT ${VALID_PIP_EXIT_CODE} EQUAL 0 ) set(DEB_INSTALL_ARGS "--install-layout ${PYTHON_LAYOUT}") endif() - install( - CODE - "EXECUTE_PROCESS( + install(CODE " + EXECUTE_PROCESS( + COMMAND_ECHO STDOUT RESULT_VARIABLE INSTALL_STATUS COMMAND /usr/bin/env ${XROOTD_PYBUILD_ENV} ${PYTHON_EXECUTABLE} ${SETUP_PY} install \ - --verbose \ - --prefix \$ENV{DESTDIR}/${CMAKE_INSTALL_PREFIX} \ - ${DEB_INSTALL_ARGS} - )" - ) - + --verbose --prefix \$ENV{DESTDIR}/${CMAKE_INSTALL_PREFIX} ${DEB_INSTALL_ARGS} + ) + if(NOT INSTALL_STATUS EQUAL 0) + message(FATAL_ERROR \"Failed to install Python bindings\") + endif() + ") else() - install( - CODE - "EXECUTE_PROCESS( + install(CODE " + EXECUTE_PROCESS( + COMMAND_ECHO STDOUT RESULT_VARIABLE INSTALL_STATUS COMMAND /usr/bin/env ${XROOTD_PYBUILD_ENV} ${PYTHON_EXECUTABLE} -m pip install \ - ${PIP_OPTIONS} \ - ${CMAKE_CURRENT_BINARY_DIR} - )" - ) + ${PIP_OPTIONS} ${CMAKE_CURRENT_BINARY_DIR} + ) + if(NOT INSTALL_STATUS EQUAL 0) + message(FATAL_ERROR \"Failed to install Python bindings\") + endif() + ") endif()