Skip to content

Updated OpenGL rendering example to remove the distutils import#1205

Merged
shi-eric merged 1 commit intoNVIDIA:mainfrom
nawedume:bugfix/opengl-example-distutils-fix
Feb 3, 2026
Merged

Updated OpenGL rendering example to remove the distutils import#1205
shi-eric merged 1 commit intoNVIDIA:mainfrom
nawedume:bugfix/opengl-example-distutils-fix

Conversation

@nawedume
Copy link
Contributor

@nawedume nawedume commented Feb 1, 2026

Updated OpenGL rendering example to remove the distutils import and replace the functionality with the BooleanOptionalAction.

Closes #1204

Description

Before your PR is "Ready for review"

  • [x ] All commits are signed-off to indicate that your contribution adheres to the Developer Certificate of Origin requirements
  • [x ] Necessary tests have been added
  • [ x] Documentation is up-to-date
  • [ x] Auto-generated files modified by compiling Warp and building the documentation have been updated (e.g. __init__.pyi, docs/api_reference/, docs/language_reference/)
  • [ x] Code passes formatting and linting checks with pre-commit run -a

Summary by CodeRabbit

  • Bug Fixes
    • Command-line boolean flags for show_plot, split_up_tiles, and use_imgui now support both positive and negative forms (e.g., --flag and --no-flag), making CLI usage more consistent and user-friendly while preserving existing defaults and behavior.

@copy-pr-bot
Copy link

copy-pr-bot bot commented Feb 1, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai
Copy link

coderabbitai bot commented Feb 1, 2026

📝 Walkthrough

Walkthrough

Replaces distutils-based boolean parsing with argparse.BooleanOptionalAction for three CLI flags in the OpenGL example to restore compatibility with Python 3.12; behavior, defaults, and control flow remain unchanged.

Changes

Cohort / File(s) Summary
distutils removal fix
warp/examples/core/example_render_opengl.py
Replaced distutils.util.strtobool parsing with argparse.BooleanOptionalAction for --show_plot, --split_up_tiles, and --use_imgui. Removed distutils import; CLI now accepts both --flag and --no-flag forms. No other behavior changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: removing distutils import from the OpenGL example, which directly addresses the changeset.
Linked Issues check ✅ Passed The PR successfully replaces distutils-based boolean parsing with argparse.BooleanOptionalAction, directly satisfying the objective stated in issue #1204 to restore Python 3.12 compatibility.
Out of Scope Changes check ✅ Passed All changes are directly scoped to replacing distutils with argparse.BooleanOptionalAction in the OpenGL example, with no extraneous modifications introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@nawedume nawedume force-pushed the bugfix/opengl-example-distutils-fix branch from a05beb5 to 621a9d6 Compare February 1, 2026 04:18
@greptile-apps
Copy link

greptile-apps bot commented Feb 1, 2026

Greptile Overview

Greptile Summary

Replaced deprecated distutils.util.strtobool with modern argparse.BooleanOptionalAction for three boolean command-line flags in the OpenGL rendering example.

Key Changes:

  • Removed import distutils.util (deprecated in Python 3.10, removed in Python 3.12)
  • Changed --show_plot, --split_up_tiles, and --use_imgui arguments from type=lambda x: bool(distutils.util.strtobool(x.strip())) to action=argparse.BooleanOptionalAction
  • Improved CLI usability by supporting both positive (--flag) and negative (--no-flag) forms automatically

Impact:

  • Fixes compatibility with Python 3.12+ where distutils has been removed
  • Maintains backward compatibility with Python 3.9+ (BooleanOptionalAction introduced in 3.9)
  • No functional changes to the example's behavior
  • Enhanced user experience with more intuitive flag handling

Confidence Score: 5/5

  • This PR is safe to merge with no concerns
  • The change is a straightforward replacement of deprecated functionality with modern standard library features. BooleanOptionalAction is available in Python 3.9+ (project requires >=3.9), provides identical functionality to the previous implementation, and the change is limited to argument parsing with no impact on core logic
  • No files require special attention

Important Files Changed

Filename Overview
warp/examples/core/example_render_opengl.py Removed deprecated distutils import and replaced with BooleanOptionalAction for three boolean CLI arguments

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as Command Line Interface
    participant ArgumentParser as argparse.ArgumentParser
    participant BooleanOptionalAction
    participant Example as Example Class
    
    User->>CLI: python example_render_opengl.py [args]
    CLI->>ArgumentParser: Parse arguments
    Note over ArgumentParser: Old: type=lambda x: bool(distutils.util.strtobool(x))
    Note over ArgumentParser: New: action=argparse.BooleanOptionalAction
    ArgumentParser->>BooleanOptionalAction: Handle --show_plot / --no-show_plot
    BooleanOptionalAction-->>ArgumentParser: Return boolean value
    ArgumentParser->>BooleanOptionalAction: Handle --split_up_tiles / --no-split_up_tiles
    BooleanOptionalAction-->>ArgumentParser: Return boolean value
    ArgumentParser->>BooleanOptionalAction: Handle --use_imgui / --no-use_imgui
    BooleanOptionalAction-->>ArgumentParser: Return boolean value
    ArgumentParser-->>CLI: Parsed args object
    CLI->>Example: Initialize with args (num_tiles, custom_tile_arrangement, use_imgui)
    Example-->>CLI: Example instance
    CLI->>Example: Run render loop
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@shi-eric
Copy link
Contributor

shi-eric commented Feb 1, 2026

Thanks for the fix, can you squash the changes down to a single commit?

@shi-eric shi-eric added this to the 1.12.0 milestone Feb 1, 2026
@shi-eric shi-eric added the docs Improvements or additions to documentation label Feb 1, 2026
…eplace the functionality with the BooleanOptionalAction.

Signed-off-by: Umar Nawed <umar.nawed@gmail.com>
@nawedume nawedume force-pushed the bugfix/opengl-example-distutils-fix branch from 3ae7748 to 62919ef Compare February 3, 2026 00:10
@nawedume
Copy link
Contributor Author

nawedume commented Feb 3, 2026

@shi-eric Squashed the commits.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@shi-eric shi-eric merged commit 8aea7bc into NVIDIA:main Feb 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] OpenGL Example fails to run in Python 3.12 due to distutils removal

2 participants

Comments