提交 75169488 编写于 作者: D Daniel Veillard

* Makefile.am configure.in libvir.spec.in python/*: added a first

  version for python bindings, heavilly based on libxml2/libxslt
  way of doing things, maybe this need to be revisited. Added packaging
  too.
* src/hash.h: fixed the Copyright notice.
Daniel
上级 85a2a989
Mon Dec 19 17:32:22 CET 2005 Daniel Veillard <veillard@redhat.com>
* Makefile.am configure.in libvir.spec.in python/*: added a first
version for python bindings, heavilly based on libxml2/libxslt
way of doing things, maybe this need to be revisited. Added packaging
too.
* src/hash.h: fixed the Copyright notice.
Fri Dec 16 19:35:29 CET 2005 Karel Zak <kzak@redhat.com>
* src/xml.c src/internal.h src/libvir.c: struct checks cleanup,
......
## Process this file with automake to produce Makefile.in
SUBDIRS = src include docs
SUBDIRS = src include docs @PYTHON_SUBDIR@
EXTRA_DIST = libvir.spec.in libvir.spec COPYING.LIB \
libvir.pc.in libvir.pc TODO AUTHORS ChangeLog \
NEWS README
......
......@@ -101,6 +101,89 @@ AC_CHECK_LIB(readline, main,
[$VIRSH_LIBS])
AC_SUBST(VIRSH_LIBS)
dnl
dnl check for python
dnl
PYTHON_VERSION=
PYTHON_INCLUDES=
PYTHON_SITE_PACKAGES=
PYTHON_TESTS=
pythondir=
if test "$with_python" != "no" ; then
if test -x "$with_python/bin/python"
then
echo Found python in $with_python/bin/python
PYTHON="$with_python/bin/python"
else
if test -x "$with_python"
then
echo Found python in $with_python
PYTHON="$with_python"
else
if test -x "$PYTHON"
then
echo Found python in environment PYTHON=$PYTHON
else
AC_PATH_PROG(PYTHON, python python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5)
fi
fi
fi
if test "$PYTHON" != ""
then
PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[[0:3]]"`
echo Found Python version $PYTHON_VERSION
fi
if test "$PYTHON_VERSION" != ""
then
if test -r $with_python/include/python$PYTHON_VERSION/Python.h -a \
-d $with_python/lib/python$PYTHON_VERSION/site-packages
then
PYTHON_INCLUDES=$with_python/include/python$PYTHON_VERSION
PYTHON_SITE_PACKAGES=$with_python/lib/python$PYTHON_VERSION/site-packages
else
if test -r $prefix/include/python$PYTHON_VERSION/Python.h
then
PYTHON_INCLUDES='$(prefix)/include/python$(PYTHON_VERSION)'
PYTHON_SITE_PACKAGES='$(libdir)/python$(PYTHON_VERSION)/site-packages'
else
if test -r /usr/include/python$PYTHON_VERSION/Python.h
then
PYTHON_INCLUDES=/usr/include/python$PYTHON_VERSION
PYTHON_SITE_PACKAGES='$(libdir)/python$(PYTHON_VERSION)/site-packages'
else
echo could not find python$PYTHON_VERSION/Python.h
fi
fi
if test ! -d "$PYTHON_SITE_PACKAGES"
then
PYTHON_SITE_PACKAGES=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib()"`
fi
fi
fi
if test "$with_python" != ""
then
pythondir='$(PYTHON_SITE_PACKAGES)'
else
pythondir='$(libdir)/python${PYTHON_VERSION}/site-packages'
fi
else
PYTHON=
fi
AM_CONDITIONAL(WITH_PYTHON, test "$PYTHON_INCLUDES" != "")
if test "$PYTHON_INCLUDES" != ""
then
PYTHON_SUBDIR=python
else
PYTHON_SUBDIR=
fi
AC_SUBST(pythondir)
AC_SUBST(PYTHON)
AC_SUBST(PYTHON_VERSION)
AC_SUBST(PYTHON_INCLUDES)
AC_SUBST(PYTHON_SITE_PACKAGES)
AC_SUBST(PYTHON_SUBDIR)
# end of if with_depends
fi
......@@ -108,4 +191,4 @@ fi
rm -f COPYING
AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
libvir.pc libvir.spec include/libvir.h)
libvir.pc libvir.spec include/libvir.h python/Makefile)
......@@ -7,7 +7,7 @@ Group: Development/Libraries
Source: libvir-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-root
URL: http://libvir.org/
BuildRequires: xen
BuildRequires: xen python python-devel
Requires: xen
%description
......@@ -23,6 +23,17 @@ Requires: libvir = %{version}
Includes and documantations for the C library providing an API to use
the Xen virtualization framework
%package python
Summary: Python bindings for the libvir library
Group: Development/Libraries
Requires: libvir = %{version}
Requires: %{_libdir}/python%(echo `python -c "import sys; print sys.version[0:3]"`)
%description python
The libvir-python package contains a module that permits applications
written in the Python programming language to use the interface
supplied by the libvir library to use the Xen virtualization framework.
%prep
%setup -q
......@@ -36,6 +47,8 @@ rm -fr %{buildroot}
%makeinstall
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/*.a
rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.a
%clean
rm -fr %{buildroot}
......@@ -63,6 +76,15 @@ rm -fr %{buildroot}
%doc docs/*.html docs/html docs/*.gif
%doc docs/libvir-api.xml
%files python
%defattr(-, root, root)
%doc AUTHORS NEWS README COPYING.LIB
%{_libdir}/python*/site-packages/libvir.py*
%{_libdir}/python*/site-packages/libvirmod*
%doc python/TODO
%doc python/libvirclass.txt
%changelog
* Wed Nov 2 2005 Daniel Veillard <veillard@redhat.com> 0.0.1-1
- created
# Makefile for libvir python library
INCLUDES = \
-I$(PYTHON_INCLUDES) \
-I$(top_srcdir)/include \
-I$(top_builddir)/include \
-I$(top_builddir)/$(subdir)
DOCS_DIR = $(datadir)/doc/libvir-python-$(LIBVIR_VERSION)
DOCS = ${srcdir}/TODO
EXTRA_DIST = \
libvir.c \
types.c \
generator.py \
libvir_wrap.h \
libvir.py \
libvir-python-api.xml \
$(DOCS)
libvirmod_la_LDFLAGS = -module -avoid-version -L$(top_builddir)/src/.libs
if WITH_PYTHON
mylibs = $(top_builddir)/src/libvir.la
all-local: libvir.py
python_LTLIBRARIES = libvirmod.la
libvirmod_la_SOURCES = libvir.c types.c libvir-py.c
libvirmod_la_LIBADD = $(mylibs)
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(pythondir)
@INSTALL@ -m 0644 libvir.py $(DESTDIR)$(pythondir)
$(mkinstalldirs) $(DESTDIR)$(DOCS_DIR)
@(for doc in $(DOCS) ; \
do @INSTALL@ -m 0644 $$doc $(DESTDIR)$(DOCS_DIR) ; done)
GENERATE = generator.py
API_DESC = $(top_srcdir)/docs/libvir-api.xml $(srcdir)/libvir-python-api.xml
GENERATED= libvir.py \
libvir-export.c \
libvirclass.txt \
libvir-py.c \
libvir-py.h
CLEANFILES= $(GENERATED) gen_prog libvir.py
$(GENERATED): gen_prog
gen_prog: $(srcdir)/$(GENERATE) $(API_DESC)
$(PYTHON) $(srcdir)/$(GENERATE) $(srcdir)
touch gen_prog
$(libvirmod_la_OBJECTS): $(GENERATED)
else
all:
endif
- Need to complete, add custom wrapper function for those
which could not be handled fully automatically
- Check the names generated, iD is bad, fix the name generation routine
- add examples, web page and python based test suite
Daniel Veillard
$date$
此差异已折叠。
<?xml version="1.0"?>
<api name='libvir-python'>
</api>
/*
* libvir.c: this modules implements the main part of the glue of the
* libvir library and the Python interpreter. It provides the
* entry points where an automatically generated stub is
* unpractical
*
* Copyright (C) 2005 Red Hat, Inc.
*
* Daniel Veillard <veillard@redhat.com>
*/
#include <Python.h>
#include <libvir.h>
#include "libvir_wrap.h"
#include "libvir-py.h"
void initlibvirmod(void);
/************************************************************************
* *
* The registration stuff *
* *
************************************************************************/
static PyMethodDef libvirMethods[] = {
#include "libvir-export.c"
{NULL, NULL, 0, NULL}
};
void
initlibvirmod(void)
{
static int initialized = 0;
if (initialized != 0)
return;
/* intialize the python extension module */
Py_InitModule((char *) "libvirmod", libvirMethods);
initialized = 1;
}
/*
* libvir_wrap.h: type wrappers for libvir python bindings
*
* Copyright (C) 2005 Red Hat, Inc.
*
* Daniel Veillard <veillard@redhat.com>
*/
#include <Python.h>
#include <libvir.h>
#ifdef __GNUC__
#ifdef ATTRIBUTE_UNUSED
#undef ATTRIBUTE_UNUSED
#endif
#ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#endif /* ATTRIBUTE_UNUSED */
#else
#define ATTRIBUTE_UNUSED
#endif
#define PyvirConnect_Get(v) (((v) == Py_None) ? NULL : \
(((PyvirConnect_Object *)(v))->obj))
typedef struct {
PyObject_HEAD
virConnectPtr obj;
} PyvirConnect_Object;
#define PyvirDomain_Get(v) (((v) == Py_None) ? NULL : \
(((PyvirDomain_Object *)(v))->obj))
typedef struct {
PyObject_HEAD
virDomainPtr obj;
} PyvirDomain_Object;
PyObject * libvir_intWrap(int val);
PyObject * libvir_longWrap(long val);
PyObject * libvir_charPtrWrap(char *str);
PyObject * libvir_constcharPtrWrap(const char *str);
PyObject * libvir_charPtrConstWrap(const char *str);
PyObject * libvir_virConnectPtrWrap(virConnectPtr node);
PyObject * libvir_virDomainPtrWrap(virDomainPtr node);
/*
* types.c: converter functions between the internal representation
* and the Python objects
*
* Copyright (C) 2005 Red Hat, Inc.
*
* Daniel Veillard <veillard@redhat.com>
*/
#include "libvir_wrap.h"
PyObject *
libvir_intWrap(int val)
{
PyObject *ret;
#ifdef DEBUG
printf("libvir_intWrap: val = %d\n", val);
#endif
ret = PyInt_FromLong((long) val);
return (ret);
}
PyObject *
libvir_longWrap(long val)
{
PyObject *ret;
#ifdef DEBUG
printf("libvir_longWrap: val = %ld\n", val);
#endif
ret = PyInt_FromLong(val);
return (ret);
}
PyObject *
libvir_charPtrWrap(char *str)
{
PyObject *ret;
#ifdef DEBUG
printf("libvir_xmlcharPtrWrap: str = %s\n", str);
#endif
if (str == NULL) {
Py_INCREF(Py_None);
return (Py_None);
}
ret = PyString_FromString(str);
free(str);
return (ret);
}
PyObject *
libvir_constcharPtrWrap(const char *str)
{
PyObject *ret;
#ifdef DEBUG
printf("libvir_xmlcharPtrWrap: str = %s\n", str);
#endif
if (str == NULL) {
Py_INCREF(Py_None);
return (Py_None);
}
ret = PyString_FromString(str);
return (ret);
}
PyObject *
libvir_charPtrConstWrap(const char *str)
{
PyObject *ret;
#ifdef DEBUG
printf("libvir_xmlcharPtrWrap: str = %s\n", str);
#endif
if (str == NULL) {
Py_INCREF(Py_None);
return (Py_None);
}
ret = PyString_FromString(str);
return (ret);
}
PyObject *
libvir_virDomainPtrWrap(virDomainPtr node)
{
PyObject *ret;
#ifdef DEBUG
printf("libvir_virDomainPtrWrap: node = %p\n", node);
#endif
if (node == NULL) {
Py_INCREF(Py_None);
return (Py_None);
}
ret =
PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virDomainPtr",
NULL);
return (ret);
}
PyObject *
libvir_virConnectPtrWrap(virConnectPtr node)
{
PyObject *ret;
#ifdef DEBUG
printf("libvir_virConnectPtrWrap: node = %p\n", node);
#endif
if (node == NULL) {
Py_INCREF(Py_None);
return (Py_None);
}
ret =
PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virConnectPtr",
NULL);
return (ret);
}
......@@ -3,7 +3,7 @@
* Description: This module implements the hash table support used in
* various places in the library.
*
* Copy: See Copyright for the status of this software.
* Copy: Copyright (C) 2005 Red Hat, Inc.
*
* Author: Bjorn Reese <bjorn.reese@systematic.dk>
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册