Skip to content

[codex] misc: Fix Python runtime detection#857

Merged
jensen-yan merged 1 commit into
xs-devfrom
fix-python
May 21, 2026
Merged

[codex] misc: Fix Python runtime detection#857
jensen-yan merged 1 commit into
xs-devfrom
fix-python

Conversation

@jensen-yan
Copy link
Copy Markdown
Collaborator

@jensen-yan jensen-yan commented May 20, 2026

Motivation

Some builds can fail during SCons configure with Checking Python version... no even after Python.h is found. This is not necessarily a Python version problem: the configure probe links an embedded Python test and then runs it, so non-system Python installations such as conda also need their libpython directory to be visible to the runtime loader.

The README and quick-start docs also still recommended installing a Python 3.8 conda environment for high Python versions, which is misleading now that Ubuntu 24.04's default Python 3.12 works.

Approach

  • Parse python*-config output with shlex.split().
  • Reuse absolute -L paths from python*-config as runtime library paths for embedded Python configure probes and resulting binaries.
  • Remove the old Python 3.8/miniconda guidance from README and quick start.
  • Update the documented recommended environment to Ubuntu 24.04 with system Python 3.12.

Validation

  • python3 -m py_compile SConstruct
  • Forced SCons configure reached and passed Checking Python version... 3.12.3; the bounded build command later timed out during generated-header work, not during Python detection.
  • The generated Python configure probe includes RUNPATH entries derived from python3-config -L paths and runs successfully, printing 3.12.3.

Summary by CodeRabbit

  • Documentation

    • Updated build/setup instructions to target Ubuntu 24.04 and recommend the default system Python 3.12
    • Improved troubleshooting guidance for configuration-stage errors with clearer diagnostics
    • Removed legacy alternative Python-version setup instructions for a simpler environment
  • Improvements

    • Better handling of embedded-Python library locations so runtime dependencies are found more reliably

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fa5c219b-cafe-4c00-8804-af648fc8abe4

📥 Commits

Reviewing files that changed from the base of the PR and between 3c85ed2 and 39fdfc2.

📒 Files selected for processing (3)
  • README.md
  • SConstruct
  • docs/quick_start.md
✅ Files skipped from review due to trivial changes (2)
  • docs/quick_start.md
  • README.md

📝 Walkthrough

Walkthrough

This PR standardizes build/docs on Ubuntu 24.04 with system Python 3.12, updates SConstruct to parse embedded-Python flags with shlex and add absolute -L paths to RPATH, and refactors FAQ troubleshooting to point users to scons_config.log for configure-stage errors.

Changes

Ubuntu 24.04 and Python 3.12 Standardization

Layer / File(s) Summary
Embedded Python library path configuration
SConstruct
Adds shlex import and updates flag_filter helper to robustly parse embedded-Python flags using shlex.split, extracts absolute -L library paths, and propagates them to build RPATH and runtime LD_LIBRARY_PATH to ensure non-system libpython discoveries.
Build environment setup documentation
README.md, docs/quick_start.md
Both files update dependency setup guidance from Ubuntu 22.04 to Ubuntu 24.04, document that system Python 3.12 works without miniconda or version downgrade, remove legacy Python environment setup sections, and clarify Docker usage preference.
FAQ and diagnostic troubleshooting guidance
README.md, docs/quick_start.md
FAQ "Python not found" entries now direct users to inspect build/RISCV/gem5.build/scons_config.log for configure-stage errors, clarify GCC vs clang warning flag issues, and remove outdated Python environment troubleshooting steps in favor of build log inspection.

🎯 2 (Simple) | ⏱️ ~12 minutes

A rabbit hops through build logs with glee,
Ubuntu twenty-four-oh-four, Python three-twelve, all working free!
No miniconda, no downgrade pains—just system tools at hand,
Library paths now travel right through RPATH-land. 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fix Python runtime detection' partially addresses the main technical change (RPATH derivation from python-config), but obscures it with a generic '[codex] misc:' prefix and does not clearly convey the primary objective of updating documentation to recommend Ubuntu 24.04 with Python 3.12. Consider using a more specific title like 'Update Python environment docs to Ubuntu 24.04 and fix embedded Python runtime detection' to clarify the main changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-python

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jensen-yan jensen-yan marked this pull request as ready for review May 20, 2026 10:31
tastynoob
tastynoob previously approved these changes May 20, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/quick_start.md`:
- Line 170: Replace the ambiguous phrase "参考关于在 Docker 中运行的 README" in
docs/quick_start.md (the sentence at Line 170) with a direct Markdown link to
the repository's Docker README so readers can jump directly; update the text to
something like "参考关于在 Docker 中运行的 README(链接)" where the link points to the
project’s Docker README file, ensuring the markdown uses a relative path and the
link text clearly says "Docker README".

In `@README.md`:
- Around line 443-448: Replace the typo "apply this path" with "apply this
patch" in the README where the remediation instruction appears (the sentence
that precedes the command `git apply ext/xs_env/clang-warning-suppress.patch`
and currently reads "apply this path") so the wording matches the command and
removes confusion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 68428504-fbce-42f9-98f3-d441f26b42a5

📥 Commits

Reviewing files that changed from the base of the PR and between 7cc32ed and 3c85ed2.

📒 Files selected for processing (3)
  • README.md
  • SConstruct
  • docs/quick_start.md

Comment thread docs/quick_start.md
Comment thread README.md
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c85ed2aa2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread SConstruct Outdated
Change-Id: I6ba0133b8a160ea28d509c08212b0e2c9c076cdc
Copy link
Copy Markdown
Collaborator Author

Addressed in 39fdfc2efa: removed the global ENV['LD_LIBRARY_PATH'] mutation and now rely on the RPATH derived from python*-config -L paths. This keeps the runtime path scoped to the linked Python probe/binary and avoids contaminating later SCons child processes.

@github-actions
Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.3130 -
This PR 2.3130 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

1 similar comment
@github-actions
Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.3130 -
This PR 2.3130 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

@jensen-yan jensen-yan merged commit 03244f9 into xs-dev May 21, 2026
2 checks passed
@jensen-yan jensen-yan deleted the fix-python branch May 21, 2026 06:42
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