pythonarcade / arcade

Easy to use Python library for creating 2D arcade games.
http://arcade.academy
Other
1.66k stars 316 forks source link

Make arcade 2.x python 3.12 compatible #1953

Closed einarf closed 1 week ago

einarf commented 6 months ago

Bumping some depedencies with minor code changes is the only thing needed to make this happen.

See #1950

professorwade commented 6 months ago

What is the timeframe for this change?

einarf commented 6 months ago

What is the timeframe for this change?

I'm looking into if this is even possible at the moment

einarf commented 6 months ago

There seems to by pyglet issues related to text with pygket 2.0dev23 meaning making a 2.x verison with python 12 support is a bit more challenging than just bumping Pillow and Pymunk.

Traceback (most recent call last):
  File "C:\Users\efors\projects\moderngl\arcade\arcade\examples\sprite_bullets.py", line 177, in <module>
    main()
  File "C:\Users\efors\projects\moderngl\arcade\arcade\examples\sprite_bullets.py", line 173, in main
    arcade.run()
  File "\arcade\arcade\window_commands.py", line 323, in run
    pyglet.app.run()
  File "site-packages\pyglet\app\__init__.py", line 107, in run
    event_loop.run(interval)
  File "site-packages\pyglet\app\base.py", line 184, in run
    timeout = self.idle()
              ^^^^^^^^^^^
  File "site-packages\pyglet\app\base.py", line 245, in idle
    self.clock.call_scheduled_functions(dt)
  File "site-packages\pyglet\clock.py", line 277, in call_scheduled_functions
    item.func(now - item.last_ts, *item.args, **item.kwargs)
  File "site-packages\pyglet\app\base.py", line 154, in _redraw_windows
    window.dispatch_event('on_draw')
  File "site-packages\pyglet\window\__init__.py", line 1361, in dispatch_event
    super().dispatch_event(*args)
  File "site-packages\pyglet\event.py", line 422, in dispatch_event
    if getattr(self, event_type)(*args):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "arcade\examples\sprite_bullets.py", line 110, in on_draw
    arcade.draw_text(f"Score: {self.score}", 10, 20, arcade.color.WHITE, 14)
  File "arcade\text_pyglet.py", line 724, in draw_text
    label = pyglet.text.Label(
            ^^^^^^^^^^^^^^^^^^
  File "site-packages\pyglet\text\__init__.py", line 474, in __init__
    super().__init__(doc, x, y, width, height, anchor_x, anchor_y, multiline, dpi, batch, group, rotation)
  File "site-packages\pyglet\text\__init__.py", line 274, in __init__
    super().__init__(document, width, height, multiline, dpi, batch, group)
  File "site-packages\pyglet\text\layout.py", line 940, in __init__
    self.document = document
    ^^^^^^^^^^^^^
  File "site-packages\pyglet\text\layout.py", line 984, in document
    self._init_document()
  File "site-packages\pyglet\text\layout.py", line 1428, in _init_document
    self._update()
  File "site-packages\pyglet\text\layout.py", line 1342, in _update
    lines = self._get_lines()
            ^^^^^^^^^^^^^^^^^
  File "site-packages\pyglet\text\layout.py", line 1319, in _get_lines
    glyphs = self._get_glyphs()
             ^^^^^^^^^^^^^^^^^^
  File "site-packages\pyglet\text\layout.py", line 1476, in _get_glyphs
    glyphs.extend(font.get_glyphs(text[start:end]))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages\pyglet\font\base.py", line 385, in get_glyphs
    glyph_renderer = self.glyph_renderer_class(self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages\pyglet\font\win32.py", line 100, in __init__
    self._create_bitmap(width, height)
  File "site-packages\pyglet\font\win32.py", line 324, in _create_bitmap
    gdiplus.GdipCreateBitmapFromScan0(width, height, width * 4,
ctypes.ArgumentError: argument 5: TypeError: expected LP_c_ubyte instance instead of c_byte_Array_3520
einarf commented 6 months ago

I created a branch here : https://github.com/pythonarcade/arcade/tree/2.6-py312

This is simply just bumped dependencies (pyglet, pymunk, pillow). The basic examples are working fine. More testing likely needed. Be free to give it a spin @professorwade

professorwade commented 6 months ago

Thank you, I'll check it out.

pushfoo commented 4 months ago

This branch seems to work under:

einarf commented 4 months ago

I do think the old pyglet version can case some platform specific issues. It would be ideal bumping to the latest stable version.

Might not be too much work wrapping that up.

pushfoo commented 3 months ago

If pymunk is consistently the thing holding us back from supporting the latest Python, the easiest thing to do would be to make it an optional dependency.

einarf commented 1 week ago

Let's not. We focus on arcade 3.x of now.

pushfoo commented 1 week ago

Added context for @professorwade: