master - python: Add bindings for liblvm2app.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ee3cfa41843b0af1ef220ecf8bf6db82676af8c8 Commit: ee3cfa41843b0af1ef220ecf8bf6db82676af8c8 Parent: 4022fd3e79099fb22b2b7d3d6dca8de733a2a783 Author: Alasdair G Kergon <[email protected]> AuthorDate: Fri Oct 12 02:08:47 2012 +0100 Committer: Alasdair G Kergon <[email protected]> CommitterDate: Fri Oct 12 02:08:47 2012 +0100
python: Add bindings for liblvm2app.
Use configure --enable-python_bindings to generate them.
Note that the Makefiles do not yet control the owner or permissions of the two new files on installation.
--- Makefile.in | 17 +- WHATS_NEW | 1 + configure | 216 ++++++- configure.in | 40 ++ lib/misc/configure.h.in | 3 - make.tmpl.in | 3 + python/Makefile.in | 39 ++ python/example.py | 125 ++++ python/liblvm.c | 1711 +++++++++++++++++++++++++++++++++++++++++++++++ python/setup.py.in | 35 + 10 files changed, 2175 insertions(+), 15 deletions(-)
Makefile.in +15 -2
@@ -32,13 +32,17 @@ ifeq ("@APPLIB@", "yes") SUBDIRS += liblvm endif +ifeq ("@PYTHON_BINDINGS@", "yes") + SUBDIRS += python +endif + SUBDIRS += scripts # FIXME Should use intermediate Makefiles here! ifeq ($(MAKECMDGOALS),distclean) SUBDIRS = doc include man test scripts \ libdaemon lib tools daemons libdm \ - udev po liblvm \ + udev po liblvm python \ unit-tests/datastruct unit-tests/mm unit-tests/regex endif DISTCLEAN_DIRS += lcov_reports*
@@ -69,6 +73,10 @@ po.pofile: tools.pofile daemons.pofile pofile: po.pofile endif +ifeq ("@PYTHON_BINDINGS@", "yes") +python: liblvm +endif + ifneq ("$(CFLOW_CMD)", "") tools.cflow: libdm.cflow lib.cflow daemons.cflow: tools.cflow
@@ -103,6 +111,11 @@ install_systemd_generators: install_systemd_units: $(MAKE) -C scripts install_systemd_units +ifeq ("@PYTHON_BINDINGS@", "yes") +install_python_bindings: + $(MAKE) -C liblvm/python install_python_bindings +endif + install_tmpfiles_configuration: $(MAKE) -C scripts install_tmpfiles_configuration
@@ -148,7 +161,7 @@ ifeq ("$(TESTING)", "yes") # testing and report generation RUBY=ruby1.9 -Ireport-generators/lib -Ireport-generators/test -.PHONEY: unit-test ruby-test test-programs +.PHONY: unit-test ruby-test test-programs # FIXME: put dependencies on libdm and liblvm # FIXME: Should be handled by Makefiles in subdirs, not here at top level.
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.98 - ================================= + Add configure --enable-python_bindings for liblvm2app to new python subdir. Add implementation of lvm2api function lvm_percent_to_float. Allow non power of 2 thin chunk sizes if thin pool driver supports that. Allow limited metadata changes when PVs are missing via [vg|lv]change.
configure +204 -10
281 lines not on this page · raw message
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -11303,6 +11497,8 @@ do
"liblvm/liblvm2app.pc") CONFIG_FILES="$CONFIG_FILES liblvm/liblvm2app.pc" ;;
"man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;
"po/Makefile") CONFIG_FILES="$CONFIG_FILES po/Makefile" ;;
+ "python/Makefile") CONFIG_FILES="$CONFIG_FILES python/Makefile" ;;
+ "python/setup.py") CONFIG_FILES="$CONFIG_FILES python/setup.py" ;;
"scripts/clvmd_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/clvmd_init_red_hat" ;;
"scripts/cmirrord_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/cmirrord_init_red_hat" ;;
"scripts/lvm2_lvmetad_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmetad_init_red_hat" ;;configure.in +40 -0
@@ -1027,6 +1027,40 @@ test x$CMDLIB = xyes \ || LVM2CMD_LIB= ################################################################################ +dnl -- Enable Python liblvm2app bindings +AC_MSG_CHECKING(whether to build Python wrapper for liblvm2app.so) +AC_ARG_ENABLE(python_bindings, + AC_HELP_STRING([--enable-python_bindings], [build Python applib bindings]), + PYTHON_BINDINGS=$enableval, PYTHON_BINDINGS=no) +AC_MSG_RESULT($PYTHON_BINDINGS) + +if test x$PYTHON_BINDINGS = xyes; then + if test x$APPLIB != xyes; then + AC_MSG_ERROR( + --enable-python_bindings requires --enable-applib + ) + fi + + AC_PATH_PROG(PYTHON, python, notfound) + if test x$PYTHON == xnotfound; then + AC_MSG_ERROR( +[python is required for --enable-python_bindings but cannot be found] + ) + fi + + AC_PATH_PROG(PYTHON_CONFIG, python-config, notfound) + if test x$PYTHON_CONFIG == xnotfound; then + AC_MSG_ERROR( +[python headers are required for --enable-python_bindings but cannot be found] + ) + fi + + PYTHON_INCDIRS=`$PYTHON_CONFIG --includes` + PYTHON_LIBDIRS=`$PYTHON_CONFIG --libs` + +fi + +################################################################################ dnl -- Enable pkg-config AC_ARG_ENABLE(pkgconfig, AC_HELP_STRING([--enable-pkgconfig], [install pkgconfig support]),
@@ -1523,6 +1557,10 @@ AC_SUBST(OCFDIR) AC_SUBST(PKGCONFIG) AC_SUBST(POOL) AC_SUBST(PTHREAD_LIBS) +AC_SUBST(PYTHON) +AC_SUBST(PYTHON_BINDINGS) +AC_SUBST(PYTHON_INCDIRS) +AC_SUBST(PYTHON_LIBDIRS) AC_SUBST(QUORUM_CFLAGS) AC_SUBST(QUORUM_LIBS) AC_SUBST(RAID)
@@ -1605,6 +1643,8 @@ liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile +python/Makefile +python/setup.py scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_lvmetad_init_red_hat
lib/misc/configure.h.in +0 -3
@@ -432,9 +432,6 @@ /* Define to 1 if you have the <utmpx.h> header file. */ #undef HAVE_UTMPX_H -/* Define to 1 if you have the <valgrind/memcheck.h> header file. */ -#undef HAVE_VALGRIND_MEMCHECK_H - /* Define to 1 if you have the `vfork' function. */ #undef HAVE_VFORK
make.tmpl.in +3 -0
@@ -28,6 +28,7 @@ LN_S = @LN_S@ SED = @SED@ CFLOW_CMD = @CFLOW_CMD@ AWK = @AWK@ +PYTHON = @PYTHON@ LIBS = @LIBS@ # Extra libraries always linked with static binaries
@@ -52,6 +53,7 @@ prefix = @prefix@ exec_prefix = @exec_prefix@ udev_prefix = @udev_prefix@ sysconfdir = @sysconfdir@ +rootdir = $(DESTDIR)/ bindir = $(DESTDIR)@bindir@ confdir = $(DESTDIR)@CONFDIR@/lvm includedir = $(DESTDIR)@includedir@
@@ -196,6 +198,7 @@ POTFILES = $(SOURCES:%.c=%.pot) .PHONY: install install_cluster install_device-mapper install_lvm2 .PHONY: install_lib_shared install_dm_plugin install_lvm2_plugin .PHONY: install_ocf help +.PHONY: python_bindings install_python_bindings .PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean) .PHONY: $(SUBDIRS.pofile) $(SUBDIRS.install_cluster) $(SUBDIRS.cflow) .PHONY: $(SUBDIRS.device-mapper) $(SUBDIRS.install-device-mapper)
python/Makefile.in new file +39 -0
@@ -0,0 +1,39 @@ +# +# Copyright (C) 2011-2012 Red Hat, Inc. +# +# This file is part of LVM2. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions +# of the GNU Lesser General Public License v.2.1. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ + +python_bindings: .liblvm_built + +.liblvm_built: liblvm_python.c + $(PYTHON) setup.py build + touch $@ + +liblvm_python.c: + $(LN_S) $(srcdir)/liblvm.c $@ + +include $(top_builddir)/make.tmpl + +install_python_bindings: python_bindings + $(PYTHON) setup.py install --skip-build --root $(rootdir) + +install_lvm2: install_python_bindings + +install: install_lvm2 + +CLEAN_TARGETS += .liblvm_built liblvm_python.c + +DISTCLEAN_DIRS += build +DISTCLEAN_TARGETS += setup.py
python/example.py new file +125 -0
125 lines not on this page · raw message
python/liblvm.c new file +1711 -0
1,711 lines not on this page · raw message
python/setup.py.in new file +35 -0
@@ -0,0 +1,35 @@ +# +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# This file is part of LVM2. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 2.1 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +from distutils.core import setup, Extension + +liblvm = Extension('lvm', + sources = ['liblvm_python.c'], + libraries= ['lvm2app'], + library_dirs= ['@top_builddir@/liblvm'], + include_dirs= ['@top_builddir@/include']) + +setup (name='lvm', + version=@LVM_VERSION@, + description='Python bindings for liblvm2', + license="LGPLv2+", + maintainer='LVM2 maintainers', + maintainer_email='linux-lvm at redhat.com', + url='http://sourceware.org/lvm2/', + ext_modules=[liblvm], +)