Registry / devops / rpm
library0.4.0pypypiunverified

The `rpm-shim` library (available on PyPI as `rpm`) provides a shim module to enable the use of system RPM Python bindings within Python virtual environments. This is necessary because native RPM Python bindings are typically tied to the system's RPM installation and are not distributed as standard Python packages. The library is currently at version 0.4.0 and releases are made on an as-needed basis to improve compatibility and search heuristics.

pip install rpm
INSTALL
IMPORT
SIG · RPM
R
rpm
devopspythonv0.4.0
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rpm
import rpm

This quickstart demonstrates installing `rpm-shim` (as `rpm`) into a virtual environment and then importing and using the `rpm` module. The core idea is that once `rpm-shim` is installed, a simple `import rpm` will make the system's RPM bindings available within your virtual environment. Ensure that your system has the native RPM Python bindings installed (e.g., `python3-rpm` package on RPM-based systems).

import venv import subprocess import sys import os # Create a dummy virtual environment for demonstration venv_path = './my_rpm_venv' if not os.path.exists(venv_path): venv.create(venv_path, with_pip=True) # Activate the virtual environment and install rpm-shim # In a real scenario, you'd activate the venv and then `pip install rpm` print(f"Installing rpm-shim in {venv_path}...") python_executable = os.path.join(venv_path, 'bin', 'python') subprocess.run([python_executable, '-m', 'pip', 'install', 'rpm'], check=True, capture_output=True) print("Installation complete.") # Now demonstrate importing and using rpm inside the virtual environment # (simulating execution within the venv) python_code = """ import sys import os try: import rpm print(f"Successfully imported rpm from: {rpm.__file__}") # Example of using rpm (check version as a simple call) print(f"RPM library version: {rpm.expand_macro('%{_rpm_version}')}") except ImportError as e: print(f"Failed to import rpm: {e}") print("Make sure system RPM Python bindings are installed on your system (e.g., python3-rpm).") """ print("\nRunning rpm import test within the virtual environment...") result = subprocess.run([python_executable, '-c', python_code], capture_output=True, text=True, check=True) print(result.stdout) if result.stderr: print("Stderr:", result.stderr) # Clean up (optional) # import shutil # shutil.rmtree(venv_path)
Debug
Known issues
gotchaPrior to `0.4.0`, `rpm-shim` might inadvertently pick up the `rpm` module from a different Python interpreter on the system (e.g., a system-wide Python 3.6 module) rather than the `rpm` bindings intended for the currently active virtual environment's Python version.
fix
Upgrade to `rpm-shim` version `0.4.0` or newer. This version prioritizes searching for the `rpm` module within the current interpreter's paths, resolving this common issue.
affects: <0.4.0
gotchaThe `rpm-shim` package on PyPI is *not* a standalone Python implementation of RPM functionality. It is a shim that relies on the presence of the native RPM Python bindings installed on the host system. If these bindings are not installed (e.g., the `python3-rpm` package on Fedora/RHEL/openSUSE), `rpm-shim` will fail to import `rpm` with an `ImportError`.
fix
Ensure that your operating system has the corresponding native Python RPM bindings installed. For most RPM-based Linux distributions, this means installing a package like `python3-rpm` (or `python-rpm` for Python 2) via your system's package manager (e.g., `dnf install python3-rpm` or `zypper install python3-rpm`).
affects: All versions
deprecatedThe `rpm-shim` library is specifically for making system RPM bindings available in virtual environments. There is no benefit to installing this shim on a bare system outside a virtual environment, and it could potentially conflict with or overwrite existing native RPM Python bindings if not handled carefully.
fix
Only install and use `rpm-shim` within a Python virtual environment where you explicitly need access to the system `rpm` module.
affects: All versions
Upgrade
Version history
0.4.0latest on PyPI · released Apr 8, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
14
Resources
rpm — pip install rpm · libregistry