Commit 8e7b7ae0 authored by Julien Wintz's avatar Julien Wintz
Browse files

Updating wrapper interface and cmake usage.

parent cce8db01
......@@ -14,7 +14,11 @@
if(DTK_BUILD_WRAPPERS)
set(DTK_PYTHON_WRAPPER SWIG CACHE STRING "Choose the type of python wrapping")
if(NOT DTK_PYTHON_WRAPPER)
set(DTK_PYTHON_WRAPPER SWIG CACHE STRING "Choose the type of python wrapping")
else()
set(DTK_PYTHON_WRAPPER ${DTK_PYTHON_WRAPPER} CACHE STRING "dtk python wrapper")
endif()
set_property(CACHE DTK_PYTHON_WRAPPER PROPERTY STRINGS "SWIG" "SIP")
......
......@@ -190,26 +190,26 @@ set(${PROJECT_NAME}_MODULES)
if(DTK_BUILD_WRAPPERS AND SIP_FOUND)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
DEPENDS ${PROJECT_SOURCE_DIR}/dtkCore.i
DEPENDS ${CMAKE_SOURCE_DIR}/sip/${PROJECT_NAME}/${PROJECT_NAME}mod.sip
COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${CMAKE_BINARY_DIR}/modules
COMMENT "-- Moving python modules to ${CMAKE_BINARY_DIR}/modules")
if(APPLE)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
DEPENDS ${PROJECT_SOURCE_DIR}/dtkCore.i
COMMAND ln -sf ../lib/libdtkCore.dylib dtkCore.so
DEPENDS ${CMAKE_SOURCE_DIR}/sip/${PROJECT_NAME}/${PROJECT_NAME}mod.sip
COMMAND ln -sf ../lib/lib${PROJECT_NAME}.dylib ${PROJECT_NAME}.so
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/modules)
set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/dtkCore.so)
set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/${PROJECT_NAME}.so)
endif(APPLE)
if(UNIX AND NOT APPLE)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
DEPENDS ${PROJECT_SOURCE_DIR}/dtkCore.i
COMMAND ln -fs ../${CMAKE_INSTALL_LIBDIR}/libdtkCore.so dtkCore.so
DEPENDS ${CMAKE_SOURCE_DIR}/sip/${PROJECT_NAME}/${PROJECT_NAME}mod.sip
COMMAND ln -fs ../${CMAKE_INSTALL_LIBDIR}/lib${PROJECT_NAME}.so ${PROJECT_NAME}.so
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/modules)
set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/dtkCore.so)
set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/${PROJECT_NAME}.so)
endif(UNIX AND NOT APPLE)
endif(DTK_BUILD_WRAPPERS AND SIP_FOUND)
......
......@@ -56,7 +56,7 @@ public:
dtkScriptInterpreterPython::dtkScriptInterpreterPython(QObject *parent) : dtkScriptInterpreter(parent), d(new dtkScriptInterpreterPythonPrivate)
{
Py_Initialize();
PyRun_SimpleString(dtkScriptInterpreterPythonRedirector_declare.toUtf8().constData());
// PyRun_SimpleString(dtkScriptInterpreterPythonRedirector_declare.toUtf8().constData());
QString paths;
......@@ -116,7 +116,7 @@ QString dtkScriptInterpreterPython::interpret(const QString& command, int *stat)
PyObject *module = PyImport_AddModule("__main__");
PyRun_SimpleString(dtkScriptInterpreterPythonRedirector_define.toUtf8().constData());
// PyRun_SimpleString(dtkScriptInterpreterPythonRedirector_define.toUtf8().constData());
switch (PyRun_SimpleString(statement.toUtf8().constData())) {
case 0: *stat = Status_Ok; break;
......@@ -126,10 +126,12 @@ QString dtkScriptInterpreterPython::interpret(const QString& command, int *stat)
PyErr_Print();
PyObject *redtor = PyObject_GetAttrString(module, "redirector");
PyObject *result = PyObject_GetAttrString(redtor, "data");
// PyObject *redtor = PyObject_GetAttrString(module, "redirector");
// PyObject *result = PyObject_GetAttrString(redtor, "data");
return QString(PyString_AsString(result)).simplified();
// return QString(PyString_AsString(result)).simplified();
return QString();
}
//
......
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