Skip to content

fix: Install Python 3.12 alongside system Python 3.9#137

Merged
dgchinner merged 1 commit into
linux-system-roles:mainfrom
dgchinner:python-3.12-support
Jun 30, 2026
Merged

fix: Install Python 3.12 alongside system Python 3.9#137
dgchinner merged 1 commit into
linux-system-roles:mainfrom
dgchinner:python-3.12-support

Conversation

@dgchinner

@dgchinner dgchinner commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

The Slurm cluster infrastructure that uses images built by this role requires Python 3.11. RHEL 9.6 only provides Python 3.9 as the default, so this change installs Python 3.12 from the AppStream repository alongside the system default. The system default Python is left at 3.9 to avoid breaking OS tools (firewall-cmd, dnf, semanage, etc.) that depend on Python 3.9 modules not available for 3.12 (e.g. PyGObject). Python 3.12 is available as /usr/bin/python3.12.

Changes:

  • Add hpc_install_python312 variable (default: true) to defaults/main.yml
  • Add task to install python3.12, python3.12-pip, python3.12-devel
  • Add README.md documentation for the new variable
  • Disable python3.12 installation in CI test playbooks

Created-by-AI: Claude Opus 4.6 (1M context)

Prompt: new modification: the slurm cluster infrastructure that uses the build images requires support for python 3.12. RHEL 9.6 only provides python-3.9, so we need to install python-3.12 from the AppStream repository and set that to the default python version for the system.

Refinements:

  • Removed alternatives configuration that set python3.12 as system default, as it breaks OS tools like firewall-cmd that depend on python3.9-only modules (PyGObject/gi)
  • Python 3.12 is installed alongside system python, not as a replacement

Issue Tracker Tickets (Jira or BZ if any): https://redhat.atlassian.net/browse/RHELHPC-206

Summary by CodeRabbit

  • New Features

    • Added an optional Python 3.12 installation alongside the system Python 3.9, enabled by default.
    • When enabled, installs Python 3.12 along with pip and development packages while leaving the system default Python unchanged.
  • Documentation

    • Documented the new hpc_install_python312 variable, including what it installs and its default behavior.
  • Tests

    • Updated test scenarios to explicitly disable Python 3.12 where required for consistent coverage.

@dgchinner dgchinner requested review from richm and spetrosi as code owners June 24, 2026 04:29
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 509e24da-3a87-4d9d-813c-28d6ce7cb7e6

📥 Commits

Reviewing files that changed from the base of the PR and between 97bcecf and e144383.

📒 Files selected for processing (7)
  • README.md
  • defaults/.main.yml.swp
  • defaults/main.yml
  • tasks/main.yml
  • tests/tests_default.yml
  • tests/tests_include_vars_from_parent.yml
  • tests/tests_skip_toolkit.yml
✅ Files skipped from review due to trivial changes (3)
  • tests/tests_include_vars_from_parent.yml
  • tests/tests_skip_toolkit.yml
  • README.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/tests_default.yml
  • defaults/main.yml
  • tasks/main.yml

📝 Walkthrough

Walkthrough

Adds a new hpc_install_python312 boolean variable with a default of true, a conditional task to install Python 3.12 packages when enabled, matching README documentation, and test updates that disable the variable in existing scenarios.

Changes

Python 3.12 installation support

Layer / File(s) Summary
Variable default, task, and documentation
defaults/main.yml, tasks/main.yml, README.md
Defines hpc_install_python312: true, adds a conditional task that installs python3.12, python3.12-pip, and python3.12-devel with OSTree-aware package execution and retry logic, and documents the variable with its default, type, and behavior.
Test playbooks: disable Python 3.12 in test scenarios
tests/tests_default.yml, tests/tests_skip_toolkit.yml, tests/tests_include_vars_from_parent.yml
Adds hpc_install_python312: false to three existing test scenarios to keep Python 3.12 installation disabled during those runs.

Suggested reviewers

  • spetrosi
  • richm
🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description Format ⚠️ Warning The PR description lacks the required Feature/Enhancement, Reason, and Result sections; it only has narrative text and a Changes list. Rewrite the PR description to match the template: include a Feature/Enhancement section, a Reason section, and a Result section; keep the issue ticket optional.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title follows Conventional Commits and accurately summarizes the Python 3.12 installation change.
Description check ✅ Passed The description covers the enhancement, reason, result, and Jira ticket, though it does not use the exact template headings.
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.

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.

@dgchinner dgchinner changed the title [fix] Install Python 3.12 alongside system Python 3.9 fix: Install Python 3.12 alongside system Python 3.9 Jun 24, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/tests_include_vars_from_parent.yml (1)

47-64: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use the mandated test wrapper instead of direct import_role.

This test still invokes a role directly via import_role. Switch to the central wrapper task (tasks/run_role_with_clear_facts.yml) and pass these vars there, including hpc_install_python312.

As per path instructions: "CRITICAL: ... NEVER use ansible.builtin.import_role directly ... ALWAYS use ... ansible.builtin.include_tasks: tasks/run_role_with_clear_facts.yml".

🤖 Prompt for 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.

In `@tests/tests_include_vars_from_parent.yml` around lines 47 - 64, The test task
named "Import role" is using direct import_role instead of the mandated
centralized wrapper. Replace the entire import_role task with an include_tasks
task that calls tasks/run_role_with_clear_facts.yml instead, passing all the
same vars (roletoinclude, hpc_manage_storage, hpc_install_nvidia_driver,
hpc_install_cuda_driver, hpc_install_cuda_toolkit, hpc_install_hpc_nvidia_nccl,
hpc_install_nvidia_fabric_manager, hpc_install_nvidia_dcgm, hpc_install_rdma,
hpc_install_system_openmpi, hpc_build_mpi_w_nvidia_gpu_support,
hpc_install_mvapich, hpc_install_mpifileutils, and hpc_install_python312)
through the wrapper task instead of directly to import_role.

Source: Path instructions

🤖 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 `@README.md`:
- Around line 64-76: The documentation for the hpc_install_python312 variable
contains two issues that need to be fixed. First, correct the version mismatch
in the explanation: the text currently states that Azure Slurm cluster
infrastructure requires Python 3.11, but the variable is for installing Python
3.12, so update this statement to correctly reflect that Python 3.12 is
required. Second, add a concrete usage example after the variable description
that demonstrates how to enable or configure hpc_install_python312 in a playbook
or configuration file, such as showing how to set the variable to true/false and
what the resulting behavior would be.

In `@tasks/main.yml`:
- Around line 82-94: The new task "Install Python 3.12 alongside system Python
3.9" that conditionally installs python3.12, python3.12-pip, and
python3.12-devel packages lacks test coverage for its positive execution path.
The existing test only sets hpc_install_python312 to false, so the task is never
actually exercised. Add at least one test case that sets hpc_install_python312
to true and validates that the package installation task executes successfully
and installs the expected Python 3.12 packages.
- Line 84: The package task at line 84 is using a short module name instead of
the fully qualified collection name. Replace the `package:` module declaration
with `ansible.builtin.package:` to comply with the role's task policy that
requires all tasks to use FQCN (Fully Qualified Collection Name) instead of
short module names like yum, dnf, or apt.

---

Outside diff comments:
In `@tests/tests_include_vars_from_parent.yml`:
- Around line 47-64: The test task named "Import role" is using direct
import_role instead of the mandated centralized wrapper. Replace the entire
import_role task with an include_tasks task that calls
tasks/run_role_with_clear_facts.yml instead, passing all the same vars
(roletoinclude, hpc_manage_storage, hpc_install_nvidia_driver,
hpc_install_cuda_driver, hpc_install_cuda_toolkit, hpc_install_hpc_nvidia_nccl,
hpc_install_nvidia_fabric_manager, hpc_install_nvidia_dcgm, hpc_install_rdma,
hpc_install_system_openmpi, hpc_build_mpi_w_nvidia_gpu_support,
hpc_install_mvapich, hpc_install_mpifileutils, and hpc_install_python312)
through the wrapper task instead of directly to import_role.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ca4cc165-e201-4cd9-9c75-018be33305cd

📥 Commits

Reviewing files that changed from the base of the PR and between 29daf47 and d8ecdf3.

📒 Files selected for processing (6)
  • README.md
  • defaults/main.yml
  • tasks/main.yml
  • tests/tests_default.yml
  • tests/tests_include_vars_from_parent.yml
  • tests/tests_skip_toolkit.yml

Comment thread README.md
Comment thread tasks/main.yml
Comment thread tasks/main.yml
Comment thread README.md Outdated
@dgchinner dgchinner force-pushed the python-3.12-support branch from d8ecdf3 to 97bcecf Compare June 24, 2026 22:34
Comment thread tasks/main.yml
The Slurm cluster infrastructure that uses images built by this role
requires Python 3.12. RHEL 9.6 only provides Python 3.9 as the default,
so this change installs Python 3.12 from the AppStream repository
alongside the system default. The system default Python is left at 3.9
to avoid breaking OS tools (firewall-cmd, dnf, semanage, etc.) that
depend on Python 3.9 modules not available for 3.12 (e.g. PyGObject).
Python 3.12 is available as /usr/bin/python3.12.

Changes:
- Add hpc_install_python312 variable (default: true) to defaults/main.yml
- Add task to install python3.12, python3.12-pip, python3.12-devel
- Add README.md documentation for the new variable
- Disable python3.12 installation in CI test playbooks

Created-by-AI: Claude Opus 4.6 (1M context)

Prompt: new modification: the slurm cluster infrastructure that uses the build images requires support for python 3.12. RHEL 9.6 only provides python-3.9, so we need to install python-3.12 from the AppStream repository and set that to the default python version for the system.

Refinements:
- Removed alternatives configuration that set python3.12 as system default, as it breaks OS tools like firewall-cmd that depend on python3.9-only modules (PyGObject/gi)
- Python 3.12 is installed alongside system python, not as a replacement

Signed-off-by: Dave Chinner <dchinner@redhat.com>
@dgchinner dgchinner force-pushed the python-3.12-support branch from 97bcecf to e144383 Compare June 30, 2026 00:15
@dgchinner dgchinner merged commit 58c88e7 into linux-system-roles:main Jun 30, 2026
30 checks passed
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.

3 participants