added option to specify python version
parent
09ac7f7c06
commit
e9e8ca3990
|
@ -78,6 +78,7 @@ endif()
|
||||||
option(GTSAM_INSTALL_MATLAB_TOOLBOX "Enable/Disable installation of matlab toolbox" OFF)
|
option(GTSAM_INSTALL_MATLAB_TOOLBOX "Enable/Disable installation of matlab toolbox" OFF)
|
||||||
option(GTSAM_INSTALL_CYTHON_TOOLBOX "Enable/Disable installation of Cython toolbox" OFF)
|
option(GTSAM_INSTALL_CYTHON_TOOLBOX "Enable/Disable installation of Cython toolbox" OFF)
|
||||||
option(GTSAM_BUILD_WRAP "Enable/Disable building of matlab/cython wrap utility (necessary for matlab/cython interface)" ON)
|
option(GTSAM_BUILD_WRAP "Enable/Disable building of matlab/cython wrap utility (necessary for matlab/cython interface)" ON)
|
||||||
|
set(GTSAM_PYTHON_VERSION "Default" CACHE STRING "The version of python to build the cython wrapper or python module for (or Default)")
|
||||||
|
|
||||||
# Check / set dependent variables for MATLAB wrapper
|
# Check / set dependent variables for MATLAB wrapper
|
||||||
if((GTSAM_INSTALL_MATLAB_TOOLBOX OR GTSAM_INSTALL_CYTHON_TOOLBOX) AND NOT GTSAM_BUILD_WRAP)
|
if((GTSAM_INSTALL_MATLAB_TOOLBOX OR GTSAM_INSTALL_CYTHON_TOOLBOX) AND NOT GTSAM_BUILD_WRAP)
|
||||||
|
@ -554,6 +555,7 @@ endif()
|
||||||
|
|
||||||
message(STATUS "Cython toolbox flags ")
|
message(STATUS "Cython toolbox flags ")
|
||||||
print_config_flag(${GTSAM_INSTALL_CYTHON_TOOLBOX} "Install Cython toolbox ")
|
print_config_flag(${GTSAM_INSTALL_CYTHON_TOOLBOX} "Install Cython toolbox ")
|
||||||
|
message(STATUS " Python version : ${GTSAM_PYTHON_VERSION}")
|
||||||
print_config_flag(${GTSAM_BUILD_WRAP} "Build Wrap ")
|
print_config_flag(${GTSAM_BUILD_WRAP} "Build Wrap ")
|
||||||
message(STATUS "===============================================================")
|
message(STATUS "===============================================================")
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,17 @@
|
||||||
|
|
||||||
# Finding NumPy involves calling the Python interpreter
|
# Finding NumPy involves calling the Python interpreter
|
||||||
if(NumPy_FIND_REQUIRED)
|
if(NumPy_FIND_REQUIRED)
|
||||||
|
if(GTSAM_PYTHON_VERSION STREQUAL "Default")
|
||||||
find_package(PythonInterp REQUIRED)
|
find_package(PythonInterp REQUIRED)
|
||||||
|
else()
|
||||||
|
find_package(PythonInterp ${GTSAM_PYTHON_VERSION} EXACT REQUIRED)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
|
if(GTSAM_PYTHON_VERSION STREQUAL "Default")
|
||||||
find_package(PythonInterp)
|
find_package(PythonInterp)
|
||||||
|
else()
|
||||||
|
find_package(PythonInterp ${GTSAM_PYTHON_VERSION} EXACT)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT PYTHONINTERP_FOUND)
|
if(NOT PYTHONINTERP_FOUND)
|
||||||
|
|
|
@ -5,8 +5,19 @@ unset(PYTHON_EXECUTABLE CACHE)
|
||||||
unset(CYTHON_EXECUTABLE CACHE)
|
unset(CYTHON_EXECUTABLE CACHE)
|
||||||
unset(PYTHON_INCLUDE_DIR CACHE)
|
unset(PYTHON_INCLUDE_DIR CACHE)
|
||||||
unset(PYTHON_MAJOR_VERSION CACHE)
|
unset(PYTHON_MAJOR_VERSION CACHE)
|
||||||
|
|
||||||
|
if(GTSAM_PYTHON_VERSION STREQUAL "Default")
|
||||||
|
find_package(PythonLibs REQUIRED)
|
||||||
|
else()
|
||||||
|
find_package(PythonLibs ${GTSAM_PYTHON_VERSION} EXACT REQUIRED)
|
||||||
|
endif()
|
||||||
find_package(Cython 0.25.2 REQUIRED)
|
find_package(Cython 0.25.2 REQUIRED)
|
||||||
|
|
||||||
|
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
|
||||||
|
"from __future__ import print_function;import sys;print(sys.version[0], end='')"
|
||||||
|
OUTPUT_VARIABLE PYTHON_MAJOR_VERSION
|
||||||
|
)
|
||||||
|
|
||||||
# User-friendly Cython wrapping and installing function.
|
# User-friendly Cython wrapping and installing function.
|
||||||
# Builds a Cython module from the provided interface_header.
|
# Builds a Cython module from the provided interface_header.
|
||||||
# For example, for the interface header gtsam.h,
|
# For example, for the interface header gtsam.h,
|
||||||
|
@ -31,16 +42,16 @@ endfunction()
|
||||||
|
|
||||||
function(set_up_required_cython_packages)
|
function(set_up_required_cython_packages)
|
||||||
# Set up building of cython module
|
# Set up building of cython module
|
||||||
find_package(PythonLibs REQUIRED)
|
if(GTSAM_PYTHON_VERSION STREQUAL "Default")
|
||||||
|
find_package(PythonLibs REQUIRED)
|
||||||
|
else()
|
||||||
|
find_package(PythonLibs ${GTSAM_PYTHON_VERSION} EXACT REQUIRED)
|
||||||
|
endif()
|
||||||
include_directories(${PYTHON_INCLUDE_DIRS})
|
include_directories(${PYTHON_INCLUDE_DIRS})
|
||||||
find_package(NumPy REQUIRED)
|
find_package(NumPy REQUIRED)
|
||||||
include_directories(${NUMPY_INCLUDE_DIRS})
|
include_directories(${NUMPY_INCLUDE_DIRS})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
|
|
||||||
"from __future__ import print_function;import sys;print(sys.version[0], end='')"
|
|
||||||
OUTPUT_VARIABLE PYTHON_MAJOR_VERSION
|
|
||||||
)
|
|
||||||
|
|
||||||
# Convert pyx to cpp by executing cython
|
# Convert pyx to cpp by executing cython
|
||||||
# This is the first step to compile cython from the command line
|
# This is the first step to compile cython from the command line
|
||||||
|
|
|
@ -2,7 +2,7 @@ This is the Cython/Python wrapper around the GTSAM C++ library.
|
||||||
|
|
||||||
INSTALL
|
INSTALL
|
||||||
=======
|
=======
|
||||||
- if you want to build the gtsam python library for python 3, use the `-DPython_ADDITIONAL_VERSIONS=3` option when running `cmake` otherwise the interpreter at `$ which python` will be used.
|
- if you want to build the gtsam python library for a specific python version (eg 2.7), use the `-DGTSAM_PYTHON_VERSION=2.7` option when running `cmake` otherwise the default interpreter will be used.
|
||||||
- If the interpreter is inside an environment (such as an anaconda environment or virtualenv environment) then the environment should be active while building gtsam.
|
- If the interpreter is inside an environment (such as an anaconda environment or virtualenv environment) then the environment should be active while building gtsam.
|
||||||
- This wrapper needs Cython(>=0.25.2), backports_abc>=0.5, and numpy. These can be installed as follows:
|
- This wrapper needs Cython(>=0.25.2), backports_abc>=0.5, and numpy. These can be installed as follows:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue