YumLocalPackage in python 3

34 Views Asked by At

On Python 2 I have a script that reads local RPM packages in a directory as in the code below. Now moving to RHEL8 and Python 3 the whole Yum python API has changed to DNF and Hawkey. How do get the same done in Python 3, DNF, hawkey?

import yum.packages
for package_file in package_files:
    # A 'package_file' is a for example '/path/to/foo-1.2.noarch.rpm'
    lp = yum.packages.YumLocalPackage(filename=package_file)
    for entry in lp.returnFileEntries():
        # process the filenames.
        pass
    for dep in lp.returnPrcoNames('requires'):
        # process the requires-dependencies.
        pass

Just trying to read plain RPM files. The directory is not a repo. The readthedocs.io documentation is not helping me any further. Trying to reverse engineer the DNF/hawkey source code is also not helping.

0

There are 0 best solutions below