CycloneDX Software Bill of Materials (SBOM) generator for Python projects and environments

7.3.0 · active · verified Sat Apr 11

cyclonedx-bom is a Python library and command-line tool for generating CycloneDX Software Bill of Materials (SBOM) for Python projects and environments. It supports various formats and schema versions of the CycloneDX specification. The current version is 7.3.0, and it maintains an active release cadence with frequent updates, with the latest release on March 30, 2026.

Warnings

Install

Quickstart

Demonstrates how to generate a CycloneDX SBOM for the current Python environment using the `cyclonedx-py` command-line tool and capture its JSON output.

import subprocess
import json
import os

# Generate an SBOM for the current Python environment in JSON format
# and print it to stdout. In a real scenario, you'd typically direct to a file.
try:
    # Using `-o -` directs output to stdout
    result = subprocess.run(
        ['cyclonedx-py', 'environment', '--output-format', 'JSON', '-o', '-'],
        capture_output=True,
        text=True,
        check=True
    )
    sbom_data = json.loads(result.stdout)
    print("Successfully generated CycloneDX SBOM (first 200 chars):")
    print(json.dumps(sbom_data, indent=2)[:200] + "...")
except subprocess.CalledProcessError as e:
    print(f"Error generating SBOM: {e}")
    print(f"Stdout: {e.stdout}")
    print(f"Stderr: {e.stderr}")
except json.JSONDecodeError:
    print("Failed to decode JSON from SBOM output.")
    print(f"Raw output: {result.stdout}")

view raw JSON →