aboutsummaryrefslogtreecommitdiff
path: root/bindings/python
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-08-04 14:18:00 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2011-09-15 14:15:28 +0300
commitb4e9659ae72be31fb4b345efeaf0f66607ed73fa (patch)
tree8ef6f7bf0b60a58c280a2cb48f0306b127886075 /bindings/python
parent544747d02cd4c8b6ad2b6e8a8bf35e0242ba2d2e (diff)
downloadlibssh-b4e9659ae72be31fb4b345efeaf0f66607ed73fa.tar.gz
libssh-b4e9659ae72be31fb4b345efeaf0f66607ed73fa.tar.xz
libssh-b4e9659ae72be31fb4b345efeaf0f66607ed73fa.zip
binding: Added python bindings support using swig.
Diffstat (limited to 'bindings/python')
-rw-r--r--bindings/python/CMakeLists.txt26
1 files changed, 26 insertions, 0 deletions
diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt
new file mode 100644
index 00000000..4d410339
--- /dev/null
+++ b/bindings/python/CMakeLists.txt
@@ -0,0 +1,26 @@
+project(libssh-python CXX)
+
+set(SWIG_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ssh_python.cpp")
+
+find_package(PythonInterp REQUIRED)
+execute_process(
+ COMMAND
+ ${PYTHON_EXECUTABLE} -c "from sys import stdout; from distutils import sysconfig; stdout.write(sysconfig.get_python_lib())"
+ OUTPUT_VARIABLE
+ PYTHON_LIB_DIR
+)
+
+if (NOT PYTHON_SITEDIR)
+ set(PYTHON_SITEDIR ${PYTHON_LIB_DIR})
+endif (NOT PYTHON_SITEDIR)
+
+include_directories(${LIBSSH_PUBLIC_INCLUDE_DIRS} ${PYTHON_INCLUDE_PATH})
+
+set_source_files_properties(${SWIG_INPUT} PROPERTIES CPLUSPLUS ON)
+# Py_True and Py_False are a bit tricky
+set_source_files_properties(${swig_generated_file_fullname} PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing")
+swig_add_module(ssh python ${SWIG_INPUT})
+swig_link_libraries(ssh ${LIBSSH_SHARED_LIBRARY} ${PYTHON_LIBRARIES})
+
+install(TARGETS ${SWIG_MODULE_ssh_REAL_NAME} LIBRARY DESTINATION ${PYTHON_SITEDIR})
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ssh.py DESTINATION ${PYTHON_SITEDIR})