feat: support explicit main component metadata for projects without pyproject.toml #1105
Description
Description
Many Python projects, especially older or minimal ones, do not have a pyproject.toml file. In those cases, the current root-component metadata flow depends on --pyproject, which makes it difficult to generate an SBOM with the correct main component name and version unless a project metadata file is present.
This creates a gap for projects that are still valid Python applications or libraries but are not structured around PEP 621 metadata.
Solution
Add CLI support for explicitly setting the main component metadata when pyproject.toml is not available.
Specifically:
--mc-name: Set the main component name directly from the CLI--mc-version: Set the main component version directly from the CLI- Keep
--mc-typesupport for specifying the main component type - Use directory-name fallback as a final fallback when neither explicit metadata nor
pyproject.tomlis available
This should be supported for the requirements and environment subcommands, and should complement the existing --pyproject behavior rather than replacing it.
mc here stands for "main component".
Describe alternatives you've considered
- Inferring the root component name from the current directory name only
- Adding a custom config file for component metadata
Additional context
This is especially useful for legacy Python projects, simple scripts, or deployments where the project metadata is not stored in pyproject.toml, but the SBOM still needs a valid top-level component.
Contribution
- I am willing to provide an implementation
- I will wait until somebody else implements it
Activity
[-]Metadata Component Auto-Detection[/-][+]feat: metadata component auto-detection[/+][-]feat: metadata component auto-detection[/-][+]feat: support explicit main component metadata for projects without pyproject.toml[/+]jkowalleck commentedon Sep 28, 2026
what is the exact use case here?
Could you elaborate on a specific real-world example?
abhijit24learning commentedon Sep 29, 2026
When scanning a project via
requirements.txt, the generated SBOM currently has nometadata.componentat all - there's no main component name, version, or type populated in the output.There is already a way to supply this via
--pyproject, but for many projects that's not practical: not everyrequirements.txt-based project has (or wants to introduce) a pyproject.toml just to satisfy SBOM generation. In most cases, all that's actually needed is the main component's name and version - e.g.:I'd propose adding two new CLI options,
--mc-nameand--mc-version, so this metadata can be provided directly on the command line without requiring a pyproject.toml:--mc-name: setsmetadata.component.name--mc-version: setsmetadata.component.versionThese would complement the existing
--mc-typeand--pyprojectoptions rather than replace them - if--pyprojectis given, its values would still be used as the default, with--mc-name/--mc-versionacting as overrides when set. If no--pyprojectis given, they'd populatemetadata.componenton their own, which is currently impossible.jkowalleck commentedon Sep 29, 2026
i see. sounds like an interesting feature. 👍
please go ahead, and (draft) pullrequest an implementation.
abhijit24learning commentedon Sep 29, 2026
Thanks! I'll get a draft PR up shortly implementing --mc-name/--mc-version for the requirements and environment subcommands.