]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- framework for swig python bindings
authorArvin Schnell <aschnell@suse.de>
Tue, 13 Sep 2011 14:07:26 +0000 (16:07 +0200)
committerArvin Schnell <aschnell@suse.de>
Tue, 13 Sep 2011 14:07:26 +0000 (16:07 +0200)
bindings/Makefile.am [new file with mode: 0644]
bindings/python/.gitignore [new file with mode: 0644]
bindings/python/Makefile.am [new file with mode: 0644]
bindings/python/examples/create.py [new file with mode: 0755]
bindings/python/libsnapper.i [new file with mode: 0644]
configure.in

diff --git a/bindings/Makefile.am b/bindings/Makefile.am
new file mode 100644 (file)
index 0000000..25b6729
--- /dev/null
@@ -0,0 +1,5 @@
+#
+# Makefile.am for libsnapper/bindings
+#
+
+SUBDIRS = python
diff --git a/bindings/python/.gitignore b/bindings/python/.gitignore
new file mode 100644 (file)
index 0000000..67a5132
--- /dev/null
@@ -0,0 +1,3 @@
+libsnapper.py
+libsnapper_wrap.*
+_libsnapper*
diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
new file mode 100644 (file)
index 0000000..18d4ef3
--- /dev/null
@@ -0,0 +1,39 @@
+#
+# Makefile.am for libsnapper/bindings/python
+#
+
+EXTRA_DIST = libsnapper.i
+
+AM_CXXFLAGS = -fPIC -DPIC
+
+PYLIBVER ?= python$(PYTHON_VERSION)
+
+INCLUDES = -I. -I${top_srcdir} -I/usr/include/$(PYLIBVER)
+
+DEPENDENCIES =                                         \
+       ${top_srcdir}/snapper/Factory.h                 \
+       ${top_srcdir}/snapper/Snapper.h                 \
+       ${top_srcdir}/snapper/Snapshot.h                \
+       ${top_srcdir}/snapper/File.h                    \
+       ${top_srcdir}/snapper/Comparison.h              \
+       ${top_srcdir}/snapper/Exception.h
+
+LIBS = $(top_builddir)/snapper/libsnapper.la
+
+python_PYTHON = libsnapper.py
+
+pyexec_LTLIBRARIES = _libsnapper.la
+
+_libsnapper_la_LDFLAGS = -module -avoid-version
+_libsnapper_la_HEADERS: $(top_builddir)/config.h
+
+_libsnapper_la_DEPENDENCIES =                          \
+       $(DEPENDENCIES)                                 \
+       ${top_builddir}/snapper/libsnapper.la
+
+nodist__libsnapper_la_SOURCES = libsnapper_wrap.cxx
+
+libsnapper.py libsnapper_wrap.cxx: libsnapper.i $(DEPENDENCIES)
+       swig -o libsnapper_wrap.cxx -c++ -python ${INCLUDES} libsnapper.i
+
+CLEANFILES = libsnapper.py libsnapper_wrap.cxx
diff --git a/bindings/python/examples/create.py b/bindings/python/examples/create.py
new file mode 100755 (executable)
index 0000000..2cabdcd
--- /dev/null
@@ -0,0 +1,11 @@
+#!/usr/bin/python
+
+import libsnapper
+
+
+sh = libsnapper.createSnapper("root", False)
+
+sh.createSingleSnapshot("python test")
+
+libsnapper.deleteSnapper(sh)
+
diff --git a/bindings/python/libsnapper.i b/bindings/python/libsnapper.i
new file mode 100644 (file)
index 0000000..b6f6980
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// Python interface definition for libsnapper
+//
+
+%module libsnapper
+
+%{
+using namespace std;
+
+#include <snapper/Factory.h>
+#include <snapper/Snapshot.h>
+#include <snapper/Snapper.h>
+#include <snapper/File.h>
+#include <snapper/Comparison.h>
+#include <snapper/Exception.h>
+%}
+
+using namespace std;
+
+%include "std_string.i"
+%include "std_vector.i"
+%include "std_list.i"
+
+%typemap(out) std::string* {
+    $result = PyString_FromString($1->c_str());
+}
+
+%include "../../snapper/Factory.h"
+%include "../../snapper/Snapshot.h"
+%include "../../snapper/Snapper.h"
+%include "../../snapper/File.h"
+%include "../../snapper/Comparison.h"
+%include "../../snapper/Exception.h"
+
+using namespace snapper;
+
+%template(vectorstring) vector<string>;
+
index 9a2bf7c9f36a5bce25ee88decc4a07cfc1315a03..cf6ba0d7c87fcc3ea9361247f2c3cb8b86180099 100644 (file)
@@ -21,6 +21,7 @@ AC_DISABLE_STATIC
 AC_PROG_CXX
 AC_PROG_LIBTOOL
 AM_PROG_LIBTOOL
+AM_PATH_PYTHON
 
 AC_PREFIX_DEFAULT(/usr)