dmalcolm (dmalcolm) wrote,

librpm and python 3(000)

I've had a go at hacking up librpm's python bindings so that they work with both python 2 and python 3.

Here's my progress so far, trying out some sample rpm python code with py3k. Some things appear to be working, but I really need a unit test suite to do this properly, I think.

[david@brick rpm]$ PYTHONPATH=/home/david/coding/python3/rpm-python-bindings/install-prefix/lib/python3.1/site-packages python3
Python 3.1.1 (r311:74480, Oct 1 2009, 12:20:21)
[GCC 4.4.1 20090725 (Red Hat 4.4.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpm
/home/david/coding/python3/rpm-python-bindings/install-prefix/lib/python3.1/site-packages/rpm/ DeprecationWarning: Type rpm.hdr defines tp_reserved (formerly tp_compare) but not tp_richcompare. Comparisons may not behave as intended.
from rpm._rpm import *
# (clearly I need to fix this)
>>> rpm.addMacro("_dbpath", "/var/lib/rpm")
>>> ts = rpm.TransactionSet()
>>> mi = ts.dbMatch()
>>> for h in mi:
... print("%s-%s-%s" % (h['name'], h['version'], h['release']))

etc. (note how print has become a function, and how the data is coming back as "bytes", not as strings)

For the gory details, I sent my patches here:

Does anyone have a good test suite for the python rpm API?

Tags: fedora, python, rpm
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded