From efde078b944e1865ea9e53e68726c48c5cf2d2e7 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 24 Jun 2020 14:05:17 -0500 Subject: [PATCH] pure CMake script to install Python wrapper after compiling --- cmake/GtsamCythonWrap.cmake | 15 --------------- cython/CMakeLists.txt | 3 ++- cython/scripts/install.bat | 18 ------------------ cython/scripts/install.sh | 30 ------------------------------ 4 files changed, 2 insertions(+), 64 deletions(-) delete mode 100755 cython/scripts/install.bat delete mode 100755 cython/scripts/install.sh diff --git a/cmake/GtsamCythonWrap.cmake b/cmake/GtsamCythonWrap.cmake index 4cd061852..6331d1e95 100644 --- a/cmake/GtsamCythonWrap.cmake +++ b/cmake/GtsamCythonWrap.cmake @@ -278,18 +278,3 @@ function(install_cython_files source_files dest_directory) endif() endfunction() - -function(install_python_package install_path) - # Select the correct install script based on the OS - if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - set(PYTHON_INSTALL_SCRIPT "install.bat") - elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set(PYTHON_INSTALL_SCRIPT "install.sh") - endif() - - # Configure the variables in the script - configure_file(${PROJECT_SOURCE_DIR}/cython/scripts/${PYTHON_INSTALL_SCRIPT} ${PROJECT_BINARY_DIR}/cython/scripts/${PYTHON_INSTALL_SCRIPT}) - - # Add the new make target command - add_custom_target(python-install "${PROJECT_BINARY_DIR}/cython/scripts/${PYTHON_INSTALL_SCRIPT}") -endfunction() diff --git a/cython/CMakeLists.txt b/cython/CMakeLists.txt index 96503b82f..bce9f2308 100644 --- a/cython/CMakeLists.txt +++ b/cython/CMakeLists.txt @@ -45,6 +45,7 @@ if (GTSAM_INSTALL_CYTHON_TOOLBOX) install_cython_scripts("${PROJECT_SOURCE_DIR}/cython/gtsam" "${GTSAM_CYTHON_INSTALL_PATH}" "*.py") install_cython_scripts("${PROJECT_SOURCE_DIR}/cython/gtsam_unstable" "${GTSAM_CYTHON_INSTALL_PATH}" "*.py") - install_python_package("${GTSAM_CYTHON_INSTALL_PATH}") + # Add the new make target command + add_custom_target(python-install COMMAND ${PYTHON_EXECUTABLE} ${GTSAM_CYTHON_INSTALL_PATH}${GTSAM_BUILD_TAG}/setup.py install) endif () diff --git a/cython/scripts/install.bat b/cython/scripts/install.bat deleted file mode 100755 index 4dbd2051f..000000000 --- a/cython/scripts/install.bat +++ /dev/null @@ -1,18 +0,0 @@ -:: This script runs the installation flow for python wrapped GTSAM. -:: It does so by running `python setup.py install` to install the wrapped package. - -echo "Installing GTSAM Python Wrapper" - -:: Set the package path -PACKAGE_PATH=${GTSAM_CYTHON_INSTALL_PATH}${GTSAM_BUILD_TAG} - -:: Check if package directory exists. If not, print warning and exit. -if [ ! -d "$PACKAGE_PATH" ] -then - echo "Directory $PACKAGE_PATH DOES NOT exist. Please run 'make install' first."; - exit 1; -fi - -:: Run setup.py install with full paths. -echo "Running setup.py in $PACKAGE_PATH" -${PYTHON_EXECUTABLE} $PACKAGE_PATH/setup.py install diff --git a/cython/scripts/install.sh b/cython/scripts/install.sh deleted file mode 100755 index fdf86f130..000000000 --- a/cython/scripts/install.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh - -# This script runs the installation flow for python wrapped GTSAM. -# It does so by first setting the correct ownership permissions on the package directory, -# and then running `python setup.py install` to install the wrapped package. - -echo "Installing GTSAM Python Wrapper" - -# Set the package path -PACKAGE_PATH=${GTSAM_CYTHON_INSTALL_PATH}${GTSAM_BUILD_TAG} - -# Check if package directory exists. If not, print warning and exit. -if [ ! -d "$PACKAGE_PATH" ] -then - echo "Directory $PACKAGE_PATH DOES NOT exist. Please run 'make install' first."; - exit 1; -fi - -# Set cython directory permissions to user so we don't get permission denied. -# This also works inside Docker containers. -if [ "$(whoami)" != "root" ] -then - sudo chown -R $(logname) ${GTSAM_CYTHON_INSTALL_PATH} -else - chown -R $(logname) ${GTSAM_CYTHON_INSTALL_PATH} -fi - -# Run setup.py install with full paths. -echo "Running setup.py in $PACKAGE_PATH" -${PYTHON_EXECUTABLE} $PACKAGE_PATH/setup.py install