Skip to content

feat(environment): with -E and no <python>, probe the current interpreter - #1134

Open
juliosuas wants to merge 2 commits into
CycloneDX:mainfrom
juliosuas:feat/environment-E-current-python
Open

juliosuas wants to merge 2 commits into
CycloneDX:mainfrom
juliosuas:feat/environment-E-current-python

Conversation

@juliosuas

Copy link
Copy Markdown
Contributor

Description

Follow-up to #1106. Without a target <python>, -E did nothing: the SBOM reused the running interpreter's sys.path, which already honored parent PYTHON* variables at startup. With this change, cyclonedx-py environment -E (no target) probes sys.executable with python -E, same as when a target is given. Default behavior without -E is unchanged.

The idea comes from @EltonChang1's #1123, so he's credited as co-author. Help text and docs/usage.rst are updated, and a regression test covers the no-target case (it fails without the fix).

Resolves or fixes issue: #1045

AI Tool Disclosure

  • My contribution does not include any AI-generated content
  • My contribution includes AI-generated content, as disclosed below:
    • AI Tools: Cursor coding agent
    • LLMs and versions: Cursor coding agent (model not exposed)
    • Prompts: Implement the no-target -E probe from #1123 as a minimal follow-up to #1106, with a regression test and docs; I reviewed and tested the result.

Affirmation

…erpreter

Without a target `<python>`, `-E` had no effect: the SBOM reused the
already-imported `sys.path`, which honored parent `PYTHON*` env vars at
startup. Now the current executable is probed with `python -E` instead.

Idea from CycloneDX#1123 by Elton Chang. Follow-up to CycloneDX#1106, see CycloneDX#1045.

Co-authored-by: Elton Chang <80650461+Notle-eltoN@users.noreply.github.com>
Signed-off-by: Julio César Suástegui <juliosuas@gmail.com>
@juliosuas
juliosuas requested a review from a team as a code owner October 29, 2026 06:41
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity ✅ 0 (≤ 20 complexity)
Duplication 0

View in Codacy

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.

@read-the-docs-community

read-the-docs-community Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 CycloneDX Python SBOM Tool | 🛠️ Build #35499469 | 📁 Comparing b41bbb7 against latest (5a81ff8)

  🔍 Preview build  

1 file changed
± usage.html

@jkowalleck

Copy link
Copy Markdown
Member

let's broaden the topic a bit:
lets have this proposed new behavior for -S and -E

…erpreter

Extends the previous change to `-S` as requested in review: when `-S`
and/or `-E` is given without a target `<python>`, the current executable
is probed with the corresponding flag(s) instead of reusing the
already-imported `sys.path`. Without either flag, behavior is unchanged.

Co-authored-by: Elton Chang <80650461+Notle-eltoN@users.noreply.github.com>
Signed-off-by: Julio César Suástegui <juliosuas@gmail.com>
@juliosuas

Copy link
Copy Markdown
Contributor Author

Makes sense. Extended it so -S behaves the same way when no <python> is given (b41bbb7).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants