Commit d4505495 authored by Purves, Murray's avatar Purves, Murray
Browse files

CMake configuration to build & install python bindings for radixmath interpolate methods

parent ea877136
Pipeline #28433 failed with stages
in 52 seconds
......@@ -2,25 +2,35 @@ TRIBITS_SUBPACKAGE(py)
# we need Python 3 for this
FIND_PACKAGE(Python3 COMPONENTS Interpreter Development)
IF(PYTHON3_FOUND)
MESSAGE(STATUS "Found Python 3 - version ${PYTHON3_VERSION}")
MESSAGE(STATUS "Executable: ${PYTHON3_EXECUTABLE}")
MESSAGE(STATUS "Include dirs: ${PYTHON3_INCLUDE_DIRS}")
ENDIF()
INCLUDE_DIRECTORIES(${PYTHON3_INCLUDE_DIRS})
IF(Python3_FOUND)
MESSAGE(STATUS "Found Python 3 - version: ${Python3_VERSION}")
MESSAGE(STATUS "Executable: ${Python3_EXECUTABLE}")
MESSAGE(STATUS "Include dirs: ${Python3_INCLUDE_DIRS}")
MESSAGE(STATUS "Root dir: ${Python3_ROOT_DIR}")
MESSAGE(STATUS "${Python_VERSION}")
MESSAGE(STATUS "${Python_EXECUTABLE}")
MESSAGE(STATUS "${Python_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES(${Python3_INCLUDE_DIRS})
# Set up the Python setup script
SET(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/radixmathpy/setup.py.in")
SET(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/radixmathpy/setup.py")
CONFIGURE_FILE(${SETUP_PY_IN} ${SETUP_PY})
# Set up the Python setup script
SET(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/radixmathpy/setup.py.in")
SET(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/radixmathpy/setup.py")
CONFIGURE_FILE(${SETUP_PY_IN} ${SETUP_PY})
SET(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/radixmathpy/build_output")
ADD_CUSTOM_COMMAND(
OUTPUT ${OUTPUT}
COMMAND ${PYTHON3_EXECUTABLE} ${SETUP_PY} build
DEPENDS ""
)
SET(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/radixmathpy/build_output")
ADD_CUSTOM_COMMAND(
OUTPUT ${OUTPUT}
COMMAND ${Python3_EXECUTABLE} ${SETUP_PY} build
COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
DEPENDS ""
)
ADD_CUSTOM_TARGET(target ALL DEPENDS ${OUTPUT})
install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install)")
install(CODE "execute_process(COMMAND ${Python3_EXECUTABLE} ${SETUP_PY} install --prefix=${CMAKE_INSTALL_PREFIX})")
ELSE()
MESSAGE(WARNING "Not found Python 3: not including bindings")
ENDIF()
TRIBITS_SUBPACKAGE_POSTPROCESS()
// May have to use Python/Python.h for mac?
#include <Python.h>
#include <vector>
#include "radixmath/interpolate.hh"
#include "../../radixmath/interpolate.hh"
#include "python_utils.hh"
#include "../python_utils.hh"
static PyObject* interpolate_values(PyObject* self, PyObject* args)
{
......
......@@ -19,7 +19,7 @@ else:
interpolate_module = Extension(
'interpolate',
sources=['${CMAKE_CURRENT_SOURCE_DIR}/interpolatemodule.cc'],
sources=['${CMAKE_CURRENT_SOURCE_DIR}/radixmathpy/interpolatemodule.cc'],
language='C++',
libraries=libraries,
library_dirs=library_dirs,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment