Conversation
Previously the module silently overwrote any existing PYOPENGL_PLATFORM value (other than 'egl') when imported, which could cause hard-to-debug mixed-platform GL state if e.g. 'osmesa' had already been set. Now: - If PYOPENGL_PLATFORM is unset: set it to 'egl' (existing behaviour). - If PYOPENGL_PLATFORM == 'egl': no-op (already correct). - If PYOPENGL_PLATFORM is set to anything else: raise RuntimeError with a clear explanation, instead of silently overwriting it.
Both docstrings said window=None only when 'an OSMesa context is active', but EGL offscreen contexts also return window=None from init_offscreen_context. Updated both Parameters sections to say 'EGL or OSMesa offscreen context'.
Previously only mentioned OSMesa. Now describes all three paths: 1. GLFW invisible window (display available) 2. EGL GPU rendering (no display, /dev/dri/renderD* accessible) — new 3. OSMesa CPU fallback Adds install hint for libegl1 and notes EGL as the recommended path for SSH servers with a GPU. Docker section clarified to say OSMesa is used there specifically (no GPU device in standard containers).
- Opening paragraph: note GPU rendering is possible with --device - Notes section: split into 'default OSMesa' and 'optional EGL GPU' bullets, add --device example and libegl1 install note. OSMesa remains the default since no /dev/dri/ device is exposed in standard Docker containers.
There was a problem hiding this comment.
Pull request overview
This PR fixes EGL support by correcting the timing of the PYOPENGL_PLATFORM=egl environment variable assignment. Previously, the EGL platform was set lazily inside egl_context.py (which could be imported after OpenGL.GL was already bound to a different backend). Now it is set eagerly in _headless.py at package import time — before any OpenGL.GL import can occur — eliminating silent GL function-pointer mismatches.
Changes:
_headless.pynow immediately setsPYOPENGL_PLATFORM=eglwhen a headless EGL device is detected, instead of deferring toegl_context.pycontext.pyandegl_context.pyupdate their EGL guard logic to rely on the environment variable being already set, and documentation is updated throughout to describe the new platform-selection semanticsDockerfileand documentation (README.md,DOCKER.md) are updated to document EGL GPU rendering as a first-class headless option alongside OSMesa
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
whippersnappy/gl/_headless.py |
Sets PYOPENGL_PLATFORM=egl eagerly; updates module docstring |
whippersnappy/gl/egl_context.py |
Adds RuntimeError guard for wrong platform at direct-import time |
whippersnappy/gl/context.py |
Replaces egl_device_is_available() runtime check with PYOPENGL_PLATFORM=="egl" env check; updates docstrings |
whippersnappy/gl/__init__.py |
Updates package-level docstring to reflect new EGL/OSMesa selection logic |
README.md |
Documents three-path Linux headless fallback including EGL |
Dockerfile |
Adds libegl1 dependency for EGL GPU rendering support |
DOCKER.md |
Documents EGL GPU Docker usage with --device /dev/dri/renderD* |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #73 +/- ##
==========================================
- Coverage 34.91% 34.85% -0.07%
==========================================
Files 24 24
Lines 2237 2241 +4
Branches 340 341 +1
==========================================
Hits 781 781
- Misses 1362 1366 +4
Partials 94 94
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
minor fixes to EGL support