[zypp-devel] libzypp-bindings: More API support
Hi all, We would like to use more python API in libzypp-bindings, such as PoolQuery, and I have tried to import the related API to libzypp, but fails. Here's the patch I used to import PoolQuery API: --- diff -uNr libzypp-bindings-0.5.8/swig/PoolQuery.i libzypp-bindings-0.5.8.new/swig/PoolQuery.i --- libzypp-bindings-0.5.8/swig/PoolQuery.i 1970-01-01 08:00:00.000000000 +0800 +++ libzypp-bindings-0.5.8.new/swig/PoolQuery.i 2011-08-30 13:19:41.067491333 +0800 @@ -0,0 +1 @@ +%include <zypp/PoolQuery.h> diff -uNr libzypp-bindings-0.5.8/swig/zypp.i libzypp-bindings-0.5.8.new/swig/zypp.i --- libzypp-bindings-0.5.8/swig/zypp.i 2011-08-30 13:18:41.251366083 +0800 +++ libzypp-bindings-0.5.8.new/swig/zypp.i 2011-08-30 13:48:54.900428645 +0800 @@ -59,6 +59,7 @@ #include "zypp/Resolver.h" #include "zypp/pool/GetResolvablesToInsDel.h" +#include "zypp/PoolQuery.h" #include "zypp/Product.h" using namespace boost; @@ -159,6 +160,7 @@ %include "TmpPath.i" %include "Resolver.i" %include "ZConfig.i" +%include "PoolQuery.i" %ignore zypp::ZYpp::setTextLocale; %ignore zypp::ZYpp::getTextLocale; --- But, I have got the following build error. ########### /home/abuild/rpmbuild/BUILD/libzypp-bindings-0.5.8/swig/python/libzypp_python.cc: In function 'PyObject* _wrap___lshift__(PyObject*, PyObject*)': /home/abuild/rpmbuild/BUILD/libzypp-bindings-0.5.8/swig/python/libzypp_python.cc:122672: error: redefinition of 'PyObject* _wrap___lshift__(PyObject*, PyObject*)' /home/abuild/rpmbuild/BUILD/libzypp-bindings-0.5.8/swig/python/libzypp_python.cc:107956: error: 'PyObject* _wrap___lshift__(PyObject*, PyObject*)' previously defined here /home/abuild/rpmbuild/BUILD/libzypp-bindings-0.5.8/swig/python/libzypp_python.cc: In function 'PyObject* _wrap_dumpOn(PyObject*, PyObject*)': /home/abuild/rpmbuild/BUILD/libzypp-bindings-0.5.8/swig/python/libzypp_python.cc:122718: error: redefinition of 'PyObject* _wrap_dumpOn(PyObject*, PyObject*)' /home/abuild/rpmbuild/BUILD/libzypp-bindings-0.5.8/swig/python/libzypp_python.cc:122336: error: 'PyObject* _wrap_dumpOn(PyObject*, PyObject*)' previously defined here /home/abuild/rpmbuild/BUILD/libzypp-bindings-0.5.8/swig/python/libzypp_python.cc: In function 'PyObject* _wrap_ZYppFactoryException_locker_pid(PyObject*, PyObject*)': /home/abuild/rpmbuild/BUILD/libzypp-bindings-0.5.8/swig/python/libzypp_python.cc:123604: warning: 'pid_t zypp::ZYppFactoryException::locker_pid() const' is deprecated (declared at /usr/include/zypp/ZYppFactory.h:33) ########### Do you have any comments? Thanks In advance. Qiang
* Zhang, Qiang Z <qiang.z.zhang@intel.com> [Aug 30. 2011 07:54]:
Hi all,
We would like to use more python API in libzypp-bindings, such as PoolQuery, and I have tried to import the related API to libzypp, but fails.
Uhm, I'm not very fond of exposing more of libzypp's C++ details to the bindings. I'd rather access the underlying satsolver library for which clean bindings already exist. Klaus --- SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) Maxfeldstraße 5, 90409 Nürnberg, Germany -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
On Thursday 01 September 2011 14:48:59 Klaus Kaempf wrote:
* Zhang, Qiang Z <qiang.z.zhang@intel.com> [Aug 30. 2011 07:54]:
Hi all,
We would like to use more python API in libzypp-bindings, such as PoolQuery, and I have tried to import the related API to libzypp, but fails.
Uhm, I'm not very fond of exposing more of libzypp's C++ details to the bindings. I'd rather access the underlying satsolver library for which clean bindings already exist.
Well, class sat::LookupAttr is a generic and quite easy to use wrapper around satsolvers dataiterator stuff. Not exposing that many C++ details. Just define the attribute or substructure attribute, maybe add some matcher (glob/regex/..) and get back an iterator to navigate through the results. PoolQuery basically runs multiple LookupAttr queries in parallel, combining the results. Unfortunately PoolQuery is not generic. You can just combine a few predefined queries (name && arch && repo..). So I would not offer this in the bindings. Instead I'd provide a generic interface that allows to combine arbitrary LookupAttr queries. This way you can easily build queries for whatever purpose: (name="foo*") && (repo="baa" || ! arch="i386") -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres SUSE LINUX Products GmbH, Development, ma@suse.de GF:Jeff Hawn,Jennifer Guild,Felix Imendörffer, HRB16746(AG Nürnberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+ -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
On 08/30/2011 07:53 AM, Zhang, Qiang Z wrote:
Hi all,
We would like to use more python API in libzypp-bindings, such as PoolQuery, and I have tried to import the related API to libzypp, but fails.
Here's the patch I used to import PoolQuery API:
Just out of curiosity, what are you exactly using the bindings for? -- Duncan Mac-Vicar P. - http://www.suse.com/ SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) Maxfeldstraße 5, 90409 Nürnberg, Germany -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
We want to clean up the code of mic2, which use libzypp-bindings. Currently we just use libzypp-bindings to resolve dependencies, and download/install work is controlled in mic2. We have several points to refine the code: 1. Support download/install callback in libzypp-bindings, so that we can let libzypp-binding to download/install packages, and return the progress by callback function. These feature has been implemented in libzypp-bindings with the help of Klaus, but always segmentation fault. 2. Support advanced search in libzypp-bindings, such as wildcard(*) and pattern search. Currently we have just iterate the pool and found the correct poolItem, have not use any search function of libzypp. Use case as follows: (1) PoolQuery. addAttribute(sat::SolvAttr::name, "X11-*"); // Support wildcard search (2) pattern = pool.byIdentBegin (zypp.ResKind.pattern, "xyz") // pattern search My latest libzypp-bindings can be downloaded from here: http://download.meego.com/live/home:/xiaoqiang:/branches:/Tools:/Building/ Attached is the test code. Run test case: [root@localhost mic]# python zypppkgmgr.py zypp architecture: i686 Starting to download: glibc-common-2.13-14.11.i686.rpm Download at 0 % Download at 0 % Download at 10 % Download at 10 % Segmentation fault (core dumped) [root@localhost mic]# python zypppkgmgr.py zypp architecture: i686 Starting to install ncurses Install of ncurses at 100 % Install of ncurses at 0 % Install of ncurses at 0 % Install of ncurses at 100 % Install of ncurses finished with problem no_error : Segmentation fault (core dumped) Thanks Qiang -----Original Message----- From: Duncan Mac-Vicar P. [mailto:dmacvicar@suse.de] Sent: Thursday, September 01, 2011 8:52 PM To: zypp-devel@opensuse.org Subject: Re: [zypp-devel] libzypp-bindings: More API support On 08/30/2011 07:53 AM, Zhang, Qiang Z wrote:
Hi all,
We would like to use more python API in libzypp-bindings, such as PoolQuery, and I have tried to import the related API to libzypp, but fails.
Here's the patch I used to import PoolQuery API:
Just out of curiosity, what are you exactly using the bindings for? -- Duncan Mac-Vicar P. - http://www.suse.com/ SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) Maxfeldstraße 5, 90409 Nürnberg, Germany -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
participants (4)
-
Duncan Mac-Vicar P.
-
Klaus Kaempf
-
Michael Andres
-
Zhang, Qiang Z