Skip to content

Commit 200e3af

Browse files
pvcravenPaul V Cravenclaude
authored
Update pyglet to 3.0.dev3 (#2842)
* Update pyglet dependency from 3.0.dev2 to 3.0.dev3 Adapt to breaking API changes in pyglet 3.0.dev3: - OpenGLConfig → OpenGLUserConfig with GraphicsAPI enum - pyglet.media.load → load_audio/load_video - pyglet.gl module moved to pyglet.graphics.api.gl Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Update Sphinx to 9.1.0, RTD theme to 3.1.0, Pillow to >=12.2.0 Also patch pyglet LibraryMock to add __bool__/__iter__ so doc builds don't crash when ffmpeg codec init runs under sys.is_pyglet_doc_run. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Use arcade.gl.enums.NEAREST instead of pyglet GL import Per review feedback: pyglet.graphics.api.gl imports are backend-specific and would break WebGL. arcade.gl.enums is backend-agnostic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Revert Sphinx/RTD theme upgrade (requires Python >=3.12) Sphinx 9.1.0 requires Python >=3.12 but arcade supports >=3.10. Revert to Sphinx 8.1.3 and sphinx-rtd-theme 3.0.2. The LibraryMock patch in conf.py is still needed for pyglet 3.0.dev3 doc builds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Revert Pillow bump to keep pyodide/WASM compatibility Pyodide only ships Pillow 11.3.0 and PyPI doesn't support WASM wheels yet, so requiring >=12.2.0 would break web deployments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Paul V Craven <paul.craven@optimizley.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cf30fbb commit 200e3af

8 files changed

Lines changed: 26 additions & 12 deletions

File tree

arcade/application.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import pyglet.config
2222
import pyglet.window.mouse
23+
from pyglet.config import GraphicsAPI
2324
from pyglet.display.base import Screen, ScreenMode
2425
from pyglet.event import EVENT_HANDLE_STATE, EVENT_UNHANDLED
2526
from pyglet.window import MouseCursor
@@ -211,15 +212,21 @@ def __init__(
211212
self._pixel_perfect: bool = pixel_perfect
212213
"""If True, ignore OS DPI scaling and use a 1:1 pixel ratio."""
213214

215+
_GL_API_MAP = {
216+
"opengl": GraphicsAPI.OPENGL,
217+
"opengles": GraphicsAPI.OPENGL_ES_3,
218+
}
219+
214220
config = None
215221
# Attempt to make window with antialiasing
216222
if gl_api == "opengl" or gl_api == "opengles":
223+
graphics_api = _GL_API_MAP[gl_api]
217224
if antialiasing:
218225
try:
219-
config = pyglet.config.OpenGLConfig(
226+
config = pyglet.config.OpenGLUserConfig(
220227
major_version=gl_version[0],
221228
minor_version=gl_version[1],
222-
opengl_api=gl_api.replace("open", ""), # type: ignore # pending: upstream fix
229+
api=graphics_api,
223230
double_buffer=True,
224231
sample_buffers=1,
225232
samples=samples,
@@ -236,10 +243,10 @@ def __init__(
236243
antialiasing = False
237244
# If we still don't have a config
238245
if not config:
239-
config = pyglet.config.OpenGLConfig(
246+
config = pyglet.config.OpenGLUserConfig(
240247
major_version=gl_version[0],
241248
minor_version=gl_version[1],
242-
opengl_api=gl_api.replace("open", ""), # type: ignore # pending: upstream fix
249+
api=graphics_api,
243250
double_buffer=True,
244251
depth_size=24,
245252
stencil_size=8,

arcade/examples/gui/exp_controller_inventory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
import pyglet.font
2020
from pyglet.event import EVENT_HANDLED
21-
from pyglet.gl import GL_NEAREST
2221
from pyglet.input import Controller
2322

2423
import arcade
24+
from arcade.gl.enums import NEAREST
2525
from arcade import Rect
2626
from arcade.examples.gui.exp_controller_support_grid import (
2727
ControllerIndicator,
@@ -412,8 +412,8 @@ def on_draw_before_ui(self):
412412

413413
if __name__ == "__main__":
414414
# pixelate the font
415-
pyglet.font.base.Font.texture_min_filter = GL_NEAREST # type: ignore
416-
pyglet.font.base.Font.texture_mag_filter = GL_NEAREST # type: ignore
415+
pyglet.font.base.Font.texture_min_filter = NEAREST # type: ignore
416+
pyglet.font.base.Font.texture_mag_filter = NEAREST # type: ignore
417417

418418
load_kenney_fonts()
419419

arcade/future/video/video_player.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class VideoPlayer:
2525
def __init__(self, path: str | Path, loop: bool = False):
2626
self.player = pyglet.media.VideoPlayer()
2727
self.player.loop = loop
28-
self.player.queue(pyglet.media.load(str(arcade.resources.resolve(path))))
28+
self.player.queue(pyglet.media.load_video(str(arcade.resources.resolve(path))))
2929
self.player.play()
3030

3131
self.ctx = arcade.get_window().ctx

arcade/gl/backends/opengl/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def get(self, enum, default=0) -> int:
534534
value = c_int()
535535
gl.glGetIntegerv(enum, value)
536536
return value.value
537-
except pyglet.gl.lib.GLException:
537+
except gl.lib.GLException:
538538
return default
539539

540540
def get_float(self, enum, default=0.0) -> float:

arcade/gl/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ def blend_func(self) -> Tuple[int, int] | Tuple[int, int, int, int]:
597597
598598
These enums can be accessed in the ``arcade.gl``
599599
module or simply as attributes of the context object.
600-
The raw enums from ``pyglet.gl`` can also be used.
600+
The raw enums from ``pyglet.graphics.api.gl`` can also be used.
601601
602602
Example::
603603

arcade/sound.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __init__(self, file_name: str | Path, streaming: bool = False):
7373
raise FileNotFoundError(f"The sound file '{file_name}' is not a file or can't be read.")
7474
self.file_name = str(file_name)
7575

76-
self.source: Source = media.load(self.file_name, streaming=streaming)
76+
self.source: Source = media.load_audio(self.file_name, streaming=streaming)
7777
"""
7878
The :py:class:`pyglet.media.Source` object that holds the audio data.
7979
"""

doc/conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@
5252
# 2. The commit: https://github.com/pyglet/pyglet/commit/97076c3a33a7d368cc9c9e44ca67769b6a16a905
5353
sys.is_pyglet_doc_run = True
5454

55+
# pyglet 3.0.dev3 LibraryMock lacks __iter__/__bool__, causing crashes
56+
# when ffmpeg codec init calls get_input_extensions() during doc builds.
57+
# Patch before any pyglet imports trigger media codec loading.
58+
import pyglet.lib # noqa: E402
59+
pyglet.lib.LibraryMock.__bool__ = lambda self: False
60+
pyglet.lib.LibraryMock.__iter__ = lambda self: iter([])
61+
5562
# --- Pre-processing Tasks
5663

5764
# Report our diagnostic info

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ classifiers = [
2222
dependencies = [
2323
"pillow>=11.3.0",
2424
"pytiled-parser~=2.2.9",
25-
"pyglet==3.0.dev2",
25+
"pyglet==3.0.dev3",
2626
]
2727
dynamic = ["version"]
2828

0 commit comments

Comments
 (0)