add new make command for installing python wrapper

release/4.3a0
Varun Agrawal 2020-06-22 20:14:03 -05:00
parent 1725a577cf
commit 93a00a38a4
4 changed files with 36 additions and 5 deletions

View File

@ -280,9 +280,16 @@ function(install_cython_files source_files dest_directory)
endfunction() endfunction()
function(install_python_package install_path) function(install_python_package install_path)
set(package_path "${install_path}${GTSAM_BUILD_TAG}") #TODO this will only work for Linux. Need to make it work on macOS and Windows as well
# set cython directory permissions to user so we don't get permission denied #TODO Running `sudo make install` makes this run in admin space causing Python 2.7 to be picked up.
install(CODE "execute_process(COMMAND sh \"-c\" \"chown -R $(logname):$(logname) ${package_path}\")") # # go to cython directory and run setup.py
# go to cython directory and run setup.py # install(CODE "execute_process(COMMAND sh \"-c\" \"cd ${package_path} && python setup.py install\")")
install(CODE "execute_process(COMMAND sh \"-c\" \"cd ${package_path} && python setup.py install\")") 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_file(${PROJECT_SOURCE_DIR}/cython/scripts/${PYTHON_INSTALL_SCRIPT} ${PROJECT_BINARY_DIR}/cython/scripts/${PYTHON_INSTALL_SCRIPT})
add_custom_target(python-install "${PROJECT_BINARY_DIR}/cython/scripts/${PYTHON_INSTALL_SCRIPT}")
endfunction() endfunction()

View File

@ -45,6 +45,9 @@ 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" "${GTSAM_CYTHON_INSTALL_PATH}" "*.py")
install_cython_scripts("${PROJECT_SOURCE_DIR}/cython/gtsam_unstable" "${GTSAM_CYTHON_INSTALL_PATH}" "*.py") install_cython_scripts("${PROJECT_SOURCE_DIR}/cython/gtsam_unstable" "${GTSAM_CYTHON_INSTALL_PATH}" "*.py")
# file(GLOB GTSAM_PYTHON_INSTALL_SCRIPTS "scripts/*")
# file(COPY ${GTSAM_PYTHON_INSTALL_SCRIPTS} DESTINATION ${PROJECT_BINARY_DIR}/cython/scripts)
install_python_package("${GTSAM_CYTHON_INSTALL_PATH}") install_python_package("${GTSAM_CYTHON_INSTALL_PATH}")
endif () endif ()

0
cython/scripts/install.bat Executable file
View File

21
cython/scripts/install.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
echo "Installing GTSAM Python Wrapper"
PACKAGE_PATH=${GTSAM_CYTHON_INSTALL_PATH}${GTSAM_BUILD_TAG}
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
if [ "$(whoami)" != "root" ]
then
sudo chown -R $(logname) ${GTSAM_CYTHON_INSTALL_PATH}
else
chown -R $(logname) ${GTSAM_CYTHON_INSTALL_PATH}
fi
echo "Running setup.py in $PACKAGE_PATH"
${PYTHON_EXECUTABLE} $PACKAGE_PATH/setup.py install