Repository navigation
feat(environment)!: add Python runtime component - #1146
Merged
jkowalleck merged 2 commits intoNov 19, 2026
Merged
Conversation
…t for CycloneDX 1.7 When CycloneDX 1.7 or later is requested, `cyclonedx-py environment` adds the Python runtime of the analyzed environment as a component with `type=platform` and `isExternal=true`, named `python` and versioned like `3.13.5`. The version is taken from the analyzed interpreter. If a root component is known, it depends on the runtime component. The implementation (CPython, PyPy, etc.) is intentionally not recorded. Requires `cyclonedx-python-lib` with `Component.is_external` (>= 11.12); with older versions of the lib, the runtime component is omitted. Resolves CycloneDX#597 Signed-off-by: juliosuas <juliosuas@users.noreply.github.com>
Documentation build overview
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | ✅ 9 (≤ 20 complexity) |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
jkowalleck
reviewed
Nov 16, 2026
…ime` Address review feedback: - Raise the minimum `cyclonedx-python-lib` to `>=11.12`, the first release with `Component.is_external` (CycloneDX 1.7), and drop the feature detection. - A new CLI switch `--add-python-runtime` decides whether the runtime component is added. Its version is taken via `__version4python(python)` for a target `<python>`, else `platform.python_version()` of the current interpreter. The spec-version gate and the extra `-S`/`-E` probing branch are gone, and `cli.py` is unchanged again. - The switch is off by default, so existing 1.7 snapshots stay as on main. Signed-off-by: Julio César Suástegui <5745504+juliosuas@users.noreply.github.com>
jkowalleck
reviewed
Nov 17, 2026
jkowalleck
self-requested a review
November 17, 2026 09:34
Member
|
the approach looks promising - feel free to transition from please adjust the PR description to the actual/final outcome. |
platform component for CycloneDX 1.7
juliosuas
marked this pull request as ready for review
November 17, 2026 21:27
jkowalleck
approved these changes
Nov 18, 2026
Member
|
This PR is ready to be merged. For the changelog I propose the following text: ### Breaking Changes
- Raise the minimum `cyclonedx-python-lib` version from `8` to `11.12`.
Environments pinned below `11.12` must upgrade.
### Features
- **environment**: Add opt-in `--add-python-runtime` to include the analyzed Python runtime as a `platform` component.
The root component depends on it when present; `isExternal` is included for CycloneDX 1.7+.@juliosuas what do you think? |
Contributor
Author
|
Thanks @jkowalleck, the changelog text looks good to me and matches the final behavior. Happy for this to be merged. |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements the expected outcome from #597 (comment) for
cyclonedx-py environmentonly:with the new opt-in switch
--add-python-runtime, the Python runtime of the analyzed environment is added as a component withtype=platformandisExternal=true.Example (
cyclonedx-py environment --add-python-runtime --sv 1.7 --pyproject pyproject.toml .venv):Behavior:
--add-python-runtimethe output is unchanged for every spec version.nameispython,versionisplatform.python_version(): taken from the target<python>via__version4python(started with the same-S/-Eflags as__path4python), otherwise from the current interpreter. The implementation (CPython, PyPy, etc.) is not recorded.isExternalis only serialized for CycloneDX 1.7+. With--svbelow 1.7 the component is still added, as a plainplatformcomponent (documented in help and docs).--pyproject), it depends on the runtime component. Without a root component, the runtime appears as a standalone node in the dependency graph.cyclonedx-python-lib>=11.12, <12(first release withComponent.is_external).Breaking change: the lower bound moves up from
>=8, so environments pinned tocyclonedx-python-lib8.x–11.11 need to upgrade.poetry,requirementsandpipenvare not covered.Open for follow-up (not part of this PR):
poetry/requirements/pipenv.Tests:
main.--add-python-runtime; version of the current interpreter; omitted by default.docs/usage.rst, environment section and--helpoutput.Resolves or fixes issue: #597
AI Tool Disclosure
Grok Bot (coding agent)not exposed by the toolImplement the expected outcome from #597 (python runtime as type=platform, isExternal=true, CycloneDX 1.7) in "cyclonedx-py environment" only, following CONTRIBUTING.md; regenerate snapshots; add tests and docs.andAddress the review feedback on this PR: raise the lib floor, put the runtime behind a CLI switch, simplify.I reviewed the changes and ran the test suite and linters locally.Affirmation