From 005d279b7762a735439a2b025b63b5a77c1a27cd Mon Sep 17 00:00:00 2001 From: ryanking13 Date: Wed, 15 Oct 2025 22:09:14 +0900 Subject: [PATCH 1/5] Bump pygame-ce --- packages/pygame-ce/meta.yaml | 130 ++++++++++++----------------------- 1 file changed, 44 insertions(+), 86 deletions(-) diff --git a/packages/pygame-ce/meta.yaml b/packages/pygame-ce/meta.yaml index b76ebfb9..2bf8e207 100644 --- a/packages/pygame-ce/meta.yaml +++ b/packages/pygame-ce/meta.yaml @@ -1,99 +1,57 @@ package: name: pygame-ce - version: 2.4.1 - # Need newer version for 3.13 compat see https://github.com/pyodide/pyodide/pull/5522 - _disabled: true + version: 2.5.6.dev2 top-level: - pygame source: - url: https://files.pythonhosted.org/packages/dc/b1/64fffc2c8664497ae82b2afb4f5efe0130d38b39f2d25af0288c4261df3e/pygame-ce-2.4.1.tar.gz - sha256: 70a84aa1417c633a0fd6754ffa5dc92ee1b9aeb70baaa52c8c8c94a7c6db9cf0 - patches: - - patches/0001-Replace-OpenAudioDevice-with-OpenAudio.patch - - patches/0001-freetype-init.patch - - patches/0001-wasm_unify_pygame_web_pyodide_static_Freetype_init.patch -requirements: - constraint: - - setuptools < 75 + url: https://files.pythonhosted.org/packages/ab/98/911c3287c42a774a48271758990cd7d57cce148866f4126a41314223ab98/pygame_ce-2.5.6.dev2.tar.gz + sha256: a1303cd212a3e92253712293480f2b7741fd7ac6e29981c5ff1ded1d554d030c build: script: | - embuilder build sdl2 sdl2_ttf sdl2_image sdl2_mixer sdl2_gfx libjpeg libpng giflib harfbuzz vorbis mpg123 libmodplug freetype libhtml5 --pic - export SDL_CONFIG=$(em-config CACHE)/sysroot/bin/sdl2-config - cflags: | - -sRELOCATABLE=1 - -DSDL_NO_COMPAT - -DBUILD_STATIC - -ferror-limit=1 - -sUSE_SDL=2 - -sUSE_SDL_MIXER=2 - -sSDL2_MIXER_FORMATS=mid,mod,mpg,ogg - -sUSE_SDL_TTF=2 - -sUSE_SDL_IMAGE=2 - -sSDL2_IMAGE_FORMATS=bmp,gif,jpg,png - -sUSE_SDL_GFX=2 - -sUSE_FREETYPE=1 - -sUSE_LIBJPEG=1 - -sUSE_LIBPNG=1 - -sUSE_GIFLIB=1 - -sUSE_HARFBUZZ=1 - -Wno-unreachable-code-fallthrough - ldflags: | - -sRELOCATABLE=1 - -sUSE_SDL=2 - -sUSE_SDL_MIXER=2 - -sSDL2_MIXER_FORMATS=mid,mod,mpg,ogg - -sUSE_SDL_TTF=2 - -sUSE_SDL_IMAGE=2 - -sSDL2_IMAGE_FORMATS=bmp,gif,jpg,png - -sUSE_SDL_GFX=2 - -sUSE_FREETYPE=1 - -sUSE_LIBJPEG=1 - -sUSE_LIBPNG=1 - -sUSE_GIFLIB=1 - -sUSE_HARFBUZZ=1 - post: | - # Remove docs to reduce the size of a wheel - # (Perhaps also remove typeshed and examples too?) - rm -rf ./pygame/docs - - # WASM version of pygame uses a single module 'pygame_static', - # and pygame_static calls PyInit_* functions from other modules. - # This is okay when all these modules are bundled in a single module: libpython. - # But as we don't do that, we need to load these modules globally, so that - # pygame_static can see the symbols. - STATIC_OBJS=$(find ${PKG_BUILD_DIR} -name "*.o") - echo "build dir: " $PKG_BUILD_DIR - echo "static objs: " $STATIC_OBJS + # formats should be the same as the cibuildwheel config in pygame-ce + # https://github.com/pygame-community/pygame-ce/blob/e197e353fd33448abeed384dd4098e163c4998a5/pyproject.toml#L107 - SHARED_LIBS=$(find ${WHEELDIR} -name "*.so" ! -name "static*.so") - echo "shared libs: " $SHARED_LIBS + # workaround to build wasm-exception-enabled port of sdl2_image (See: https://github.com/pygame-community/pygame-ce/pull/3588#issuecomment-3352072309) + touch dummy_src_for_port.c + emcc dummy_src_for_port.c -sSUPPORT_LONGJMP="wasm" -sRELOCATABLE=1 -fpic "--use-port=sdl2_image:formats=bmp,gif,jpg,lbm,pcx,png,pnm,qoi,svg,tga,xcf,xpm,xv" - emcc \ - -shared \ - ${SIDE_MODULE_LDFLAGS} \ - -fPIC \ - -lSDL2 \ - -lSDL2_image-bmp-gif-jpg-png-wasm-sjlj \ - -lSDL2_ttf \ - -lSDL2_mixer_mid-mod-mpg-ogg \ - -lSDL2_gfx \ - -lfreetype-legacysjlj \ - -lharfbuzz \ - -lpng-legacysjlj \ - -ljpeg \ - -lgif \ - -lvorbis \ - -lmodplug \ - -lmpg123 \ - -logg \ - -lhtml5 \ - ${STATIC_OBJS} \ - ${SHARED_LIBS} \ - -sSUPPORT_LONGJMP=wasm \ - -o pygame_static.so + embuilder --pic build sdl2 libhtml5 sdl2_ttf 'sdl2_mixer:formats=ogg,mp3,mod,mid' - # Remove duplicated static.so module - rm -f ./pygame/static*.so + # cflags: | + # -sRELOCATABLE=1 + # -DSDL_NO_COMPAT + # -DBUILD_STATIC + # -ferror-limit=1 + # -sUSE_SDL=2 + # -sUSE_SDL_MIXER=2 + # -sSDL2_MIXER_FORMATS=mid,mod,mpg,ogg + # -sUSE_SDL_TTF=2 + # -sUSE_SDL_IMAGE=2 + # -sSDL2_IMAGE_FORMATS=bmp,gif,jpg,png + # -sUSE_SDL_GFX=2 + # -sUSE_FREETYPE=1 + # -sUSE_LIBJPEG=1 + # -sUSE_LIBPNG=1 + # -sUSE_GIFLIB=1 + # -sUSE_HARFBUZZ=1 + # -Wno-unreachable-code-fallthrough + # ldflags: | + # -sRELOCATABLE=1 + # -sUSE_SDL=2 + # -sUSE_SDL_MIXER=2 + # -sSDL2_MIXER_FORMATS=mid,mod,mpg,ogg + # -sUSE_SDL_TTF=2 + # -sUSE_SDL_IMAGE=2 + # -sSDL2_IMAGE_FORMATS=bmp,gif,jpg,lbm,pcx,png,pnm,qoi,svg,tga,xcf,xpm,xv + # -sUSE_SDL_GFX=2 + # -sUSE_FREETYPE=1 + # -sUSE_LIBJPEG=1 + # -sUSE_LIBPNG=1 + # -sUSE_GIFLIB=1 + # -sUSE_HARFBUZZ=1 + post: | + # Remove docs to reduce the size of a wheel + rm -rf ./pygame/docs about: home: https://www.pygame.org PyPI: https://pypi.org/project/pygame From 845ead7932dc4eec6071b9c20561f0bd63173c58 Mon Sep 17 00:00:00 2001 From: ryanking13 Date: Wed, 15 Oct 2025 22:16:41 +0900 Subject: [PATCH 2/5] remove redundant things --- packages/pygame-ce/meta.yaml | 33 ------ packages/pygame-ce/test_pygame.py | 184 +++++++++++++++--------------- 2 files changed, 93 insertions(+), 124 deletions(-) diff --git a/packages/pygame-ce/meta.yaml b/packages/pygame-ce/meta.yaml index 2bf8e207..68f0e755 100644 --- a/packages/pygame-ce/meta.yaml +++ b/packages/pygame-ce/meta.yaml @@ -16,39 +16,6 @@ build: emcc dummy_src_for_port.c -sSUPPORT_LONGJMP="wasm" -sRELOCATABLE=1 -fpic "--use-port=sdl2_image:formats=bmp,gif,jpg,lbm,pcx,png,pnm,qoi,svg,tga,xcf,xpm,xv" embuilder --pic build sdl2 libhtml5 sdl2_ttf 'sdl2_mixer:formats=ogg,mp3,mod,mid' - - # cflags: | - # -sRELOCATABLE=1 - # -DSDL_NO_COMPAT - # -DBUILD_STATIC - # -ferror-limit=1 - # -sUSE_SDL=2 - # -sUSE_SDL_MIXER=2 - # -sSDL2_MIXER_FORMATS=mid,mod,mpg,ogg - # -sUSE_SDL_TTF=2 - # -sUSE_SDL_IMAGE=2 - # -sSDL2_IMAGE_FORMATS=bmp,gif,jpg,png - # -sUSE_SDL_GFX=2 - # -sUSE_FREETYPE=1 - # -sUSE_LIBJPEG=1 - # -sUSE_LIBPNG=1 - # -sUSE_GIFLIB=1 - # -sUSE_HARFBUZZ=1 - # -Wno-unreachable-code-fallthrough - # ldflags: | - # -sRELOCATABLE=1 - # -sUSE_SDL=2 - # -sUSE_SDL_MIXER=2 - # -sSDL2_MIXER_FORMATS=mid,mod,mpg,ogg - # -sUSE_SDL_TTF=2 - # -sUSE_SDL_IMAGE=2 - # -sSDL2_IMAGE_FORMATS=bmp,gif,jpg,lbm,pcx,png,pnm,qoi,svg,tga,xcf,xpm,xv - # -sUSE_SDL_GFX=2 - # -sUSE_FREETYPE=1 - # -sUSE_LIBJPEG=1 - # -sUSE_LIBPNG=1 - # -sUSE_GIFLIB=1 - # -sUSE_HARFBUZZ=1 post: | # Remove docs to reduce the size of a wheel rm -rf ./pygame/docs diff --git a/packages/pygame-ce/test_pygame.py b/packages/pygame-ce/test_pygame.py index 708fc112..3a6d6f0b 100644 --- a/packages/pygame-ce/test_pygame.py +++ b/packages/pygame-ce/test_pygame.py @@ -53,94 +53,96 @@ def test_keyboard_input(): assert "emscripten_compute_dom_pk_code" not in all_fields -@pytest.mark.driver_timeout(300) -@run_in_pyodide(packages=["pygame-ce", "pygame-ce-tests", "pytest"]) -def test_run_tests(selenium_sdl): - import os - from pathlib import Path - - import pygame - import pytest - - if "CI" in os.environ: - pytest.skip("Skipped in CI (takes too long to run)") - - test_path = Path(pygame.__file__).parent / "tests" - - def runtest(test_filter, ignore_filters): - ignore_filter = [] - for ignore in ignore_filters: - ignore_filter.append("--ignore-glob") - ignore_filter.append(ignore) - - ret = pytest.main( - [ - "--pyargs", - str(test_path), - "--continue-on-collection-errors", - "-v", - *ignore_filter, - "-k", - test_filter, - ] - ) - assert ret == 0 - - runtest( - ( - "not test_init " # Mix_QuerySpec - "and not test_quit__and_init " # Mix_QuerySpec - "and not test_print_debug " # Mix_Linked_Version - "and not FullscreenToggleTests " # hangs - "and not TimeModuleTest " # NotImplementedError: set_timer is not implemented on WASM yet - "and not thread " # threading - "and not iconify " # not supported - "and not caption " # doesn't work - "and not set_gamma " # doesn't work - "and not DisplayUpdateInteractiveTest " # cannot block - "and not test_get_flags__display_surf " # doesn't work (gfx?) - "and not test_toggle_fullscreen " # not supported - "and not test_set_icon_interactive " # cannot block - "and not opengl " # opengl - "and not MessageBoxInteractiveTest " # No message system available - "and not test_gaussian_blur " # tiff format - "and not test_box_blur " # tiff format - "and not test_blur_in_place " # tiff format - "and not deprecation " - "and not test_save_tga " # tga - "and not test_save_pathlib " # tga - "and not test_load_sized_svg " # svg - "and not test_load_extended " # svg - "and not test_rotozoom_keeps_colorkey " # surface (gfx?) - "and not test_format_newbuf " # surface (gfx?) - "and not test_save_to_fileobject " # tga - "and not test_magic " # no fixture - "and not test_load_non_string_file " # can't access resource on platform - "and not test_save__to_fileobject_w_namehint_argument " # can't access resource on platform (tga) - "and not testLoadBytesIO " # can't access resource on platform - "and not VisualTests " # cannot block - "and not test_load_from_invalid_sized_file_obj " # can't access resource on platform - "and not GeneralSurfaceTests" # "No convert format" does not match "Parameter 'surface' is invalid" - ), - # Following tests are ignored - [ - test_path / "sndarray_test.py", # numpy - test_path / "surfarray_test.py", # numpy - test_path / "midi_test.py", # pygame.pypm not supported - test_path / "mixer_test.py", # lots of TODOs in mixer module - test_path / "mixer_music_test.py", # lots of TODOs in mixer module - test_path / "window_test.py", # signature mismatch - test_path / "threads_test.py", # threads - test_path / "joystick_test.py", # nonsense - test_path / "scrap_test.py", # clipboard - test_path / "docs_test.py", # document removed to reduce size - test_path / "touch_test.py", # touch - test_path / "gfxdraw_test.py", # doesn't work (FIXME) - test_path - / "event_test.py", # NotImplementedError: set_timer is not implemented on WASM yet - test_path / "mouse_test.py", # freetype does not work (FIXME) - test_path / "freetype_test.py", # freetype does not work (FIXME) - test_path / "ftfont_test.py", # freetype does not work (FIXME) - test_path / "video_test.py", # signature mismatch - ], - ) +# FIXME: WASM build of pygame-ce does not include tests anymore. +# If we want to run the unittest, we need to download the test files manually. +# @pytest.mark.driver_timeout(300) +# @run_in_pyodide(packages=["pygame-ce", "pytest"]) +# def test_run_tests(selenium_sdl): +# import os +# from pathlib import Path + +# import pygame +# import pytest + +# if "CI" in os.environ: +# pytest.skip("Skipped in CI (takes too long to run)") + +# test_path = Path(pygame.__file__).parent / "tests" + +# def runtest(test_filter, ignore_filters): +# ignore_filter = [] +# for ignore in ignore_filters: +# ignore_filter.append("--ignore-glob") +# ignore_filter.append(ignore) + +# ret = pytest.main( +# [ +# "--pyargs", +# str(test_path), +# "--continue-on-collection-errors", +# "-v", +# *ignore_filter, +# "-k", +# test_filter, +# ] +# ) +# assert ret == 0 + +# runtest( +# ( +# "not test_init " # Mix_QuerySpec +# "and not test_quit__and_init " # Mix_QuerySpec +# "and not test_print_debug " # Mix_Linked_Version +# "and not FullscreenToggleTests " # hangs +# "and not TimeModuleTest " # NotImplementedError: set_timer is not implemented on WASM yet +# "and not thread " # threading +# "and not iconify " # not supported +# "and not caption " # doesn't work +# "and not set_gamma " # doesn't work +# "and not DisplayUpdateInteractiveTest " # cannot block +# "and not test_get_flags__display_surf " # doesn't work (gfx?) +# "and not test_toggle_fullscreen " # not supported +# "and not test_set_icon_interactive " # cannot block +# "and not opengl " # opengl +# "and not MessageBoxInteractiveTest " # No message system available +# "and not test_gaussian_blur " # tiff format +# "and not test_box_blur " # tiff format +# "and not test_blur_in_place " # tiff format +# "and not deprecation " +# "and not test_save_tga " # tga +# "and not test_save_pathlib " # tga +# "and not test_load_sized_svg " # svg +# "and not test_load_extended " # svg +# "and not test_rotozoom_keeps_colorkey " # surface (gfx?) +# "and not test_format_newbuf " # surface (gfx?) +# "and not test_save_to_fileobject " # tga +# "and not test_magic " # no fixture +# "and not test_load_non_string_file " # can't access resource on platform +# "and not test_save__to_fileobject_w_namehint_argument " # can't access resource on platform (tga) +# "and not testLoadBytesIO " # can't access resource on platform +# "and not VisualTests " # cannot block +# "and not test_load_from_invalid_sized_file_obj " # can't access resource on platform +# "and not GeneralSurfaceTests" # "No convert format" does not match "Parameter 'surface' is invalid" +# ), +# # Following tests are ignored +# [ +# test_path / "sndarray_test.py", # numpy +# test_path / "surfarray_test.py", # numpy +# test_path / "midi_test.py", # pygame.pypm not supported +# test_path / "mixer_test.py", # lots of TODOs in mixer module +# test_path / "mixer_music_test.py", # lots of TODOs in mixer module +# test_path / "window_test.py", # signature mismatch +# test_path / "threads_test.py", # threads +# test_path / "joystick_test.py", # nonsense +# test_path / "scrap_test.py", # clipboard +# test_path / "docs_test.py", # document removed to reduce size +# test_path / "touch_test.py", # touch +# test_path / "gfxdraw_test.py", # doesn't work (FIXME) +# test_path +# / "event_test.py", # NotImplementedError: set_timer is not implemented on WASM yet +# test_path / "mouse_test.py", # freetype does not work (FIXME) +# test_path / "freetype_test.py", # freetype does not work (FIXME) +# test_path / "ftfont_test.py", # freetype does not work (FIXME) +# test_path / "video_test.py", # signature mismatch +# ], +# ) From 9784bddc2c60ea4faecb64107b64b2e8e8f5dc27 Mon Sep 17 00:00:00 2001 From: Gyeongjae Choi Date: Thu, 16 Oct 2025 19:51:25 +0900 Subject: [PATCH 3/5] Update packages/pygame-ce/meta.yaml Co-authored-by: Ankith --- packages/pygame-ce/meta.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/pygame-ce/meta.yaml b/packages/pygame-ce/meta.yaml index 68f0e755..672cc41b 100644 --- a/packages/pygame-ce/meta.yaml +++ b/packages/pygame-ce/meta.yaml @@ -20,7 +20,7 @@ build: # Remove docs to reduce the size of a wheel rm -rf ./pygame/docs about: - home: https://www.pygame.org - PyPI: https://pypi.org/project/pygame + home: https://pyga.me + PyPI: https://pypi.org/project/pygame-ce summary: Python Game Development license: LGPL-2.1 From 1531257481e11471d4f571e186a8fc51d935469f Mon Sep 17 00:00:00 2001 From: Gyeongjae Choi Date: Thu, 16 Oct 2025 19:51:47 +0900 Subject: [PATCH 4/5] Eliminate post-build documentation removal step Removed post-build step to delete documentation. --- packages/pygame-ce/meta.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/pygame-ce/meta.yaml b/packages/pygame-ce/meta.yaml index 672cc41b..fecb8803 100644 --- a/packages/pygame-ce/meta.yaml +++ b/packages/pygame-ce/meta.yaml @@ -16,9 +16,6 @@ build: emcc dummy_src_for_port.c -sSUPPORT_LONGJMP="wasm" -sRELOCATABLE=1 -fpic "--use-port=sdl2_image:formats=bmp,gif,jpg,lbm,pcx,png,pnm,qoi,svg,tga,xcf,xpm,xv" embuilder --pic build sdl2 libhtml5 sdl2_ttf 'sdl2_mixer:formats=ogg,mp3,mod,mid' - post: | - # Remove docs to reduce the size of a wheel - rm -rf ./pygame/docs about: home: https://pyga.me PyPI: https://pypi.org/project/pygame-ce From 5644c026c8b93ebb9ac56527f102076a272e21d6 Mon Sep 17 00:00:00 2001 From: Gyeongjae Choi Date: Thu, 16 Oct 2025 19:52:12 +0900 Subject: [PATCH 5/5] Delete packages/pygame-ce/patches directory --- ...place-OpenAudioDevice-with-OpenAudio.patch | 29 -- .../patches/0001-freetype-init.patch | 247 ------------------ ...ame_web_pyodide_static_Freetype_init.patch | 29 -- 3 files changed, 305 deletions(-) delete mode 100644 packages/pygame-ce/patches/0001-Replace-OpenAudioDevice-with-OpenAudio.patch delete mode 100644 packages/pygame-ce/patches/0001-freetype-init.patch delete mode 100644 packages/pygame-ce/patches/0001-wasm_unify_pygame_web_pyodide_static_Freetype_init.patch diff --git a/packages/pygame-ce/patches/0001-Replace-OpenAudioDevice-with-OpenAudio.patch b/packages/pygame-ce/patches/0001-Replace-OpenAudioDevice-with-OpenAudio.patch deleted file mode 100644 index 84ee6174..00000000 --- a/packages/pygame-ce/patches/0001-Replace-OpenAudioDevice-with-OpenAudio.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 948614b9410f57c599db98c3248314238a0d317c Mon Sep 17 00:00:00 2001 -From: ryanking13 -Date: Sat, 17 Feb 2024 10:55:27 +0900 -Subject: [PATCH 1/1] Replace OpenAudioDevice with OpenAudio - -FIXME: for some reason, Mix_OpenAudioDevice is not statically linked when building the SDL module. - ---- - src_c/mixer.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src_c/mixer.c b/src_c/mixer.c -index 51097bba..6c79747c 100644 ---- a/src_c/mixer.c -+++ b/src_c/mixer.c -@@ -441,8 +441,8 @@ _init(int freq, int size, int channels, int chunk, char *devicename, - if (SDL_InitSubSystem(SDL_INIT_AUDIO)) - return RAISE(pgExc_SDLError, SDL_GetError()); - -- if (Mix_OpenAudioDevice(freq, fmt, channels, chunk, devicename, -- allowedchanges) == -1) { -+ // No Mix_OpenAudioCompat in emscripten -+ if (Mix_OpenAudio(freq, fmt, channels, chunk) == -1) { - SDL_QuitSubSystem(SDL_INIT_AUDIO); - return RAISE(pgExc_SDLError, SDL_GetError()); - } --- -2.29.2.windows.2 - diff --git a/packages/pygame-ce/patches/0001-freetype-init.patch b/packages/pygame-ce/patches/0001-freetype-init.patch deleted file mode 100644 index c4f19565..00000000 --- a/packages/pygame-ce/patches/0001-freetype-init.patch +++ /dev/null @@ -1,247 +0,0 @@ -https://github.com/pmp-p/pygame-ce-wasm/pull/3 - ---- -diff --git a/src_c/_freetype.c b/src_c/_freetype.c -index 3ee6241e05..7953dbd6e4 100644 ---- a/src_c/_freetype.c -+++ b/src_c/_freetype.c -@@ -30,9 +30,17 @@ - #define MODULE_NAME "_freetype" - #define FONT_TYPE_NAME "Font" - -+#define DEFAULT_FONT_NAME "freesans" -+#define DEFAULT_FONT_FILE "freesansbold.ttf" -+#define PKGDATA_MODULE_NAME "pygame.pkgdata" -+#define RESOURCE_FUNC_NAME "getResource" -+ - /* - * FreeType module declarations - */ -+ -+PyObject *_freetypemodule = NULL; -+ - static const Scale_t FACE_SIZE_NONE = {0, 0}; - - static int -@@ -210,10 +218,6 @@ free_string(PGFT_String *); - _var = PyObject_IsTrue(_pyobj); \ - } - --#define DEFAULT_FONT_NAME "freesansbold.ttf" --#define PKGDATA_MODULE_NAME "pygame.pkgdata" --#define RESOURCE_FUNC_NAME "getResource" -- - static unsigned int current_freetype_generation = 0; - - #define FreetypeFont_GenerationCheck(x) \ -@@ -705,7 +709,11 @@ _ftfont_init(pgFontObject *self, PyObject *args, PyObject *kwds) - SDL_RWops *source; - - FreeTypeInstance *ft; -+#if defined(__EMSCRIPTEN__) -+ ft = FREETYPE_MOD_STATE(_freetypemodule)->freetype; -+#else - ASSERT_GRAB_FREETYPE(ft, -1); -+#endif - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O&lIi", kwlist, &file, - obj_to_scale, (void *)&face_size, -@@ -739,7 +747,7 @@ _ftfont_init(pgFontObject *self, PyObject *args, PyObject *kwds) - self->resolution = FREETYPE_STATE->resolution; - } - if (file == Py_None) { -- file = load_font_res(DEFAULT_FONT_NAME); -+ file = load_font_res(DEFAULT_FONT_FILE); - - if (!file) { - PyErr_SetString(PyExc_RuntimeError, "Failed to find default font"); -@@ -2219,6 +2227,14 @@ _ft_get_error(PyObject *self, PyObject *_null) - Py_RETURN_NONE; - } - -+#if defined(__EMSCRIPTEN__) -+static PyObject * -+_ft_get_version(PyObject *self, PyObject *args, PyObject *kwargs) -+{ -+ return Py_BuildValue("iii", FREETYPE_MAJOR, FREETYPE_MINOR, -+ FREETYPE_PATCH); -+} -+#else - static PyObject * - _ft_get_version(PyObject *self, PyObject *args, PyObject *kwargs) - { -@@ -2265,6 +2281,7 @@ _ft_get_version(PyObject *self, PyObject *args, PyObject *kwargs) - FREETYPE_PATCH); - } - } -+#endif // defined(__EMSCRIPTEN__) - - static PyObject * - _ft_get_cache_size(PyObject *self, PyObject *_null) -@@ -2304,7 +2321,7 @@ _ft_get_init(PyObject *self, PyObject *_null) - static PyObject * - _ft_get_default_font(PyObject *self, PyObject *_null) - { -- return PyUnicode_FromString(DEFAULT_FONT_NAME); -+ return PyUnicode_FromString(DEFAULT_FONT_FILE); - } - - static int -@@ -2327,13 +2344,13 @@ _ft_clear(PyObject *mod) - * FREETYPE MODULE DECLARATION - ****************************************************/ - #ifndef PYPY_VERSION --struct PyModuleDef _freetypemodule = { -+struct PyModuleDef _freetypemoduledef = { - PyModuleDef_HEAD_INIT, MODULE_NAME, DOC_FREETYPE, - sizeof(_FreeTypeState), _ft_methods, 0, - _ft_traverse, _ft_clear, 0}; - #else /* PYPY_VERSION */ - _FreeTypeState _modstate; --struct PyModuleDef _freetypemodule = { -+struct PyModuleDef _freetypemoduledef = { - PyModuleDef_HEAD_INIT, - MODULE_NAME, - DOC_FREETYPE, -@@ -2347,7 +2364,7 @@ struct PyModuleDef _freetypemodule = { - - MODINIT_DEFINE(_freetype) - { -- PyObject *module, *apiobj; -+ PyObject *apiobj; - static void *c_api[PYGAMEAPI_FREETYPE_NUMSLOTS]; - - import_pygame_base(); -@@ -2380,27 +2397,28 @@ MODINIT_DEFINE(_freetype) - return NULL; - } - -- module = PyModule_Create(&_freetypemodule); -+ _freetypemodule = PyModule_Create(&_freetypemoduledef); - -- if (!module) { -+ if (!_freetypemodule) { - return NULL; - } - -- FREETYPE_MOD_STATE(module)->freetype = 0; -- FREETYPE_MOD_STATE(module)->cache_size = 0; -- FREETYPE_MOD_STATE(module)->resolution = PGFT_DEFAULT_RESOLUTION; -+ FREETYPE_MOD_STATE(_freetypemodule)->freetype = 0; -+ FREETYPE_MOD_STATE(_freetypemodule)->cache_size = 0; -+ FREETYPE_MOD_STATE(_freetypemodule)->resolution = PGFT_DEFAULT_RESOLUTION; - - Py_INCREF(&pgFont_Type); -- if (PyModule_AddObject(module, FONT_TYPE_NAME, (PyObject *)&pgFont_Type)) { -+ if (PyModule_AddObject(_freetypemodule, FONT_TYPE_NAME, -+ (PyObject *)&pgFont_Type)) { - Py_DECREF(&pgFont_Type); -- Py_DECREF(module); -+ Py_DECREF(_freetypemodule); - return NULL; - } - --#define DEC_CONST(x) \ -- if (PyModule_AddIntConstant(module, #x, (int)FT_##x)) { \ -- Py_DECREF(module); \ -- return NULL; \ -+#define DEC_CONST(x) \ -+ if (PyModule_AddIntConstant(_freetypemodule, #x, (int)FT_##x)) { \ -+ Py_DECREF(_freetypemodule); \ -+ return NULL; \ - } - - DEC_CONST(STYLE_NORMAL); -@@ -2423,11 +2441,11 @@ MODINIT_DEFINE(_freetype) - c_api[1] = &pgFont_New; - - apiobj = encapsulate_api(c_api, "freetype"); -- if (PyModule_AddObject(module, PYGAMEAPI_LOCAL_ENTRY, apiobj)) { -+ if (PyModule_AddObject(_freetypemodule, PYGAMEAPI_LOCAL_ENTRY, apiobj)) { - Py_XDECREF(apiobj); -- Py_DECREF(module); -+ Py_DECREF(_freetypemodule); - return NULL; - } - -- return module; -+ return _freetypemodule; - } -diff --git a/src_c/freetype/ft_wrap.h b/src_c/freetype/ft_wrap.h -index 5fc059e556..034cccff01 100644 ---- a/src_c/freetype/ft_wrap.h -+++ b/src_c/freetype/ft_wrap.h -@@ -232,9 +232,10 @@ typedef struct { - } _FreeTypeState; - - #if !defined(PYPY_VERSION) --extern struct PyModuleDef _freetypemodule; -+extern struct PyModuleDef _freetypemoduledef; - #define FREETYPE_MOD_STATE(mod) ((_FreeTypeState *)PyModule_GetState(mod)) --#define FREETYPE_STATE FREETYPE_MOD_STATE(PyState_FindModule(&_freetypemodule)) -+#define FREETYPE_STATE \ -+ FREETYPE_MOD_STATE(PyState_FindModule(&_freetypemoduledef)) - #else /* defined(PYPY_VERSION) */ - extern _FreeTypeState _modstate; - #define FREETYPE_MOD_STATE(mod) (&_modstate) -diff --git a/src_py/freetype.py b/src_py/freetype.py -index 6c8dc0e4e2..d981a9ae06 100644 ---- a/src_py/freetype.py -+++ b/src_py/freetype.py -@@ -45,7 +45,7 @@ - - - def SysFont(name, size, bold=False, italic=False, constructor=None): -- """pygame.ftfont.SysFont(name, size, bold=False, italic=False, constructor=None) -> Font -+ """pygame.freetype.SysFont(name, size, bold=False, italic=False, constructor=None) -> Font - Create a pygame Font from system font resources. - - This will search the system fonts for the given font -diff --git a/src_py/sysfont.py b/src_py/sysfont.py -index cc05f983d8..59f0155b88 100644 ---- a/src_py/sysfont.py -+++ b/src_py/sysfont.py -@@ -203,14 +203,40 @@ def initsysfonts_darwin(): - return fonts - - --# read the fonts on unix -+# read the fonts on posix/unix - def initsysfonts_unix(path="fc-list"): -- """use the fc-list from fontconfig to get a list of fonts""" -+ """if not embedded, use the fc-list from fontconfig to get a list of fonts""" - fonts = {} - -- if sys.platform == "emscripten": -+ # these are embedded and cannot get os to list fonts a simple way. -+ if hasattr(sys, "getandroidapilevel") or sys.platform == "emscripten": -+ from pathlib import Path -+ -+ # default font -+ import importlib.resources -+ import pygame -+ -+ entry = importlib.resources.files(pygame) / "freesansbold.ttf" -+ _parse_font_entry_unix(f"{entry}: FreeSans:style=Bold", fonts) -+ -+ # cache in search order main script folder, then /tmp -+ main = __import__("__main__") -+ if hasattr(main, "__file__"): -+ fc_cache = Path(main.__file__).parent / "fc_cache" -+ else: -+ fc_cache = Path(__import__("tempfile").gettempdir()) / "fc_cache" -+ -+ if fc_cache.is_file(): -+ with open(fc_cache, "rb") as file: -+ for entry in file.read().decode("utf-8").splitlines(): -+ _parse_font_entry_unix(entry, fonts) -+ else: -+ warnings.warn(f"no fc_cache font cache file at {fc_cache}") -+ - return fonts - -+ # fallback to os support -+ - try: - proc = subprocess.run( - [path, ":", "file", "family", "style"], \ No newline at end of file diff --git a/packages/pygame-ce/patches/0001-wasm_unify_pygame_web_pyodide_static_Freetype_init.patch b/packages/pygame-ce/patches/0001-wasm_unify_pygame_web_pyodide_static_Freetype_init.patch deleted file mode 100644 index 3ae2da4c..00000000 --- a/packages/pygame-ce/patches/0001-wasm_unify_pygame_web_pyodide_static_Freetype_init.patch +++ /dev/null @@ -1,29 +0,0 @@ -https://github.com/pygame-community/pygame-ce/pull/2748 - ---- -diff --git a/src_c/static.c b/src_c/static.c -index 563b74d16..b7e8d1ec6 100644 ---- a/src_c/static.c -+++ b/src_c/static.c -@@ -14,6 +14,8 @@ - #include "pygame.h" - #include "Python.h" - -+#include -+ - #if defined(__EMSCRIPTEN__) - #undef WITH_THREAD - #endif -@@ -269,6 +271,12 @@ static struct PyModuleDef mod_pygame_static = {PyModuleDef_HEAD_INIT, - PyMODINIT_FUNC - PyInit_pygame_static() - { -+ // cannot fail here, and font_initialized is already set to 1 in font.c . -+ TTF_Init(); -+ -+ // for correct input in wasm worker -+ SDL_SetHint("SDL_EMSCRIPTEN_KEYBOARD_ELEMENT", "1"); -+ - load_submodule("pygame", PyInit_base(), "base"); - load_submodule("pygame", PyInit_constants(), "constants"); - load_submodule("pygame", PyInit_surflock(), "surflock");