Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 11 additions & 86 deletions packages/pygame-ce/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,99 +1,24 @@
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
# formats should be the same as the cibuildwheel config in pygame-ce
# https://github.com/pygame-community/pygame-ce/blob/e197e353fd33448abeed384dd4098e163c4998a5/pyproject.toml#L107
# 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"
embuilder --pic build sdl2 libhtml5 sdl2_ttf 'sdl2_mixer:formats=ogg,mp3,mod,mid'
post: |
# Remove docs to reduce the size of a wheel
# (Perhaps also remove typeshed and examples too?)
rm -rf ./pygame/docs
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not necessary, the docs are already removed by default in the emscripten build on our side

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good to know. Thanks!

# 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
SHARED_LIBS=$(find ${WHEELDIR} -name "*.so" ! -name "static*.so")
echo "shared libs: " $SHARED_LIBS
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
# Remove duplicated static.so module
rm -f ./pygame/static*.so
about:
home: https://www.pygame.org
PyPI: https://pypi.org/project/pygame
Expand Down
184 changes: 93 additions & 91 deletions packages/pygame-ce/test_pygame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ],
# )
Loading