# ==============================================================================
#                              for python wrapping
# ==============================================================================

set(python3 true)
if(python3)
  execute_process(COMMAND python3-config --prefix OUTPUT_VARIABLE PYTHON_PATH)
  string(REGEX REPLACE "\n$" "" PYTHON_PATH "${PYTHON_PATH}")
  string(STRIP ${PYTHON_PATH} PYTHON_PATH)
  string(CONCAT PYTHON_LIBRARY ${PYTHON_PATH} "/lib/libpython3.9.dylib")
  string(CONCAT PYTHON_INCLUDE_DIR ${PYTHON_PATH} "/include/python3.9m")
  message("{PYTHON_PATH} ${PYTHON_PATH}")
  message("{PYTHON_LIBRARY} ${PYTHON_LIBRARY}")
  message("{PYTHON_INCLUDE_DIR} ${PYTHON_INCLUDE_DIR}")
  find_package(PythonLibs 3.9 EXACT REQUIRED)
  set(BOOST_LIBRARYDIR /usr/local/lib)
  find_package(Boost COMPONENTS python39 numpy39 REQUIRED )
  INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_DIRS} ${Boost_INCLUDE_DIR})
else()
  execute_process(COMMAND python2-config --prefix OUTPUT_VARIABLE PYTHON_PATH)
  string(REGEX REPLACE "\n$" "" PYTHON_PATH "${PYTHON_PATH}")
  string(STRIP ${PYTHON_PATH} PYTHON_PATH)
  string(CONCAT PYTHON_LIBRARY ${PYTHON_PATH} "/lib/libpython2.7.dylib")
  string(CONCAT PYTHON_INCLUDE_DIR ${PYTHON_PATH} "/include/python2.7")
  message("{PYTHON_PATH} ${PYTHON_PATH}")
  message("{PYTHON_LIBRARY} ${PYTHON_LIBRARY}")
  message("{PYTHON_INCLUDE_DIR} ${PYTHON_INCLUDE_DIR}")
  find_package(PythonLibs 2.7 EXACT REQUIRED)
  set(BOOST_LIBRARYDIR /usr/local/lib)
  find_package(Boost COMPONENTS python27 numpy27 REQUIRED )
  INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_DIRS} ${Boost_INCLUDE_DIR})
endif()
