{
  "id": 22944896,
  "title": "Do you build your Python SBOM from requirements.txt or from what is actually installed?",
  "url": "https://urgent.news/2026/12/01/do-you-build-your-python-sbom-from-requirements-txt-or-from-what-is",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-12-01T11:14:16.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/alessio99xx/do-you-build-your-python-sbom-from-requirementstxt-or-from-what-is-actually-installed-5clc"
  },
  "original_language": null,
  "account": "Building an SBOM (Software Bill of Materials) for a Python service can be a bit of a conundrum. You have two primary sources to draw from: the requirements.txt file, a lock file, or pyproject.toml, versus the actual packages installed in the production environment. These two sources often yield different results.\n\nThe second source - what's installed in the running environment - can uncover issues the first one might miss. This includes transitive dependencies you didn't explicitly list, packages installed manually for debugging, or versions that drifted due to looser pinning than anticipated. I developed a small Python tool to address this approach. It reads the installed packages using the importlib.metadata standard library module and outputs CycloneDX 1.5 JSON format with Package URLs. The tool operates offline, without requiring any PyPI calls.\n\nWhile writing this tool, I encountered a few unexpected nuances. Package names must be normalized to the PyPI standard format, so Ruamel.Yaml becomes ruamel-yaml. If different tools normalize the names differently, comparing SBOMs can quickly become noisy. License data can be incomplete or inconsistent based on the available metadata. Packages might even appear twice within a single environment, requiring decisions on how to report them.\n\nIt's important to remember that an SBOM is not a vulnerability scan. It simply tells you what's installed. Matching it against known vulnerabilities is a separate step. So, how do others handle this? Do you generate the SBOM from the lock file, the running image, or both? Do you run vulnerability scans like Syft or Trivy within the CI pipeline, or do you generate the SBOM within the running environment? Have you ever been asked for an SBOM by a customer, and in what format? CycloneDX or SPDX? How do you deal with missing or messy license fields? I'd love to hear about your pipeline, particularly for small teams without a dedicated security person.",
  "summary": "Quick question for anyone who has had to hand over an SBOM for a Python service (customer questionnaire, security review, or just your own \"what is actually running in prod?\"). There are two places you can build it from, and they don't always agree: What you declared : requirements.txt, a lock file, pyproject.toml. What is actually installed in the environment that runs the code: the venv or the…",
  "summary_source": "publisher",
  "key_points": [],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}