Registry / devops / koji
library1.36.0pypypi✓ verified 85d ago

Koji is a powerful, distributed system for building and tracking RPM packages, primarily used within the Fedora and Red Hat ecosystems. The `koji` Python package provides the official client library, allowing programmatic interaction with a Koji Hub, including querying build information, submitting tasks, and managing users. It is actively maintained and currently at version 1.36.0, with releases typically tied to major Koji system updates.

pip install koji
INSTALL
IMPORT
SIG · KOJI
K
koji
devopspythonv1.36.0
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
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.910 runs
build_error
glibc
py 3.103.910 runs
build_error
Code
Verified usage

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

koji
import koji
The entire koji module is typically imported to access its client session and utility functions.
ClientSession
import koji session = koji.ClientSession(...)
ClientSession is the primary class for interacting with a Koji Hub.

This quickstart demonstrates connecting to a public Koji Hub and querying its version. For anonymous access, no special configuration is needed. For tasks requiring authentication (e.g., submitting builds, modifying tags), Koji typically uses configuration files like `~/.koji/config` or environment variables for certificates.

import koji import os # Koji Hub URL. For authenticated access, Koji typically reads ~/.koji/config # or uses certificate paths. # We'll use a public read-only hub for this quickstart. KOJI_HUB_URL = os.environ.get('KOJI_HUB_URL', 'https://koji.fedoraproject.org/kojihub') try: session = koji.ClientSession(KOJI_HUB_URL) print(f"Connected to Koji Hub: {KOJI_HUB_URL}") # Get and print the Koji server version to confirm connectivity server_info = session.getKojiVersion() print(f"Koji server version: {server_info['version']} ({server_info['release']})") # Example: Get info for a specific build (if you know an NVR) # For a real scenario, you'd look up a valid NVR first. # print("\nTrying to find a specific build (e.g., 'kernel-5.18.11-200.fc36')") # try: # build_info = session.getBuild('kernel-5.18.11-200.fc36') # print(f"Found build: {build_info['nvr']} (ID: {build_info['build_id']})") # except Exception as e: # print(f"Could not find build or an error occurred: {e}") except koji.AuthError as e: print(f"Authentication Error: {e}") print("\nIf you intend to use authenticated access, ensure your Koji configuration (e.g., ~/.koji/config) is correct.") except Exception as e: print(f"An error occurred during Koji interaction: {e}")
koji --version
Debug
Known issues
gotchaAuthenticated Koji client operations (e.g., submitting tasks, managing tags) typically require specific configuration files (`~/.koji/config` or `/etc/koji.conf`) with server URL, certificates, and SSL verification settings. Anonymous read-only access is often possible without this.
fix
Ensure your Koji configuration file is correctly set up for the target Koji Hub, including appropriate certificate paths and permissions, if you encounter `koji.AuthError`.
affects: All versions
gotchaWhile Koji supports Python 2.7, it is primarily developed and deployed with Python 3. Mixing Python 2 scripts with modern Python 3 environments or relying on Python 2 features can lead to encoding issues or compatibility problems. New development should target Python 3.
fix
Develop new Koji client scripts using Python 3. Ensure your Python environment is consistent.
affects: <=1.x.x (gradual transition from Py2 to Py3)
gotchaKoji's client methods often return dictionary structures. The exact keys and their types can vary slightly between Koji server versions or for different types of objects. Always validate dictionary keys before accessing them.
fix
Use `.get()` with a default value (e.g., `obj.get('key', None)`) or check for key existence (e.g., `if 'key' in obj:`) when accessing dictionary values returned by Koji API calls to prevent `KeyError`.
affects: All versions
Errors
Common errors & fixes
koji.AuthError: authentication failed
The Koji client failed to authenticate with the Koji Hub, usually due to missing or incorrect certificates, an invalid Koji configuration file, or incorrect permissions.
fix
Verify the Koji configuration file (e.g., `~/.koji/config` or `/etc/koji.conf`) specifies the correct `server`, `cert`, `serverca`, and `topdir` paths. Ensure certificate files exist and are readable by the user running the script.
xmlrpc.client.Fault: <Server message>
This is a server-side error returned by the Koji Hub, indicating an issue with the parameters of your API call (e.g., a non-existent build ID, an invalid tag name) or a server-side problem.
fix
Examine the specific 'Server message' for clues. Check the parameters passed to the Koji API function (e.g., `getBuild`, `listBuilds`) to ensure they are valid and refer to existing entities on the Koji Hub.
socket.gaierror: [Errno -2] Name or service not known
The Koji Hub URL specified in `ClientSession` or your Koji configuration file is incorrect or unreachable, or there's a DNS resolution issue.
fix
Double-check the `KOJI_HUB_URL` (or `server` setting in your config). Ensure the hostname is correct and that your machine can resolve and connect to it (e.g., using `ping` or `curl`).
Upgrade
Version history
1.36.0latest on PyPI · released Mar 23, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
koji — pip install koji · libregistry