Python API ========== The Python API is what a project needs to add its own knowledge to the SBOM: the hatchling build hook and the content provider it calls, with the types those take and return. Everything else, from embedding to validation, runs through the :doc:`cli`. The core is importable from ``python_sbom`` without hatchling; the hook lives in ``python_sbom.hatch``. .. py:data:: python_sbom.__version__ :type: str The installed version of python-sbom. Hatchling build hook -------------------- .. autoclass:: python_sbom.hatch.SbomBuildHook :members: content_provider Content provider ---------------- .. autoclass:: python_sbom.ContentProvider :members: bundled_wheel, contributions .. autoclass:: python_sbom.ProviderContext :members: read .. autoclass:: python_sbom.BundledWheelInfo .. autoclass:: python_sbom.Contributions .. autoclass:: python_sbom.Settings .. autoclass:: python_sbom.ProjectIdentity Component types --------------- These :class:`~typing.TypedDict` types describe the JSON a provider builds. Each follows the CycloneDX 1.6 object of the same name; the `CycloneDX 1.6 reference `_ describes every key. .. py:class:: python_sbom.Component A CycloneDX 1.6 component, a distribution, an application, the interpreter or a file, as a dictionary with the keys the CycloneDX component object defines. python-sbom uses ``type``, ``bom-ref``, ``name``, ``version``, ``purl``, ``supplier`` (an :class:`~python_sbom.OrganizationalEntity`), ``authors`` (:class:`~python_sbom.Contact`), ``description``, ``licenses`` (:class:`~python_sbom.License`), ``copyright``, ``hashes`` (:class:`~python_sbom.Hash`), ``externalReferences`` (:class:`~python_sbom.ExternalReference`), ``properties`` (:class:`~python_sbom.Property`), ``evidence`` (:class:`~python_sbom.Evidence`) and the nested ``components``. .. autoclass:: python_sbom.Property :no-members: .. autoclass:: python_sbom.Dependency :no-members: .. autoclass:: python_sbom.OrganizationalEntity :no-members: .. autoclass:: python_sbom.Contact :no-members: .. autoclass:: python_sbom.ExternalReference :no-members: .. autoclass:: python_sbom.Hash :no-members: .. autoclass:: python_sbom.License :no-members: .. autoclass:: python_sbom.LicenseInfo :no-members: .. autoclass:: python_sbom.Evidence :no-members: .. autoclass:: python_sbom.Identity :no-members: .. autoclass:: python_sbom.IdentityMethod :no-members: Errors ------ .. autoexception:: python_sbom.SbomError