Skip to main content

Read rpm archive files

Project description


Build Status Actions Status PyPI version

Tools for inspecting RPM files in python. This module is modeled after the tarfile module.


$ python -m pip install -U rpmfile

If you want to use rpmfile with zstd compressed rpms, you'll need to install the zstandard module.

zstd also requires that you are using Python >= 3.5

$ python -m pip install -U zstandard


See the tests for more examples.

import rpmfile

with'file.rpm') as rpm:

    # Inspect the RPM headers
    print(rpm.headers.get('arch', 'noarch'))

    # Extract a fileobject from the archive
    fd = rpm.extractfile('./usr/bin/script')

    for member in rpm.getmembers():

Command line usage

You can use rpmfile via it's module invocation or via rpmfile command if your PATH environment variable is configured correctly. Pass --help for all options.

List RPM contents

curl -sfL '' | gzip -d - | python -m rpmfile -l -

Extract files

curl -sfL '' | gzip -d - | rpmfile -xv -

Extract files to directory

curl -sfL '' | gzip -d - | rpmfile -xvC /tmp -

Display RPM information (similar to command rpm -qip in Linux)

curl -sfL '' |gzip -d - | rpmfile -i -
Name        : something
Version     : 1.02
Release     : 1
Architecture: noarch
Group       : default
Size        : 1234
License     : BSD
Signature   : None
Source RPM  : some.src.rpm
Build Date  : Tue Apr  9 08:55:16 2019
Build Host  : demo
URL         :
Summary     : Example of something
Description : 
The description of something.
It can display more than one line.


  • rpmfile.RPMFile: The RPMFile object provides an interface to a RPM archive
  • rpmfile.RPMInfo: An RPMInfo object represents one member in a RPMFile.


The black formater should be used on all files before submitting a contribution. Version 19.10b0.

$ pip install black==19.10b0
$ black .

Code in this module was borrowed from:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rpmfile-2.0.0.tar.gz (20.6 kB view hashes)

Uploaded Source

Built Distribution

rpmfile-2.0.0-py3-none-any.whl (17.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page