Python Dpkg module?

I am trying to do some package manipulation (a la dpkg), and although I can just popen or subprocess.call , I would rather do everything possible in python.

Unfortunately, I could not find the python module to do the trick.

I saw a link to python-deb , but it seems to be non-existent. python-apt may seem like a potential solution, but AFAICT cannot handle individual .deb files.

Does anyone know a good python dpkg solution?

+4
source share
4 answers

In fact, python-apt allows you to work with these files directly. Here is an example:

 from apt.debfile import DebPackage from pprint import pprint pkg = DebPackage('/tmp/wajig_2.7_all.deb') pprint(pkg.filelist) 

Output:

 $ ./script.py ['./', 'etc/', 'etc/bash_completion.d/', ... 'usr/bin/', 'usr/bin/wajig'] 

This is not as complete as I would like sadly, but it has a bunch of functionality.

( more details )

+4
source

Python-apt is probably the canonical way of doing this, but if you need the ability to work on non-debian platforms, I released an early version of my own reimplementation of some of its parts:

https://github.com/TheClimateCorporation/python-dpkg

+1
source

I have little knowledge of python modules for deb, but I would like to point out that subprocess calls are not what * ix needs, it's on Windows. Windows seems to be trying to break up calls as a subprocess and parsing, but * ix usually makes it quite viable.

0
source

Obviously, Gdebi is python based. If gdebi is installed, you have access to it using the GDebi module.

I can't find any documentation, so I'm not sure if this should be a public API, but this can do the trick.

0
source

All Articles