diff --git a/.editorconfig b/.editorconfig index 27b9d1f03e..e26463f129 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,7 +11,7 @@ tab_width = 4 charset = utf-8 trim_trailing_whitespace = true -# The settings for C (*.c and *.h) files are mirrored in src_c/.clang-format. +# The settings for C (*.c and *.h) files are mirrored in src/.clang-format. # Keep them in sync. [*.{c,h}] max_line_length = 79 diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml index 2594db25d7..0374d9c2ae 100644 --- a/.github/workflows/cppcheck.yml +++ b/.github/workflows/cppcheck.yml @@ -1,16 +1,16 @@ name: cppcheck Static Analysis -# Run cppcheck on src_c changes to main branch, or any PR to main. +# Run cppcheck on src changes to main branch, or any PR to main. on: push: branches: main paths: - - 'src_c/**' + - 'src/**' pull_request: branches: main paths: - - 'src_c/**' + - 'src/**' concurrency: group: ${{ github.workflow }}-${{ github.ref }}-cppcheck @@ -34,8 +34,8 @@ jobs: - name: Run Static Checker # skip cppcheck on SDL_gfx, scrap, scale_mm* and ft_cache for now # suppress missingReturn and syntaxError because it gives many false positives - run: cppcheck src_c --enable=performance,portability,warning \ - --suppress=*:src_c/freetype/ft_cache.c --suppress=*:src_c/scrap* \ - --suppress=*:src_c/scale_mmx*.c --suppress=*:src_c/SDL_gfx/* \ + run: cppcheck src --enable=performance,portability,warning \ + --suppress=*:src/freetype/ft_cache.c --suppress=*:src/scrap* \ + --suppress=*:src/scale_mmx*.c --suppress=*:src/SDL_gfx/* \ --suppress=missingReturn --suppress=syntaxError -DWITH_THREAD -j $(nproc) \ -DPG_MAJOR_VERSION -DPG_MINOR_VERSION -DPG_PATCH_VERSION -DPG_VERSION_TAG diff --git a/.gitignore b/.gitignore index ee57d22510..c87af96d4d 100644 --- a/.gitignore +++ b/.gitignore @@ -50,7 +50,7 @@ _headers/* buildconfig/win_dll_dirs.json # cython generated files -src_c/_sdl2/*.c -!/src_c/_sdl2/touch.c -!/src_c/_sdl2/controller.c +src/_sdl2/*.c +!/src/_sdl2/touch.c +!/src/_sdl2/controller.c src_c/pypm.c diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 47597c7a4f..3e81128e31 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,11 +40,11 @@ repos: - id: clang-format exclude: | (?x)^( - ^src_c/_sdl2/.*$ - | ^src_c/doc/.*$ + ^src/_sdl2/.*$ + | ^src/.+/.*_doc.h$ | docs/reST/_static/script.js | docs/reST/_templates/header.h - | src_c/include/sse2neon.h - | src_c/include/pythoncapi_compat.h - | src_c/pypm.c + | src/include/sse2neon.h + | src/include/pythoncapi_compat.h + | src/pypm.c )$ diff --git a/buildconfig/MANIFEST.in b/buildconfig/MANIFEST.in index 9f9eab0c71..f5d37d4502 100644 --- a/buildconfig/MANIFEST.in +++ b/buildconfig/MANIFEST.in @@ -1,9 +1,7 @@ recursive-include buildconfig * recursive-include docs * -recursive-include src_py * -recursive-include src_c * +recursive-include src * recursive-include examples * -recursive-include test * recursive-exclude buildconfig/manylinux-build * recursive-exclude buildconfig/macdependencies * diff --git a/buildconfig/Setup.Android.SDL2.in b/buildconfig/Setup.Android.SDL2.in index 610d897d8c..fb9d84782d 100644 --- a/buildconfig/Setup.Android.SDL2.in +++ b/buildconfig/Setup.Android.SDL2.in @@ -13,54 +13,54 @@ DEBUG = #everything you can, but you can ignore ones you don't have #dependencies for, just comment them out -imageext src_c/imageext.c $(SDL) $(IMAGE) $(DEBUG) -font src_c/font.c $(SDL) $(FONT) $(DEBUG) -mixer src_c/mixer.c $(SDL) $(MIXER) $(DEBUG) -mixer_music src_c/music.c $(SDL) $(MIXER) $(DEBUG) -scrap src_c/scrap.c $(SDL) $(SCRAP) $(DEBUG) -# pypm src_c/pypm.c $(SDL) $(PORTMIDI) $(PORTTIME) $(DEBUG) +imageext src/imageext.c $(SDL) $(IMAGE) $(DEBUG) +font src/font.c $(SDL) $(FONT) $(DEBUG) +mixer src/mixer.c $(SDL) $(MIXER) $(DEBUG) +mixer_music src/music.c $(SDL) $(MIXER) $(DEBUG) +scrap src/scrap.c $(SDL) $(SCRAP) $(DEBUG) +# pypm src/pypm.c $(SDL) $(PORTMIDI) $(PORTTIME) $(DEBUG) -_sdl2.sdl2 src_c/_sdl2/sdl2.c $(SDL) $(DEBUG) -Isrc_c -_sdl2.audio src_c/_sdl2/audio.c $(SDL) $(DEBUG) -Isrc_c -_sdl2.video src_c/_sdl2/video.c src_c/pgcompat.c $(SDL) $(DEBUG) -Isrc_c -_sdl2.mixer src_c/_sdl2/mixer.c $(SDL) $(MIXER) $(DEBUG) -Isrc_c -_sdl2.touch src_c/_sdl2/touch.c $(SDL) $(DEBUG) -Isrc_c -_sdl2.controller_old src_c/_sdl2/controller_old.c $(SDL) $(DEBUG) -Isrc_c +_sdl2.sdl2 src/_sdl2/sdl2.c $(SDL) $(DEBUG) -Isrc +_sdl2.audio src/_sdl2/audio.c $(SDL) $(DEBUG) -Isrc +_sdl2.video src/_sdl2/video.c src/pgcompat.c $(SDL) $(DEBUG) -Isrc +_sdl2.mixer src/_sdl2/mixer.c $(SDL) $(MIXER) $(DEBUG) -Isrc +_sdl2.touch src/_sdl2/touch.c $(SDL) $(DEBUG) -Isrc +_sdl2.controller_old src/_sdl2/controller_old.c $(SDL) $(DEBUG) -Isrc -GFX = src_c/SDL_gfx/SDL_gfxPrimitives.c -#GFX = src_c/SDL_gfx/SDL_gfxBlitFunc.c src_c/SDL_gfx/SDL_gfxPrimitives.c -gfxdraw src_c/gfxdraw.c $(SDL) $(GFX) $(DEBUG) +GFX = src/SDL_gfx/SDL_gfxPrimitives.c +#GFX = src/SDL_gfx/SDL_gfxBlitFunc.c src/SDL_gfx/SDL_gfxPrimitives.c +gfxdraw src/gfxdraw.c $(SDL) $(GFX) $(DEBUG) #optional freetype module (do not break in multiple lines #or the configuration script will choke!) -#_freetype src_c/freetype/ft_cache.c src_c/freetype/ft_wrap.c src_c/freetype/ft_render.c src_c/freetype/ft_render_cb.c src_c/freetype/ft_layout.c src_c/freetype/ft_unicode.c src_c/_freetype.c $(SDL) $(FREETYPE) $(DEBUG) +#_freetype src/freetype/ft_cache.c src/freetype/ft_wrap.c src/freetype/ft_render.c src/freetype/ft_render_cb.c src/freetype/ft_layout.c src/freetype/ft_unicode.c src/_freetype.c $(SDL) $(FREETYPE) $(DEBUG) #these modules are required for pygame to run. they only require #SDL as a dependency. these should not be altered -base src_c/base.c $(SDL) $(DEBUG) -color src_c/color.c $(SDL) $(DEBUG) -constants src_c/constants.c $(SDL) $(DEBUG) -display src_c/display.c $(SDL) $(DEBUG) -event src_c/event.c $(SDL) $(DEBUG) -key src_c/key.c $(SDL) $(DEBUG) -mouse src_c/mouse.c $(SDL) $(DEBUG) -rect src_c/rect.c src_c/pgcompat_rect.c $(SDL) $(DEBUG) -rwobject src_c/rwobject.c $(SDL) $(DEBUG) -surface src_c/simd_blitters_sse2.c src_c/simd_blitters_avx2.c src_c/surface.c src_c/alphablit.c src_c/surface_fill.c src_c/simd_surface_fill_avx2.c src_c/simd_surface_fill_sse2.c $(SDL) $(DEBUG) -surflock src_c/surflock.c $(SDL) $(DEBUG) -time src_c/time.c $(SDL) $(DEBUG) -joystick src_c/joystick.c $(SDL) $(DEBUG) -draw src_c/draw.c $(SDL) $(DEBUG) -image src_c/image.c $(SDL) $(DEBUG) -transform src_c/simd_transform_sse2.c src_c/simd_transform_avx2.c src_c/transform.c src_c/rotozoom.c src_c/scale2x.c src_c/scale_mmx.c $(SDL) $(DEBUG) -D_NO_MMX_FOR_X86_64 -mask src_c/mask.c src_c/bitmask.c $(SDL) $(DEBUG) -bufferproxy src_c/bufferproxy.c $(SDL) $(DEBUG) -pixelarray src_c/pixelarray.c $(SDL) $(DEBUG) -math src_c/math.c $(SDL) $(DEBUG) -pixelcopy src_c/pixelcopy.c $(SDL) $(DEBUG) -newbuffer src_c/newbuffer.c $(SDL) $(DEBUG) -window src_c/window.c $(SDL) $(DEBUG) -_render src_c/render.c $(SDL) $(DEBUG) -geometry src_c/geometry.c $(SDL) $(DEBUG) +base src/base.c $(SDL) $(DEBUG) +color src/color.c $(SDL) $(DEBUG) +constants src/constants.c $(SDL) $(DEBUG) +display src/display.c $(SDL) $(DEBUG) +event src/event.c $(SDL) $(DEBUG) +key src/key.c $(SDL) $(DEBUG) +mouse src/mouse.c $(SDL) $(DEBUG) +rect src/rect.c src/pgcompat_rect.c $(SDL) $(DEBUG) +rwobject src/rwobject.c $(SDL) $(DEBUG) +surface src/simd_blitters_sse2.c src/simd_blitters_avx2.c src/surface.c src/alphablit.c src/surface_fill.c src/simd_surface_fill_avx2.c src/simd_surface_fill_sse2.c $(SDL) $(DEBUG) +surflock src/surflock.c $(SDL) $(DEBUG) +time src/time.c $(SDL) $(DEBUG) +joystick src/joystick.c $(SDL) $(DEBUG) +draw src/draw/draw.c $(SDL) $(DEBUG) +image src/image.c $(SDL) $(DEBUG) +transform src/simd_transform_sse2.c src/simd_transform_avx2.c src/transform.c src/rotozoom.c src/scale2x.c src/scale_mmx.c $(SDL) $(DEBUG) -D_NO_MMX_FOR_X86_64 +mask src/mask.c src/bitmask.c $(SDL) $(DEBUG) +bufferproxy src/bufferproxy.c $(SDL) $(DEBUG) +pixelarray src/pixelarray.c $(SDL) $(DEBUG) +math src/math.c $(SDL) $(DEBUG) +pixelcopy src/pixelcopy.c $(SDL) $(DEBUG) +newbuffer src/newbuffer.c $(SDL) $(DEBUG) +window src/window.c $(SDL) $(DEBUG) +_render src/render.c $(SDL) $(DEBUG) +geometry src/geometry.c $(SDL) $(DEBUG) diff --git a/buildconfig/Setup.Emscripten.SDL2.in b/buildconfig/Setup.Emscripten.SDL2.in index 9c465102f1..4970911650 100644 --- a/buildconfig/Setup.Emscripten.SDL2.in +++ b/buildconfig/Setup.Emscripten.SDL2.in @@ -15,64 +15,64 @@ DEBUG = # these can build alone and object files merged with ar -_sdl2.sdl2 src_c/_sdl2/sdl2.c $(SDL) $(DEBUG) -Isrc_c +_sdl2.sdl2 src/_sdl2/sdl2.c $(SDL) $(DEBUG) -Isrc -_sdl2.audio src_c/_sdl2/audio.c $(SDL) $(DEBUG) -Isrc_c +_sdl2.audio src/_sdl2/audio.c $(SDL) $(DEBUG) -Isrc -pygame_sdl2_video src_c/_sdl2/video.c src_c/pgcompat.c $(SDL) $(DEBUG) -Isrc_c -_sdl2.video = src_c/void.c +pygame_sdl2_video src/_sdl2/video.c src/pgcompat.c $(SDL) $(DEBUG) -Isrc +_sdl2.video = src/static/void.c -_sdl2.mixer src_c/_sdl2/mixer.c $(SDL) $(MIXER) $(DEBUG) -Isrc_c +_sdl2.mixer src/_sdl2/mixer.c $(SDL) $(MIXER) $(DEBUG) -Isrc -constants src_c/constants.c $(SDL) $(DEBUG) -mask src_c/bitmask.c -math src_c/math.c $(SDL) $(DEBUG) +constants src/constants.c $(SDL) $(DEBUG) +mask src/bitmask.c +math src/math.c $(SDL) $(DEBUG) -#GFX = src_c/SDL_gfx/SDL_gfxBlitFunc.c src_c/SDL_gfx/SDL_gfxPrimitives.c -GFX = src_c/SDL_gfx/SDL_gfxPrimitives.c +#GFX = src/SDL_gfx/SDL_gfxBlitFunc.c src/SDL_gfx/SDL_gfxPrimitives.c +GFX = src/SDL_gfx/SDL_gfxPrimitives.c -static src_c/static.c $(SDL) $(FREETYPE) $(FONT) $(MIXER) $(IMAGE) $(PNG) $(JPEG) $(DEBUG) +static src/static/static.c $(SDL) $(FREETYPE) $(FONT) $(MIXER) $(IMAGE) $(PNG) $(JPEG) $(DEBUG) # these should not be altered they already are in static.c merging file above -time src_c/void.c -_freetype src_c/void.c -imageext src_c/void.c -image src_c/void.c -base src_c/void.c -bufferproxy src_c/void.c -color src_c/void.c -controller src_c/void.c -controller_old src_c/void.c -display src_c/void.c -draw src_c/void.c -event src_c/void.c -font src_c/void.c -gfxdraw src_c/void.c -joystick src_c/void.c -key src_c/void.c -newbuffer src_c/void.c -mixer_music src_c/void.c -mixer src_c/void.c -mouse src_c/void.c -pixelcopy src_c/void.c -pixelarray src_c/void.c -surface src_c/void.c -surflock src_c/void.c -rect src_c/void.c -rwobject src_c/void.c -system src_c/void.c -window src_c/void.c -_render src_c/void.c -geometry src_c/void.c - -#_sdl2.controller src_c/_sdl2/controller.c $(SDL) $(DEBUG) -Isrc_c -_sdl2.controller src_c/void.c -_sdl2.controller_old src_c/void.c - -#_sdl2.touch src_c/_sdl2/touch.c $(SDL) $(DEBUG) -Isrc_c -_sdl2.touch src_c/void.c - -#transform src_c/simd_transform_sse2.c src_c/simd_transform_avx2.c src_c/transform.c src_c/rotozoom.c src_c/scale2x.c src_c/scale_mmx.c src_c/simd_surface_fill_avx2.c src_c/simd_surface_fill_sse2.c $(SDL) $(DEBUG) -D_NO_MMX_FOR_X86_64 -transform src_c/void.c +time src/static/void.c +_freetype src/static/void.c +imageext src/static/void.c +image src/static/void.c +base src/static/void.c +bufferproxy src/static/void.c +color src/static/void.c +controller src/static/void.c +controller_old src/static/void.c +display src/static/void.c +draw src/static/void.c +event src/static/void.c +font src/static/void.c +gfxdraw src/static/void.c +joystick src/static/void.c +key src/static/void.c +newbuffer src/static/void.c +mixer_music src/static/void.c +mixer src/static/void.c +mouse src/static/void.c +pixelcopy src/static/void.c +pixelarray src/static/void.c +surface src/static/void.c +surflock src/static/void.c +rect src/static/void.c +rwobject src/static/void.c +system src/static/void.c +window src/static/void.c +_render src/static/void.c +geometry src/static/void.c + +#_sdl2.controller src/_sdl2/controller.c $(SDL) $(DEBUG) -Isrc +_sdl2.controller src/static/void.c +_sdl2.controller_old src/static/void.c + +#_sdl2.touch src/_sdl2/touch.c $(SDL) $(DEBUG) -Isrc +_sdl2.touch src/static/void.c + +#transform src/simd_transform_sse2.c src/simd_transform_avx2.c src/transform.c src/rotozoom.c src/scale2x.c src/scale_mmx.c src/simd_surface_fill_avx2.c src/simd_surface_fill_sse2.c $(SDL) $(DEBUG) -D_NO_MMX_FOR_X86_64 +transform src/static/void.c diff --git a/buildconfig/Setup.SDL2.in b/buildconfig/Setup.SDL2.in index 0acde7e2fe..c185315864 100644 --- a/buildconfig/Setup.SDL2.in +++ b/buildconfig/Setup.SDL2.in @@ -23,56 +23,56 @@ DEBUG = #everything you can, but you can ignore ones you don't have #dependencies for, just comment them out -imageext src_c/imageext.c $(SDL) $(IMAGE) $(DEBUG) -font src_c/font.c $(SDL) $(FONT) $(DEBUG) -mixer src_c/mixer.c $(SDL) $(MIXER) $(DEBUG) -mixer_music src_c/music.c $(SDL) $(MIXER) $(DEBUG) -scrap src_c/scrap.c $(SDL) $(SCRAP) $(DEBUG) -pypm src_c/pypm.c $(SDL) $(PORTMIDI) $(PORTTIME) $(DEBUG) +imageext src/imageext.c $(SDL) $(IMAGE) $(DEBUG) +font src/font.c $(SDL) $(FONT) $(DEBUG) +mixer src/mixer.c $(SDL) $(MIXER) $(DEBUG) +mixer_music src/music.c $(SDL) $(MIXER) $(DEBUG) +scrap src/scrap.c $(SDL) $(SCRAP) $(DEBUG) +pypm src/pypm.c $(SDL) $(PORTMIDI) $(PORTTIME) $(DEBUG) -_sdl2.sdl2 src_c/_sdl2/sdl2.c $(SDL) $(DEBUG) -Isrc_c -_sdl2.audio src_c/_sdl2/audio.c $(SDL) $(DEBUG) -Isrc_c -_sdl2.video src_c/_sdl2/video.c src_c/pgcompat.c $(SDL) $(DEBUG) -Isrc_c -_sdl2.mixer src_c/_sdl2/mixer.c $(SDL) $(MIXER) $(DEBUG) -Isrc_c -_sdl2.touch src_c/_sdl2/touch.c $(SDL) $(DEBUG) -Isrc_c -_sdl2.controller src_c/_sdl2/controller.c $(SDL) $(DEBUG) -Isrc_c -_sdl2.controller_old src_c/_sdl2/controller_old.c $(SDL) $(DEBUG) -Isrc_c +_sdl2.sdl2 src/_sdl2/sdl2.c $(SDL) $(DEBUG) -Isrc +_sdl2.audio src/_sdl2/audio.c $(SDL) $(DEBUG) -Isrc +_sdl2.video src/_sdl2/video.c src/pgcompat.c $(SDL) $(DEBUG) -Isrc +_sdl2.mixer src/_sdl2/mixer.c $(SDL) $(MIXER) $(DEBUG) -Isrc +_sdl2.touch src/_sdl2/touch.c $(SDL) $(DEBUG) -Isrc +_sdl2.controller src/_sdl2/controller.c $(SDL) $(DEBUG) -Isrc +_sdl2.controller_old src/_sdl2/controller_old.c $(SDL) $(DEBUG) -Isrc -GFX = src_c/SDL_gfx/SDL_gfxPrimitives.c -#GFX = src_c/SDL_gfx/SDL_gfxBlitFunc.c src_c/SDL_gfx/SDL_gfxPrimitives.c -gfxdraw src_c/gfxdraw.c $(SDL) $(GFX) $(DEBUG) +GFX = src/SDL_gfx/SDL_gfxPrimitives.c +#GFX = src/SDL_gfx/SDL_gfxBlitFunc.c src/SDL_gfx/SDL_gfxPrimitives.c +gfxdraw src/gfxdraw.c $(SDL) $(GFX) $(DEBUG) #optional freetype module (do not break in multiple lines #or the configuration script will choke!) -_freetype src_c/freetype/ft_cache.c src_c/freetype/ft_wrap.c src_c/freetype/ft_render.c src_c/freetype/ft_render_cb.c src_c/freetype/ft_layout.c src_c/freetype/ft_unicode.c src_c/_freetype.c $(SDL) $(FREETYPE) $(DEBUG) +_freetype src/freetype/ft_cache.c src/freetype/ft_wrap.c src/freetype/ft_render.c src/freetype/ft_render_cb.c src/freetype/ft_layout.c src/freetype/ft_unicode.c src/_freetype.c $(SDL) $(FREETYPE) $(DEBUG) #these modules are required for pygame to run. they only require #SDL as a dependency. these should not be altered -base src_c/base.c $(SDL) $(DEBUG) -color src_c/color.c $(SDL) $(DEBUG) -constants src_c/constants.c $(SDL) $(DEBUG) -display src_c/display.c $(SDL) $(DEBUG) -event src_c/event.c $(SDL) $(DEBUG) -key src_c/key.c $(SDL) $(DEBUG) -mouse src_c/mouse.c $(SDL) $(DEBUG) -rect src_c/rect.c src_c/pgcompat_rect.c $(SDL) $(DEBUG) -rwobject src_c/rwobject.c $(SDL) $(DEBUG) -surface src_c/simd_blitters_sse2.c src_c/simd_blitters_avx2.c src_c/surface.c src_c/alphablit.c src_c/surface_fill.c src_c/simd_surface_fill_avx2.c src_c/simd_surface_fill_sse2.c $(SDL) $(DEBUG) -surflock src_c/surflock.c $(SDL) $(DEBUG) -time src_c/time.c $(SDL) $(DEBUG) -joystick src_c/joystick.c $(SDL) $(DEBUG) -draw src_c/draw.c $(SDL) $(DEBUG) -image src_c/image.c $(SDL) $(DEBUG) -transform src_c/simd_transform_sse2.c src_c/simd_transform_avx2.c src_c/transform.c src_c/rotozoom.c src_c/scale2x.c src_c/scale_mmx.c $(SDL) $(DEBUG) -mask src_c/mask.c src_c/bitmask.c $(SDL) $(DEBUG) -bufferproxy src_c/bufferproxy.c $(SDL) $(DEBUG) -pixelarray src_c/pixelarray.c $(SDL) $(DEBUG) -math src_c/math.c $(SDL) $(DEBUG) -pixelcopy src_c/pixelcopy.c $(SDL) $(DEBUG) -newbuffer src_c/newbuffer.c $(SDL) $(DEBUG) -system src_c/system.c $(SDL) $(DEBUG) -geometry src_c/geometry.c $(SDL) $(DEBUG) -window src_c/window.c $(SDL) $(DEBUG) -_render src_c/render.c $(SDL) $(DEBUG) +base src/base.c $(SDL) $(DEBUG) +color src/color.c $(SDL) $(DEBUG) +constants src/constants.c $(SDL) $(DEBUG) +display src/display.c $(SDL) $(DEBUG) +event src/event.c $(SDL) $(DEBUG) +key src/key.c $(SDL) $(DEBUG) +mouse src/mouse.c $(SDL) $(DEBUG) +rect src/rect.c src/pgcompat_rect.c $(SDL) $(DEBUG) +rwobject src/rwobject.c $(SDL) $(DEBUG) +surface src/simd_blitters_sse2.c src/simd_blitters_avx2.c src/surface.c src/alphablit.c src/surface_fill.c src/simd_surface_fill_avx2.c src/simd_surface_fill_sse2.c $(SDL) $(DEBUG) +surflock src/surflock.c $(SDL) $(DEBUG) +time src/time.c $(SDL) $(DEBUG) +joystick src/joystick.c $(SDL) $(DEBUG) +draw src/draw/draw.c $(SDL) $(DEBUG) +image src/image.c $(SDL) $(DEBUG) +transform src/simd_transform_sse2.c src/simd_transform_avx2.c src/transform.c src/rotozoom.c src/scale2x.c src/scale_mmx.c $(SDL) $(DEBUG) +mask src/mask.c src/bitmask.c $(SDL) $(DEBUG) +bufferproxy src/bufferproxy.c $(SDL) $(DEBUG) +pixelarray src/pixelarray.c $(SDL) $(DEBUG) +math src/math.c $(SDL) $(DEBUG) +pixelcopy src/pixelcopy.c $(SDL) $(DEBUG) +newbuffer src/newbuffer.c $(SDL) $(DEBUG) +system src/system.c $(SDL) $(DEBUG) +geometry src/geometry.c $(SDL) $(DEBUG) +window src/window.c $(SDL) $(DEBUG) +_render src/render.c $(SDL) $(DEBUG) diff --git a/buildconfig/Setup_Darwin.in b/buildconfig/Setup_Darwin.in index 8ce19cd21e..2b7a176599 100644 --- a/buildconfig/Setup_Darwin.in +++ b/buildconfig/Setup_Darwin.in @@ -1,4 +1,4 @@ #This file defines platform specific modules for mac os x SCRAP = -scrap src_c/scrap.c $(SDL) $(SCRAP) $(DEBUG) -_camera src_c/_camera.c $(SDL) $(DEBUG) +scrap src/scrap.c $(SDL) $(SCRAP) $(DEBUG) +_camera src/_camera.c $(SDL) $(DEBUG) diff --git a/buildconfig/Setup_Unix.in b/buildconfig/Setup_Unix.in index f69aea082a..6346d1609d 100644 --- a/buildconfig/Setup_Unix.in +++ b/buildconfig/Setup_Unix.in @@ -1,2 +1,2 @@ #This file defines platform specific modules for linux -_camera src_c/_camera.c src_c/camera_v4l2.c $(SDL) $(DEBUG) +_camera src/_camera.c src/camera_v4l2.c $(SDL) $(DEBUG) diff --git a/buildconfig/Setup_Win_Camera.in b/buildconfig/Setup_Win_Camera.in index 7e28265599..d577267fa1 100644 --- a/buildconfig/Setup_Win_Camera.in +++ b/buildconfig/Setup_Win_Camera.in @@ -1 +1 @@ -_camera src_c/_camera.c src_c/camera_windows.c -lMfplat -lMf -lMfuuid -lMfreadwrite -lOle32 $(SDL) $(DEBUG) +_camera src/_camera.c src/camera_windows.c -lMfplat -lMf -lMfuuid -lMfreadwrite -lOle32 $(SDL) $(DEBUG) diff --git a/buildconfig/make_docs.py b/buildconfig/make_docs.py index 25664042c9..3e4c840d29 100755 --- a/buildconfig/make_docs.py +++ b/buildconfig/make_docs.py @@ -3,13 +3,37 @@ import sys import os import subprocess +import glob rst_dir = 'docs' rst_source_dir = os.path.join(rst_dir, 'reST') rst_build_dir = os.path.join('docs', 'generated') rst_doctree_dir = os.path.join(rst_build_dir, 'doctrees') -c_header_dir = os.path.join('src_c', 'doc') +c_header_dir = os.path.join('src', 'docs') +special_paths = { + "music": os.path.join("src", "mixer"), + "pygame": os.path.join("src", "base"), + "controller": os.path.join("src", "_sdl2", "controller"), + "touch": os.path.join("src", "_sdl2", "touch"), + "video": os.path.join("src", "_sdl2", "video"), + "freetype": os.path.join("src", "_freetype") +} + +def move_doc_headers(): + for file in glob.glob(f'{c_header_dir}/*.h'): + file_name = file.replace(c_header_dir + os.sep, '') + module_name = file.replace('_doc.h', '').replace(c_header_dir + os.sep, '') + args = ['src', module_name] + if 'sdl2_' in module_name: + module_name = module_name.replace('sdl2_', '') + args.insert(1, 'sdl2') + path = special_paths[module_name] if module_name in special_paths else os.path.join(*args) + if os.path.exists(path): + os.replace(file, os.path.join(path, file_name)) + print(f"Moved file {file_name} from {file} to {os.path.join(path, file_name)}") + else: + print(f"Skipping file {file} because there is no destination") def run(): full_generation_flag = False @@ -27,7 +51,11 @@ def run(): if full_generation_flag: subprocess_args.append('-E') print("Executing sphinx in subprocess with args:", subprocess_args) - return subprocess.run(subprocess_args).returncode + returncode = subprocess.run(subprocess_args).returncode + if returncode != 0: + return returncode + move_doc_headers() + return 0 except Exception: print('---') print('Have you installed sphinx?') diff --git a/buildconfig/stubs/gen_stubs.py b/buildconfig/stubs/gen_stubs.py index f78d5e9f11..5c28136c00 100644 --- a/buildconfig/stubs/gen_stubs.py +++ b/buildconfig/stubs/gen_stubs.py @@ -110,7 +110,7 @@ def get_all(mod: Any): misc_stubs = """""" # write constants.pyi file -constants_file = pathlib.Path(__file__).parent / "pygame" / "constants.pyi" +constants_file = pathlib.Path(__file__).parent.parent.parent / "src" / "constants" / "constants.pyi" with open(constants_file, "w") as f: # write the module docstring of this file in the generated file, so that # people know this file exists @@ -123,7 +123,7 @@ def get_all(mod: Any): # write __init__.pyi file -init_file = pathlib.Path(__file__).parent / "pygame" / "__init__.pyi" +init_file = pathlib.Path(__file__).parent.parent.parent / "src" / "pygame" / "__init__.pyi" with open(init_file, "w") as f: # write the module docstring of this file in the generated file, so that # people know this file exists @@ -148,7 +148,7 @@ def get_all(mod: Any): f.write(")\n") # write locals.pyi file -locals_file = pathlib.Path(__file__).parent / "pygame" / "locals.pyi" +locals_file = pathlib.Path(__file__).parent.parent.parent / "src" / "locals" / "locals.pyi" with open(locals_file, "w") as f: f.write(info_header) f.write("\n") @@ -158,6 +158,7 @@ def get_all(mod: Any): f.write(f"{element}: {constant_type}\n") # copy typing.py to typing.pyi for type checkers -typing_py_file = pathlib.Path(__file__).parent.parent.parent / "src_py" / "typing.py" -typing_stub_file = pathlib.Path(__file__).parent / "pygame" / "typing.pyi" +typing_dir = pathlib.Path(__file__).parent.parent.parent / "src" / "typing" +typing_py_file = typing_dir / "typing.py" +typing_stub_file = typing_dir / "typing.pyi" shutil.copyfile(typing_py_file, typing_stub_file) diff --git a/buildconfig/stubs/mypy_allow_list.txt b/buildconfig/stubs/mypy_allow_list.txt index 1e7c532d72..132d5609ef 100644 --- a/buildconfig/stubs/mypy_allow_list.txt +++ b/buildconfig/stubs/mypy_allow_list.txt @@ -5,14 +5,17 @@ # cython files have this top level dunder pygame\._sdl2\..*\.__test__ -# cython classes have some special dunders for internal use, ignore that in -# stubtest -pygame\._sdl2\..*\.__pyx_.*__ - # don't look for stubs for examples or for tests pygame\.examples.* pygame\.tests.* +# don't look for stubs for modules that are not auto-imported +pygame\.camera +pygame\.gfxdraw +pygame\.freetype +pygame\.midi +pygame\._sdl2.* + # don't look for stubs for pyinstaller hook pygame\.__pyinstaller.* pygame\.__briefcase.* @@ -24,6 +27,5 @@ pygame\.macosx pygame\.newbuffer pygame\.pkgdata pygame\.pypm -pygame\._sdl2\.mixer pygame\.sysfont.* pygame\.docs.* diff --git a/dev.py b/dev.py index d334178c04..2637636984 100644 --- a/dev.py +++ b/dev.py @@ -271,7 +271,7 @@ def cmd_docs(self): def cmd_lint(self): pprint("Linting code (with pylint)") - cmd_run([self.py, "-m", "pylint", "src_py", "docs"]) + cmd_run([self.py, "-m", "pylint", "docs"]) def cmd_stubs(self): pprint("Generating and testing type stubs (with mypy)") diff --git a/docs/reST/c_api.rst b/docs/reST/c_api.rst index f83223722d..e412c225ca 100644 --- a/docs/reST/c_api.rst +++ b/docs/reST/c_api.rst @@ -22,6 +22,6 @@ pygame C API c_api/window.rst -src_c/include/ contains header files for applications -that use the pygame C API, while src_c/ contains +src/include/ contains header files for applications +that use the pygame C API, while src/ contains headers used by pygame internally. diff --git a/docs/reST/c_api/base.rst b/docs/reST/c_api/base.rst index f53d9813c6..e160b9e656 100644 --- a/docs/reST/c_api/base.rst +++ b/docs/reST/c_api/base.rst @@ -6,13 +6,13 @@ High level API exported by pygame.base ****************************************** -src_c/base.c +src/base.c ============ This extension module defines general purpose routines for starting and stopping SDL as well as various conversion routines uses elsewhere in pygame. -C header: src_c/include/pygame.h +C header: src/include/pygame.h .. c:var:: PyObject* pgExc_SDLError diff --git a/docs/reST/c_api/bufferproxy.rst b/docs/reST/c_api/bufferproxy.rst index 5edaf7b4ae..48c8b38ce1 100644 --- a/docs/reST/c_api/bufferproxy.rst +++ b/docs/reST/c_api/bufferproxy.rst @@ -6,7 +6,7 @@ Class BufferProxy API exported by pygame.bufferproxy ******************************************************** -src_c/bufferproxy.c +src/bufferproxy.c =================== This extension module defines Python type :py:class:`pygame.BufferProxy`. diff --git a/docs/reST/c_api/color.rst b/docs/reST/c_api/color.rst index f6349fe805..8bc173cc03 100644 --- a/docs/reST/c_api/color.rst +++ b/docs/reST/c_api/color.rst @@ -6,12 +6,12 @@ Class Color API exported by pygame.color ******************************************** -src_c/color.c +src/color.c ============= This extension module defines the Python type :py:class:`pygame.Color`. -Header file: src_c/include/pygame.h +Header file: src/include/pygame.h .. c:var:: PyTypeObject *pgColor_Type diff --git a/docs/reST/c_api/display.rst b/docs/reST/c_api/display.rst index e1aef534e7..0f9d6d7fa3 100644 --- a/docs/reST/c_api/display.rst +++ b/docs/reST/c_api/display.rst @@ -6,12 +6,12 @@ API exported by pygame.display ********************************** -src_c/display.c +src/display.c =============== This is the :py:mod:`pygame.display` extension module. -Header file: src_c/include/pygame.h +Header file: src/include/pygame.h .. c:type:: pgVidInfoObject diff --git a/docs/reST/c_api/event.rst b/docs/reST/c_api/event.rst index 650dccd25b..479c406471 100644 --- a/docs/reST/c_api/event.rst +++ b/docs/reST/c_api/event.rst @@ -6,12 +6,12 @@ API exported by pygame.event ******************************** -src_c/event.c +src/event.c ============= The extension module :py:mod:`pygame.event`. -Header file: src_c/include/pygame.h +Header file: src/include/pygame.h .. c:type:: pgEventObject diff --git a/docs/reST/c_api/freetype.rst b/docs/reST/c_api/freetype.rst index 30efb4e078..3c64bb846d 100644 --- a/docs/reST/c_api/freetype.rst +++ b/docs/reST/c_api/freetype.rst @@ -6,12 +6,12 @@ API exported by pygame._freetype ************************************ -src_c/_freetype.c +src/_freetype.c ================= This extension module defines Python type :py:class:`pygame.freetype.Font`. -Header file: src_c/include/pygame_freetype.h +Header file: src/include/pygame_freetype.h .. c:type:: pgFontObject diff --git a/docs/reST/c_api/joystick.rst b/docs/reST/c_api/joystick.rst index 507a00b2f7..2ecda6192e 100644 --- a/docs/reST/c_api/joystick.rst +++ b/docs/reST/c_api/joystick.rst @@ -6,12 +6,12 @@ API exported by pygame.joystick ****************************************** -src_c/joystick.c +src/joystick.c ================ The extension module :py:mod:`pygame.joystick`. -Header file: src_c/include/pygame.h +Header file: src/include/pygame.h .. c:var:: PyTypeObject *pgJoystick_Type diff --git a/docs/reST/c_api/mixer.rst b/docs/reST/c_api/mixer.rst index 6cd281a2df..4c9e48ad4a 100644 --- a/docs/reST/c_api/mixer.rst +++ b/docs/reST/c_api/mixer.rst @@ -6,13 +6,13 @@ API exported by pygame.mixer ******************************** -src_c/mixer.c +src/mixer.c ============= Python types and module startup/shutdown functions defined in the :py:mod:`pygame.mixer` extension module. -Header file: src_c/include/pygame_mixer.h +Header file: src/include/pygame_mixer.h .. c:type:: pgSoundObject diff --git a/docs/reST/c_api/rect.rst b/docs/reST/c_api/rect.rst index 147a68cc7e..8f9b8db0a1 100644 --- a/docs/reST/c_api/rect.rst +++ b/docs/reST/c_api/rect.rst @@ -6,12 +6,12 @@ Class Rect API exported by pygame.rect ****************************************** -src_c/rect.c +src/rect.c ============ This extension module defines Python type :py:class:`pygame.Rect` & :py:class:`pygame.FRect`. -Header file: src_c/include/pygame.h +Header file: src/include/pygame.h .. c:type:: pgRectObject diff --git a/docs/reST/c_api/rwobject.rst b/docs/reST/c_api/rwobject.rst index 3507118451..4b78347dfa 100644 --- a/docs/reST/c_api/rwobject.rst +++ b/docs/reST/c_api/rwobject.rst @@ -6,13 +6,13 @@ API exported by pygame.rwobject *********************************** -src_c/rwobject.c +src/rwobject.c ================ This extension module implements functions for wrapping a Python file like object in a :c:type:`SDL_RWops` struct for SDL file access. -Header file: src_c/include/pygame.h +Header file: src/include/pygame.h .. c:function:: SDL_RWops* pgRWops_FromObject(PyObject *obj, char **extptr) diff --git a/docs/reST/c_api/slots.rst b/docs/reST/c_api/slots.rst index 9477b397cd..82c0911889 100644 --- a/docs/reST/c_api/slots.rst +++ b/docs/reST/c_api/slots.rst @@ -14,7 +14,7 @@ base.c has this exposing the pg_RGBAFromObj function to the `c_api` structure: c_api[12] = pg_RGBAFromObj; -Then in src_c/include/_pygame.h there is an +Then in src/include/_pygame.h there is an #define pg_RGBAFromObj. diff --git a/docs/reST/c_api/surface.rst b/docs/reST/c_api/surface.rst index a394d629f0..e24be93773 100644 --- a/docs/reST/c_api/surface.rst +++ b/docs/reST/c_api/surface.rst @@ -6,12 +6,12 @@ Class Surface API exported by pygame.surface ************************************************ -src_c/surface.c +src/surface.c =============== This extension module defines Python type :py:class:`pygame.Surface`. -Header file: src_c/include/pygame.h +Header file: src/include/pygame.h .. c:type:: pgSurfaceObject diff --git a/docs/reST/c_api/surflock.rst b/docs/reST/c_api/surflock.rst index 9e08034dea..2fa30caceb 100644 --- a/docs/reST/c_api/surflock.rst +++ b/docs/reST/c_api/surflock.rst @@ -6,13 +6,13 @@ API exported by pygame.surflock *********************************** -src_c/surflock.c +src/surflock.c ================ This extension module implements SDL surface locking for the :py:class:`pygame.Surface` type. -Header file: src_c/include/pygame.h +Header file: src/include/pygame.h .. c:function:: void pgSurface_Prep(pgSurfaceObject *surfobj) diff --git a/docs/reST/c_api/version.rst b/docs/reST/c_api/version.rst index c8f98d896d..92c9354186 100644 --- a/docs/reST/c_api/version.rst +++ b/docs/reST/c_api/version.rst @@ -9,7 +9,7 @@ src_py/version.py ================= -Header file: src_c/include/pygame.h +Header file: src/include/pygame.h Version information can be retrieved at compile-time using these macros. diff --git a/docs/reST/c_api/window.rst b/docs/reST/c_api/window.rst index 4ab8f083a2..c0b381c775 100644 --- a/docs/reST/c_api/window.rst +++ b/docs/reST/c_api/window.rst @@ -6,12 +6,12 @@ Class Window API exported by pygame.window ************************************************ -src_c/window.c +src/window.c =============== This extension module defines Python type :py:class:`pygame.Window`. -Header file: src_c/include/pygame.h +Header file: src/include/pygame.h .. c:type:: pgWindowObject diff --git a/docs/reST/conf.py b/docs/reST/conf.py index 1dd12d1673..3e77dfaccf 100644 --- a/docs/reST/conf.py +++ b/docs/reST/conf.py @@ -28,8 +28,7 @@ autoapi_dirs = [ - pathlib.Path('.').resolve().parent.parent / 'buildconfig' / 'stubs' / 'pygame', - pathlib.Path('.').resolve().parent.parent / 'src_py', + pathlib.Path('.').resolve().parent.parent / 'src' / 'pygame', ] autoapi_options = ['members', 'undoc-members'] diff --git a/docs/reST/ref/transform.rst b/docs/reST/ref/transform.rst index 4039583704..731f3a7334 100644 --- a/docs/reST/ref/transform.rst +++ b/docs/reST/ref/transform.rst @@ -433,9 +433,9 @@ Instead, always begin with the original image and scale to the desired size.) :Examples: - See the threshold tests for an example: https://github.com/pygame-community/pygame-ce/blob/main/test/transform_test.py + See the threshold tests for an example: https://github.com/pygame-community/pygame-ce/blob/main/src/transform/transform_test.py - .. literalinclude:: ../../../test/transform_test.py + .. literalinclude:: ../../../src/transform/transform_test.py :pyobject: TransformModuleTest.test_threshold_dest_surf_not_change diff --git a/examples/blit_blends.py b/examples/blit_blends.py index 12da36b92c..530b53d486 100644 --- a/examples/blit_blends.py +++ b/examples/blit_blends.py @@ -30,6 +30,7 @@ try: import numpy + import pygame.surfarray except ImportError: print("no surfarray for you! install numpy") diff --git a/examples/sound_array_demos.py b/examples/sound_array_demos.py index 6defd03416..d4a9668436 100644 --- a/examples/sound_array_demos.py +++ b/examples/sound_array_demos.py @@ -17,9 +17,10 @@ import os import time -import pygame from numpy import int16, int32, zeros +import pygame + # pygame.mixer.init(44100, -16, 0) pygame.mixer.init() # pygame.mixer.init(11025, -16, 0) diff --git a/examples/window_opengl.py b/examples/window_opengl.py index 253e5def48..eb6b0c6149 100644 --- a/examples/window_opengl.py +++ b/examples/window_opengl.py @@ -6,9 +6,10 @@ Posted here with permission from https://github.com/szabolcsdombi given in the PGC discord server """ -import pygame import zengl +import pygame + def main(): window_size = (1280, 720) diff --git a/meson.build b/meson.build index 96a721a74a..571da00d45 100644 --- a/meson.build +++ b/meson.build @@ -417,8 +417,7 @@ else endif endif -subdir('src_c') -subdir('src_py') +subdir('src') if not get_option('stripped') # run make_docs and make docs @@ -432,7 +431,6 @@ if not get_option('stripped') message(res.stderr().strip()) endif subdir('docs') - subdir('test') subdir('buildconfig/stubs') install_subdir('examples', install_dir: pg_dir, install_tag: 'pg-tag') # TODO: install headers? not really important though diff --git a/pyproject.toml b/pyproject.toml index 2506837f6f..9e162f7830 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,7 +94,7 @@ setup-args = [ [tool.ruff] exclude = [ "buildconfig/*.py", - "buildconfig/stubs/pygame/typing.pyi", + "src/typing/*", "docs/reST/", "setup.py", ] diff --git a/setup.py b/setup.py index 001edc3e2c..1f569206cc 100644 --- a/setup.py +++ b/setup.py @@ -229,8 +229,8 @@ def consume_arg(name): import glob - pyx_files = glob.glob(os.path.join('src_c', 'cython', 'pygame', '*.pyx')) + \ - glob.glob(os.path.join('src_c', 'cython', 'pygame', '**', '*.pyx')) + pyx_files = glob.glob(os.path.join('src', 'cython', 'pygame', '*.pyx')) + \ + glob.glob(os.path.join('src', 'cython', 'pygame', '**', '*.pyx')) pyx_files, pyx_meta = create_extension_list(pyx_files, ctx=ctx) deps = create_dependency_tree(ctx) @@ -241,7 +241,7 @@ def consume_arg(name): pyx_file = ext.sources[0] # TODO: check all sources, extension c_file = os.path.splitext(pyx_file)[0].split(os.path.sep) - del c_file[1:3] # output in src_c/ + del c_file[1:3] # output in src/ c_file = os.path.sep.join(c_file) + '.c' # update outdated .c files @@ -325,9 +325,9 @@ def do_directory(root_dest_path, root_src_path, elements): }) # headers to install -headers = glob.glob(os.path.join('src_c', '*.h')) -headers.remove(os.path.join('src_c', 'scale.h')) -headers.append(os.path.join('src_c', 'include')) +headers = glob.glob(os.path.join('src', '*.h')) +headers.remove(os.path.join('src', 'scale.h')) +headers.append(os.path.join('src', 'include')) import distutils.command.install_headers @@ -858,8 +858,8 @@ def run(self): 'pygame.tests': 'test', 'pygame.docs': 'docs', 'pygame.examples': 'examples', - 'pygame.__pyinstaller': 'src_py/__pyinstaller', - 'pygame.__briefcase': 'src_py/__briefcase'}, + 'pygame.__pyinstaller': 'src/__pyinstaller', + 'pygame.__briefcase': 'src/__briefcase'}, "headers": headers, "ext_modules": extensions, "data_files": data_files, @@ -867,11 +867,11 @@ def run(self): } if STRIPPED: pygame_data_files = [] - data_files = [('pygame', ["src_py/freesansbold.ttf", - "src_py/pygame.ico", - "src_py/pygame_icon.icns", - "src_py/pygame_icon.bmp", - "src_py/pygame_icon_mac.bmp"])] + data_files = [('pygame', ["src/resources/freesansbold.ttf", + "src/resources/pygame.ico", + "src/resources/pygame_icon.icns", + "src/resources/pygame_icon.bmp", + "src/resources/pygame_icon_mac.bmp"])] PACKAGEDATA = { "cmdclass": cmdclass, diff --git a/src_c/.clang-format b/src/.clang-format similarity index 100% rename from src_c/.clang-format rename to src/.clang-format diff --git a/src_py/__briefcase/__init__.py b/src/__briefcase/__init__.py similarity index 100% rename from src_py/__briefcase/__init__.py rename to src/__briefcase/__init__.py diff --git a/src_py/__briefcase/meson.build b/src/__briefcase/meson.build similarity index 100% rename from src_py/__briefcase/meson.build rename to src/__briefcase/meson.build diff --git a/src_py/__briefcase/pygame_ce.py b/src/__briefcase/pygame_ce.py similarity index 100% rename from src_py/__briefcase/pygame_ce.py rename to src/__briefcase/pygame_ce.py diff --git a/src_py/__pyinstaller/__init__.py b/src/__pyinstaller/__init__.py similarity index 100% rename from src_py/__pyinstaller/__init__.py rename to src/__pyinstaller/__init__.py diff --git a/src_py/__pyinstaller/hook-pygame.py b/src/__pyinstaller/hook-pygame.py similarity index 100% rename from src_py/__pyinstaller/hook-pygame.py rename to src/__pyinstaller/hook-pygame.py diff --git a/src_py/__pyinstaller/meson.build b/src/__pyinstaller/meson.build similarity index 100% rename from src_py/__pyinstaller/meson.build rename to src/__pyinstaller/meson.build diff --git a/src_py/_debug.py b/src/_debug/_debug.py similarity index 100% rename from src_py/_debug.py rename to src/_debug/_debug.py diff --git a/buildconfig/stubs/pygame/_debug.pyi b/src/_debug/_debug.pyi similarity index 100% rename from buildconfig/stubs/pygame/_debug.pyi rename to src/_debug/_debug.pyi diff --git a/test/debug_test.py b/src/_debug/debug_test.py similarity index 100% rename from test/debug_test.py rename to src/_debug/debug_test.py diff --git a/src/_debug/meson.build b/src/_debug/meson.build new file mode 100644 index 0000000000..548fc6bd45 --- /dev/null +++ b/src/_debug/meson.build @@ -0,0 +1,5 @@ +py.install_sources('_debug.py', subdir: pg) +install_data('_debug.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('debug_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/_freetype.c b/src/_freetype/freetype.c similarity index 99% rename from src_c/_freetype.c rename to src/_freetype/freetype.c index 7b032671cc..6c50c7d6c3 100644 --- a/src_c/_freetype.c +++ b/src/_freetype/freetype.c @@ -23,9 +23,9 @@ #include "freetype.h" -#include "freetype/ft_wrap.h" +#include "ft_wrap.h" -#include "doc/freetype_doc.h" +#include "freetype_doc.h" #define MODULE_NAME "_freetype" #define FONT_TYPE_NAME "Font" diff --git a/src_c/freetype.h b/src/_freetype/freetype.h similarity index 98% rename from src_c/freetype.h rename to src/_freetype/freetype.h index 7a38a6c4db..2b8c6634aa 100644 --- a/src_c/freetype.h +++ b/src/_freetype/freetype.h @@ -108,7 +108,7 @@ typedef struct { #define pgFont_IS_ALIVE(o) (((pgFontObject *)(o))->_internals != 0) /* import public API */ -#include "include/pygame_freetype.h" +#include "pygame_freetype.h" #define PYGAMEAPI_FREETYPE_NUMSLOTS 2 diff --git a/src_py/freetype.py b/src/_freetype/freetype.py similarity index 100% rename from src_py/freetype.py rename to src/_freetype/freetype.py diff --git a/buildconfig/stubs/pygame/freetype.pyi b/src/_freetype/freetype.pyi similarity index 99% rename from buildconfig/stubs/pygame/freetype.pyi rename to src/_freetype/freetype.pyi index cd36088e9a..d6db94fb00 100644 --- a/buildconfig/stubs/pygame/freetype.pyi +++ b/src/_freetype/freetype.pyi @@ -1,11 +1,12 @@ from collections.abc import Callable, Iterable from typing import Any, Optional, Union +from typing_extensions import deprecated # added in 3.13 + from pygame.color import Color from pygame.rect import Rect from pygame.surface import Surface from pygame.typing import ColorLike, FileLike, RectLike -from typing_extensions import deprecated # added in 3.13 def get_error() -> str: ... def get_version(linked: bool = True) -> tuple[int, int, int]: ... diff --git a/src_c/doc/freetype_doc.h b/src/_freetype/freetype_doc.h similarity index 100% rename from src_c/doc/freetype_doc.h rename to src/_freetype/freetype_doc.h diff --git a/test/freetype_test.py b/src/_freetype/freetype_test.py similarity index 100% rename from test/freetype_test.py rename to src/_freetype/freetype_test.py diff --git a/src_c/freetype/ft_cache.c b/src/_freetype/ft_cache.c similarity index 99% rename from src_c/freetype/ft_cache.c rename to src/_freetype/ft_cache.c index f98f28d11c..de679925f1 100644 --- a/src_c/freetype/ft_cache.c +++ b/src/_freetype/ft_cache.c @@ -19,7 +19,6 @@ */ #define PYGAME_FREETYPE_INTERNAL -#define NO_PYGAME_C_API #include "ft_wrap.h" #include FT_MODULE_H diff --git a/src_c/freetype/ft_layout.c b/src/_freetype/ft_layout.c similarity index 100% rename from src_c/freetype/ft_layout.c rename to src/_freetype/ft_layout.c diff --git a/src_c/freetype/ft_pixel.h b/src/_freetype/ft_pixel.h similarity index 99% rename from src_c/freetype/ft_pixel.h rename to src/_freetype/ft_pixel.h index 46c5b47732..d35df3bcfa 100644 --- a/src_c/freetype/ft_pixel.h +++ b/src/_freetype/ft_pixel.h @@ -20,7 +20,7 @@ #ifndef _PYGAME_FREETYPE_PIXEL_H_ #define _PYGAME_FREETYPE_PIXEL_H_ -#include "../surface.h" +#include "../surface/surface.h" #define GET_RGB_VALS(pixel, fmt, r, g, b, a) \ (r) = ((pixel) & (fmt)->Rmask) >> (fmt)->Rshift; \ diff --git a/src_c/freetype/ft_render.c b/src/_freetype/ft_render.c similarity index 100% rename from src_c/freetype/ft_render.c rename to src/_freetype/ft_render.c diff --git a/src_c/freetype/ft_render_cb.c b/src/_freetype/ft_render_cb.c similarity index 100% rename from src_c/freetype/ft_render_cb.c rename to src/_freetype/ft_render_cb.c diff --git a/src_c/freetype/ft_unicode.c b/src/_freetype/ft_unicode.c similarity index 100% rename from src_c/freetype/ft_unicode.c rename to src/_freetype/ft_unicode.c diff --git a/src_c/freetype/ft_wrap.c b/src/_freetype/ft_wrap.c similarity index 99% rename from src_c/freetype/ft_wrap.c rename to src/_freetype/ft_wrap.c index 708e9832d5..782afab2a4 100644 --- a/src_c/freetype/ft_wrap.c +++ b/src/_freetype/ft_wrap.c @@ -20,7 +20,7 @@ #define PYGAME_FREETYPE_INTERNAL -#include "../pygame.h" +#include "pygame.h" #include "ft_wrap.h" #include FT_MODULE_H diff --git a/src_c/freetype/ft_wrap.h b/src/_freetype/ft_wrap.h similarity index 99% rename from src_c/freetype/ft_wrap.h rename to src/_freetype/ft_wrap.h index 0bba50fc91..db7d726072 100644 --- a/src_c/freetype/ft_wrap.h +++ b/src/_freetype/ft_wrap.h @@ -22,8 +22,8 @@ #define _PYGAME_FREETYPE_WRAP_H_ #define PYGAME_FREETYPE_INTERNAL -#include "../_pygame.h" -#include "../freetype.h" +#include "_pygame_internal.h" +#include "freetype.h" /********************************************************** * Internal module defines diff --git a/src/_freetype/meson.build b/src/_freetype/meson.build new file mode 100644 index 0000000000..ae9ce7c336 --- /dev/null +++ b/src/_freetype/meson.build @@ -0,0 +1,26 @@ +if sdl_api != 3 + if freetype_dep.found() + _freetype = py.extension_module( + '_freetype', + [ + 'ft_cache.c', + 'ft_wrap.c', + 'ft_render.c', + 'ft_render_cb.c', + 'ft_layout.c', + 'ft_unicode.c', + 'freetype.c', + ], + include_directories: '../include', + c_args: warnings_error + warnings_temp_freetype, + dependencies: pg_base_deps + freetype_dep, + install: true, + subdir: pg, + ) + py.install_sources('freetype.py', subdir: pg) + install_data('freetype.pyi', install_dir: pg_dir, install_tag: 'pg-tag') + if not get_option('stripped') + py.install_sources('freetype_test.py', subdir: pg / 'tests') + endif + endif +endif diff --git a/src_c/include/pygame_freetype.h b/src/_freetype/pygame_freetype.h similarity index 97% rename from src_c/include/pygame_freetype.h rename to src/_freetype/pygame_freetype.h index c8113bd105..08caed1383 100644 --- a/src_c/include/pygame_freetype.h +++ b/src/_freetype/pygame_freetype.h @@ -21,7 +21,7 @@ #define PYGAME_FREETYPE_H_ #include "pgplatform.h" -#include "pgimport.h" +#include "../include/pgimport.h" #include "pgcompat.h" #ifndef PYGAME_FREETYPE_INTERNAL diff --git a/src/_render/meson.build b/src/_render/meson.build new file mode 100644 index 0000000000..8142fd037a --- /dev/null +++ b/src/_render/meson.build @@ -0,0 +1,12 @@ +# TODO: support SDL3 +if sdl_api != 3 +_render = py.extension_module( + '_render', + 'render.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +endif diff --git a/src_c/render.c b/src/_render/render.c similarity index 98% rename from src_c/render.c rename to src/_render/render.c index 9f873d615c..9e76338ee9 100644 --- a/src_c/render.c +++ b/src/_render/render.c @@ -4,7 +4,7 @@ #include "pgcompat.h" -#include "doc/sdl2_video_doc.h" +#include "../_sdl2/video/sdl2_video_doc.h" static PyTypeObject pgRenderer_Type; diff --git a/src_c/cython/pygame/_sdl2/audio.pxd b/src/_sdl2/audio/audio.pxd similarity index 94% rename from src_c/cython/pygame/_sdl2/audio.pxd rename to src/_sdl2/audio/audio.pxd index 6985775428..3bb8b3acf9 100644 --- a/src_c/cython/pygame/_sdl2/audio.pxd +++ b/src/_sdl2/audio/audio.pxd @@ -1,7 +1,7 @@ # cython: language_level=3str # -from .sdl2 cimport * +from libc.string cimport memset cdef extern from "SDL.h" nogil: # https://wiki.libsdl.org/SDL_OpenAudioDevice @@ -9,6 +9,10 @@ cdef extern from "SDL.h" nogil: # https://wiki.libsdl.org/SDL_AudioSpec # https://wiki.libsdl.org/SDL_AudioFormat + ctypedef unsigned char Uint8 + ctypedef unsigned short Uint16 + ctypedef unsigned long Uint32 + ctypedef Uint32 SDL_AudioDeviceID ctypedef Uint16 SDL_AudioFormat ctypedef void (*SDL_AudioCallback)(void *userdata, Uint8 *stream, int len) diff --git a/buildconfig/stubs/pygame/_sdl2/audio.pyi b/src/_sdl2/audio/audio.pyi similarity index 100% rename from buildconfig/stubs/pygame/_sdl2/audio.pyi rename to src/_sdl2/audio/audio.pyi diff --git a/src_c/cython/pygame/_sdl2/audio.pyx b/src/_sdl2/audio/audio.pyx similarity index 100% rename from src_c/cython/pygame/_sdl2/audio.pyx rename to src/_sdl2/audio/audio.pyx diff --git a/src/_sdl2/audio/meson.build b/src/_sdl2/audio/meson.build new file mode 100644 index 0000000000..d6ba350cb9 --- /dev/null +++ b/src/_sdl2/audio/meson.build @@ -0,0 +1,10 @@ +_sdl2_audio = py.extension_module( + 'audio', + fs.is_file('audio.c') ? 'audio.c' : 'audio.pyx', + include_directories: '../../include', + dependencies: pg_base_deps, + install: true, + subdir: pg / '_sdl2', +) + +install_data('audio.pyi', install_dir: pg_dir / '_sdl2', install_tag: 'pg-tag') diff --git a/src_c/_sdl2/controller.c b/src/_sdl2/controller/controller.c similarity index 99% rename from src_c/_sdl2/controller.c rename to src/_sdl2/controller/controller.c index 648af64a09..37c85079f8 100644 --- a/src_c/_sdl2/controller.c +++ b/src/_sdl2/controller/controller.c @@ -1,9 +1,9 @@ -#include "../pgcompat.h" -#include "../pygame.h" +#include "pgcompat.h" +#include "pygame.h" #include "structmember.h" -#include "../doc/sdl2_controller_doc.h" +#include "sdl2_controller_doc.h" #define CONTROLLER_INIT_CHECK() \ if (!SDL_WasInit(SDL_INIT_GAMECONTROLLER)) \ return RAISE(pgExc_SDLError, "Controller system not initialized"); diff --git a/buildconfig/stubs/pygame/_sdl2/controller.pyi b/src/_sdl2/controller/controller.pyi similarity index 100% rename from buildconfig/stubs/pygame/_sdl2/controller.pyi rename to src/_sdl2/controller/controller.pyi diff --git a/test/controller_test.py b/src/_sdl2/controller/controller_test.py similarity index 100% rename from test/controller_test.py rename to src/_sdl2/controller/controller_test.py diff --git a/src/_sdl2/controller/meson.build b/src/_sdl2/controller/meson.build new file mode 100644 index 0000000000..90885a29b0 --- /dev/null +++ b/src/_sdl2/controller/meson.build @@ -0,0 +1,13 @@ +_sdl2_controller = py.extension_module( + 'controller', + 'controller.c', + include_directories: '../../include', + dependencies: pg_base_deps, + install: true, + subdir: pg / '_sdl2', +) + +install_data('controller.pyi', install_dir: pg_dir / '_sdl2', install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('controller_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/doc/sdl2_controller_doc.h b/src/_sdl2/controller/sdl2_controller_doc.h similarity index 100% rename from src_c/doc/sdl2_controller_doc.h rename to src/_sdl2/controller/sdl2_controller_doc.h diff --git a/src_c/cython/pygame/_sdl2/controller_old.pxd b/src/_sdl2/controller_old/controller_old.pxd similarity index 95% rename from src_c/cython/pygame/_sdl2/controller_old.pxd rename to src/_sdl2/controller_old/controller_old.pxd index c53ddcca70..1fbce9f4c9 100644 --- a/src_c/cython/pygame/_sdl2/controller_old.pxd +++ b/src/_sdl2/controller_old/controller_old.pxd @@ -1,11 +1,16 @@ # cython: language_level=3str # -from .sdl2 cimport * - #https://wiki.libsdl.org/CategoryGameController cdef extern from "SDL.h" nogil: + ctypedef unsigned char Uint8 + ctypedef signed short Sint16 + ctypedef unsigned short Uint16 + ctypedef signed long Sint32 + ctypedef unsigned long Uint32 + ctypedef int SDL_bool + ctypedef enum SDL_GameControllerAxis: SDL_CONTROLLER_AXIS_INVALID = -1, SDL_CONTROLLER_AXIS_LEFTX, diff --git a/buildconfig/stubs/pygame/_sdl2/controller_old.pyi b/src/_sdl2/controller_old/controller_old.pyi similarity index 100% rename from buildconfig/stubs/pygame/_sdl2/controller_old.pyi rename to src/_sdl2/controller_old/controller_old.pyi diff --git a/src_c/cython/pygame/_sdl2/controller_old.pyx b/src/_sdl2/controller_old/controller_old.pyx similarity index 97% rename from src_c/cython/pygame/_sdl2/controller_old.pyx rename to src/_sdl2/controller_old/controller_old.pyx index cb7d5ad307..42663a73a2 100644 --- a/src_c/cython/pygame/_sdl2/controller_old.pyx +++ b/src/_sdl2/controller_old/controller_old.pyx @@ -1,7 +1,7 @@ from pygame._sdl2.sdl2 import error cimport cython -cdef extern from "../pygame.h" nogil: +cdef extern from "pygame.h" nogil: int pgJoystick_Check(object joy) object pgJoystick_New(int); void import_pygame_joystick() @@ -11,6 +11,11 @@ cdef extern from "../pygame.h" nogil: cdef extern from "SDL.h" nogil: void SDL_free(void *mem) int SDL_VERSION_ATLEAST(int major, int minor, int patch) + int SDL_InitSubSystem(Uint32 flags) + void SDL_QuitSubSystem(Uint32 flags) + Uint32 SDL_WasInit(Uint32 flags) + + cdef int _SDL_INIT_GAMECONTROLLER "SDL_INIT_GAMECONTROLLER" import_pygame_joystick() diff --git a/src/_sdl2/controller_old/meson.build b/src/_sdl2/controller_old/meson.build new file mode 100644 index 0000000000..5207d98746 --- /dev/null +++ b/src/_sdl2/controller_old/meson.build @@ -0,0 +1,10 @@ +_sdl2_controller_old = py.extension_module( + 'controller_old', + fs.is_file('controller_old.c') ? 'controller_old.c' : 'controller_old.pyx', + include_directories: '../../include', + dependencies: pg_base_deps, + install: true, + subdir: pg / '_sdl2', +) + +install_data('controller_old.pyi', install_dir: pg_dir / '_sdl2', install_tag: 'pg-tag') diff --git a/src/_sdl2/meson.build b/src/_sdl2/meson.build new file mode 100644 index 0000000000..7bfb4a2246 --- /dev/null +++ b/src/_sdl2/meson.build @@ -0,0 +1,19 @@ +# TODO: support SDL3 +if sdl_api != 3 +subdir('audio') + +subdir('video') + +subdir('controller_old') + +subdir('mixer') + +subdir('touch') + +subdir('controller') + +endif + +subdir('window') + +subdir('sdl2') diff --git a/src/_sdl2/mixer/meson.build b/src/_sdl2/mixer/meson.build new file mode 100644 index 0000000000..43770537e7 --- /dev/null +++ b/src/_sdl2/mixer/meson.build @@ -0,0 +1,10 @@ +if sdl_mixer_dep.found() + _sdl2_mixer = py.extension_module( + 'mixer', + fs.is_file('mixer.c') ? 'mixer.c' : 'mixer.pyx', + include_directories: '../../include', + dependencies: pg_base_deps + sdl_mixer_dep, + install: true, + subdir: pg / '_sdl2', + ) +endif diff --git a/src_c/cython/pygame/_sdl2/mixer.pxd b/src/_sdl2/mixer/mixer.pxd similarity index 88% rename from src_c/cython/pygame/_sdl2/mixer.pxd rename to src/_sdl2/mixer/mixer.pxd index 9bef08cbbb..004c42c039 100644 --- a/src_c/cython/pygame/_sdl2/mixer.pxd +++ b/src/_sdl2/mixer/mixer.pxd @@ -1,7 +1,8 @@ # cython: language_level=3str # -from .sdl2 cimport * +cdef extern from "SDL.h" nogil: + ctypedef unsigned char Uint8 #https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC79 diff --git a/src_c/cython/pygame/_sdl2/mixer.pyx b/src/_sdl2/mixer/mixer.pyx similarity index 100% rename from src_c/cython/pygame/_sdl2/mixer.pyx rename to src/_sdl2/mixer/mixer.pyx diff --git a/src_py/_sdl2/__init__.py b/src/_sdl2/sdl2/__init__.py similarity index 100% rename from src_py/_sdl2/__init__.py rename to src/_sdl2/sdl2/__init__.py diff --git a/buildconfig/stubs/pygame/_sdl2/__init__.pyi b/src/_sdl2/sdl2/__init__.pyi similarity index 100% rename from buildconfig/stubs/pygame/_sdl2/__init__.pyi rename to src/_sdl2/sdl2/__init__.pyi diff --git a/src/_sdl2/sdl2/meson.build b/src/_sdl2/sdl2/meson.build new file mode 100644 index 0000000000..cc990f1b12 --- /dev/null +++ b/src/_sdl2/sdl2/meson.build @@ -0,0 +1,14 @@ +if sdl_api != 3 + _sdl2_sdl2 = py.extension_module( + 'sdl2', + fs.is_file('sdl2.c') ? 'sdl2.c' : 'sdl2.pyx', + include_directories: '../../include', + dependencies: pg_base_deps, + install: true, + subdir: pg / '_sdl2', + ) + install_data('sdl2.pyi', install_dir: pg_dir / '_sdl2', install_tag: 'pg-tag') +endif + +py.install_sources('__init__.py', subdir: pg / '_sdl2') +install_data('__init__.pyi', install_dir: pg_dir / '_sdl2', install_tag: 'pg-tag') diff --git a/src_c/cython/pygame/_sdl2/sdl2.pxd b/src/_sdl2/sdl2/sdl2.pxd similarity index 100% rename from src_c/cython/pygame/_sdl2/sdl2.pxd rename to src/_sdl2/sdl2/sdl2.pxd diff --git a/buildconfig/stubs/pygame/_sdl2/sdl2.pyi b/src/_sdl2/sdl2/sdl2.pyi similarity index 100% rename from buildconfig/stubs/pygame/_sdl2/sdl2.pyi rename to src/_sdl2/sdl2/sdl2.pyi diff --git a/src_c/cython/pygame/_sdl2/sdl2.pyx b/src/_sdl2/sdl2/sdl2.pyx similarity index 100% rename from src_c/cython/pygame/_sdl2/sdl2.pyx rename to src/_sdl2/sdl2/sdl2.pyx diff --git a/src/_sdl2/touch/meson.build b/src/_sdl2/touch/meson.build new file mode 100644 index 0000000000..6f67f3d2cc --- /dev/null +++ b/src/_sdl2/touch/meson.build @@ -0,0 +1,13 @@ +_sdl2_touch = py.extension_module( + 'touch', + 'touch.c', + dependencies: pg_base_deps, + include_directories: '../../include', + install: true, + subdir: pg / '_sdl2', +) + +install_data('touch.pyi', install_dir: pg_dir / '_sdl2', install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('touch_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/_sdl2/touch.c b/src/_sdl2/touch/touch.c similarity index 98% rename from src_c/_sdl2/touch.c rename to src/_sdl2/touch/touch.c index 1c7bd83b57..7ee23dc2e8 100644 --- a/src_c/_sdl2/touch.c +++ b/src/_sdl2/touch/touch.c @@ -17,10 +17,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../pygame.h" -#include "../pgcompat.h" +#include "pygame.h" +#include "pgcompat.h" -#include "../doc/touch_doc.h" +#include "touch_doc.h" static PyObject * pg_touch_num_devices(PyObject *self, PyObject *_null) diff --git a/buildconfig/stubs/pygame/_sdl2/touch.pyi b/src/_sdl2/touch/touch.pyi similarity index 100% rename from buildconfig/stubs/pygame/_sdl2/touch.pyi rename to src/_sdl2/touch/touch.pyi diff --git a/src_c/doc/touch_doc.h b/src/_sdl2/touch/touch_doc.h similarity index 100% rename from src_c/doc/touch_doc.h rename to src/_sdl2/touch/touch_doc.h diff --git a/test/touch_test.py b/src/_sdl2/touch/touch_test.py similarity index 100% rename from test/touch_test.py rename to src/_sdl2/touch/touch_test.py diff --git a/src/_sdl2/video/meson.build b/src/_sdl2/video/meson.build new file mode 100644 index 0000000000..a5047e1401 --- /dev/null +++ b/src/_sdl2/video/meson.build @@ -0,0 +1,13 @@ +_sdl2_video = py.extension_module( + 'video', + fs.is_file('video.c') ? 'video.c' : 'video.pyx', + include_directories: '../../include', + dependencies: pg_base_deps, + install: true, + subdir: pg / '_sdl2', +) + +install_data('video.pyi', install_dir: pg_dir / '_sdl2', install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('video_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/doc/sdl2_video_doc.h b/src/_sdl2/video/sdl2_video_doc.h similarity index 100% rename from src_c/doc/sdl2_video_doc.h rename to src/_sdl2/video/sdl2_video_doc.h diff --git a/src_c/cython/pygame/_sdl2/video.pxd b/src/_sdl2/video/video.pxd similarity index 99% rename from src_c/cython/pygame/_sdl2/video.pxd rename to src/_sdl2/video/video.pxd index 1d87ba43b2..261613bfb9 100644 --- a/src_c/cython/pygame/_sdl2/video.pxd +++ b/src/_sdl2/video/video.pxd @@ -1,15 +1,17 @@ # cython: language_level=3str # -from .sdl2 cimport * - -cdef extern from "pgcompat_rect.h" nogil: +cdef extern from "../rect/pgcompat_rect.h" nogil: ctypedef struct SDL_FRect: float x, y float w, h cdef extern from "SDL.h" nogil: + ctypedef unsigned char Uint8 + ctypedef unsigned long Uint32 + ctypedef int SDL_bool + ctypedef struct SDL_Window ctypedef struct SDL_Texture ctypedef struct SDL_Renderer diff --git a/buildconfig/stubs/pygame/_sdl2/video.pyi b/src/_sdl2/video/video.pyi similarity index 100% rename from buildconfig/stubs/pygame/_sdl2/video.pyi rename to src/_sdl2/video/video.pyi diff --git a/src_c/cython/pygame/_sdl2/video.pyx b/src/_sdl2/video/video.pyx similarity index 100% rename from src_c/cython/pygame/_sdl2/video.pyx rename to src/_sdl2/video/video.pyx diff --git a/test/video_test.py b/src/_sdl2/video/video_test.py similarity index 100% rename from test/video_test.py rename to src/_sdl2/video/video_test.py diff --git a/src/_sdl2/window/meson.build b/src/_sdl2/window/meson.build new file mode 100644 index 0000000000..385ad88dfa --- /dev/null +++ b/src/_sdl2/window/meson.build @@ -0,0 +1 @@ +py.install_sources('window.py', subdir: pg / '_sdl2') diff --git a/src_py/_sdl2/window.py b/src/_sdl2/window/window.py similarity index 100% rename from src_py/_sdl2/window.py rename to src/_sdl2/window/window.py diff --git a/buildconfig/stubs/pygame/_sdl2/window.pyi b/src/_sdl2/window/window.pyi similarity index 100% rename from buildconfig/stubs/pygame/_sdl2/window.pyi rename to src/_sdl2/window/window.pyi diff --git a/src_c/base.c b/src/base/base.c similarity index 99% rename from src_c/base.c rename to src/base/base.c index 7363a36c68..8b7e1f96ac 100644 --- a/src_c/base.c +++ b/src/base/base.c @@ -25,7 +25,7 @@ #include "pygame.h" #include -#include "doc/pygame_doc.h" +#include "pygame_doc.h" #include "pgarrinter.h" #include "pgcompat.h" diff --git a/buildconfig/stubs/pygame/base.pyi b/src/base/base.pyi similarity index 100% rename from buildconfig/stubs/pygame/base.pyi rename to src/base/base.pyi diff --git a/test/base_test.py b/src/base/base_test.py similarity index 100% rename from test/base_test.py rename to src/base/base_test.py diff --git a/src/base/meson.build b/src/base/meson.build new file mode 100644 index 0000000000..467399b783 --- /dev/null +++ b/src/base/meson.build @@ -0,0 +1,13 @@ +base = py.extension_module( + 'base', + 'base.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('base.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('base_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/doc/pygame_doc.h b/src/base/pygame_doc.h similarity index 100% rename from src_c/doc/pygame_doc.h rename to src/base/pygame_doc.h diff --git a/src_c/bufferproxy.c b/src/bufferproxy/bufferproxy.c similarity index 99% rename from src_c/bufferproxy.c rename to src/bufferproxy/bufferproxy.c index cb81812d52..75cb95ea82 100644 --- a/src_c/bufferproxy.c +++ b/src/bufferproxy/bufferproxy.c @@ -34,7 +34,7 @@ #include "pygame.h" #include "pgcompat.h" -#include "doc/bufferproxy_doc.h" +#include "bufferproxy_doc.h" #ifdef NDEBUG #define PyBUF_PG_VIEW PyBUF_RECORDS diff --git a/buildconfig/stubs/pygame/bufferproxy.pyi b/src/bufferproxy/bufferproxy.pyi similarity index 100% rename from buildconfig/stubs/pygame/bufferproxy.pyi rename to src/bufferproxy/bufferproxy.pyi diff --git a/src_c/doc/bufferproxy_doc.h b/src/bufferproxy/bufferproxy_doc.h similarity index 100% rename from src_c/doc/bufferproxy_doc.h rename to src/bufferproxy/bufferproxy_doc.h diff --git a/test/bufferproxy_test.py b/src/bufferproxy/bufferproxy_test.py similarity index 100% rename from test/bufferproxy_test.py rename to src/bufferproxy/bufferproxy_test.py diff --git a/src/bufferproxy/meson.build b/src/bufferproxy/meson.build new file mode 100644 index 0000000000..5c08e0b59d --- /dev/null +++ b/src/bufferproxy/meson.build @@ -0,0 +1,13 @@ +bufferproxy = py.extension_module( + 'bufferproxy', + 'bufferproxy.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('bufferproxy.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('bufferproxy_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/_camera.c b/src/camera/_camera.c similarity index 100% rename from src_c/_camera.c rename to src/camera/_camera.c diff --git a/src_c/_camera.h b/src/camera/_camera.h similarity index 96% rename from src_c/_camera.h rename to src/camera/_camera.h index 6b5121a332..9a3d5f60f6 100644 --- a/src_c/_camera.h +++ b/src/camera/_camera.h @@ -20,7 +20,7 @@ #ifndef _CAMERA_H #define _CAMERA_H -#include "_pygame.h" +#include "_pygame_internal.h" #include "camera.h" #endif diff --git a/src_py/_camera_opencv.py b/src/camera/_camera_opencv.py similarity index 99% rename from src_py/_camera_opencv.py rename to src/camera/_camera_opencv.py index c08e6caf15..0dc2e99751 100644 --- a/src_py/_camera_opencv.py +++ b/src/camera/_camera_opencv.py @@ -2,6 +2,7 @@ import cv2 import numpy + import pygame diff --git a/src_c/camera.h b/src/camera/camera.h similarity index 99% rename from src_c/camera.h rename to src/camera/camera.h index cbf0ae71c3..4b5844fff3 100644 --- a/src_c/camera.h +++ b/src/camera/camera.h @@ -21,7 +21,7 @@ #include "pygame.h" #include "pgcompat.h" -#include "doc/camera_doc.h" +#include "camera_doc.h" #if defined(__unix__) #include diff --git a/src_py/camera.py b/src/camera/camera.py similarity index 100% rename from src_py/camera.py rename to src/camera/camera.py diff --git a/buildconfig/stubs/pygame/camera.pyi b/src/camera/camera.pyi similarity index 100% rename from buildconfig/stubs/pygame/camera.pyi rename to src/camera/camera.pyi diff --git a/src_c/doc/camera_doc.h b/src/camera/camera_doc.h similarity index 100% rename from src_c/doc/camera_doc.h rename to src/camera/camera_doc.h diff --git a/test/camera_test.py b/src/camera/camera_test.py similarity index 100% rename from test/camera_test.py rename to src/camera/camera_test.py diff --git a/src_c/camera_v4l2.c b/src/camera/camera_v4l2.c similarity index 100% rename from src_c/camera_v4l2.c rename to src/camera/camera_v4l2.c diff --git a/src_c/camera_windows.c b/src/camera/camera_windows.c similarity index 100% rename from src_c/camera_windows.c rename to src/camera/camera_windows.c diff --git a/src/camera/meson.build b/src/camera/meson.build new file mode 100644 index 0000000000..f3c2eb52dd --- /dev/null +++ b/src/camera/meson.build @@ -0,0 +1,41 @@ +pg_camera_sources = ['_camera.c'] +pg_camera_link = [] +if plat == 'win' + pg_camera_sources += 'camera_windows.c' + # TODO: should this link logic be improved/made meson-ey? + pg_camera_link = [] + foreach link_arg : [ + '-lMfplat', + '-lMf', + '-lMfuuid', + '-lMfreadwrite', + '-lOle32', + ] + if cc.has_link_argument(link_arg) + pg_camera_link += link_arg + endif + endforeach +elif plat == 'linux' + pg_camera_sources += 'camera_v4l2.c' +endif + +python_sources = files( + '_camera_opencv.py', + 'camera.py', +) + +_camera = py.extension_module( + '_camera', + pg_camera_sources, + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + link_args: pg_camera_link, + install: true, + subdir: pg, +) +install_data('camera.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +py.install_sources(python_sources, subdir: pg) +if not get_option('stripped') + py.install_sources('camera_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/color.c b/src/color/color.c similarity index 99% rename from src_c/color.c rename to src/color/color.c index 9f71e9a0c0..ed5b0369ec 100644 --- a/src_c/color.c +++ b/src/color/color.c @@ -39,7 +39,7 @@ #define PYGAMEAPI_COLOR_INTERNAL -#include "doc/color_doc.h" +#include "color_doc.h" #include "pygame.h" diff --git a/buildconfig/stubs/pygame/color.pyi b/src/color/color.pyi similarity index 99% rename from buildconfig/stubs/pygame/color.pyi rename to src/color/color.pyi index 1d351656c0..45b1bb99a3 100644 --- a/buildconfig/stubs/pygame/color.pyi +++ b/src/color/color.pyi @@ -1,9 +1,10 @@ from collections.abc import Collection, Iterator from typing import Any, ClassVar, SupportsIndex, Union, overload -from pygame.typing import ColorLike from typing_extensions import deprecated # added in 3.13 +from pygame.typing import ColorLike + THECOLORS: dict[str, tuple[int, int, int, int]] # Color confirms to the Collection ABC, since it also confirms to diff --git a/src_c/doc/color_doc.h b/src/color/color_doc.h similarity index 100% rename from src_c/doc/color_doc.h rename to src/color/color_doc.h diff --git a/test/color_test.py b/src/color/color_test.py similarity index 100% rename from test/color_test.py rename to src/color/color_test.py diff --git a/src_py/colordict.py b/src/color/colordict.py similarity index 100% rename from src_py/colordict.py rename to src/color/colordict.py diff --git a/src/color/meson.build b/src/color/meson.build new file mode 100644 index 0000000000..41e0b0d3f3 --- /dev/null +++ b/src/color/meson.build @@ -0,0 +1,14 @@ +color = py.extension_module( + 'color', + 'color.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +py.install_sources('colordict.py', subdir: pg) +install_data('color.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('color_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/constants.c b/src/constants/constants.c similarity index 99% rename from src_c/constants.c rename to src/constants/constants.c index 04b8e0771d..190a299f69 100644 --- a/src_c/constants.c +++ b/src/constants/constants.c @@ -24,7 +24,7 @@ #include "pgcompat.h" -#include "scrap.h" +#include "../scrap/scrap.h" /* macros used to create each constant */ #define ADD_ERROR(x) \ diff --git a/buildconfig/stubs/pygame/constants.pyi b/src/constants/constants.pyi similarity index 100% rename from buildconfig/stubs/pygame/constants.pyi rename to src/constants/constants.pyi diff --git a/test/constants_test.py b/src/constants/constants_test.py similarity index 100% rename from test/constants_test.py rename to src/constants/constants_test.py diff --git a/src/constants/meson.build b/src/constants/meson.build new file mode 100644 index 0000000000..2fd22aff50 --- /dev/null +++ b/src/constants/meson.build @@ -0,0 +1,13 @@ +constants = py.extension_module( + 'constants', + 'constants.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('constants.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('constants_test.py', subdir: pg / 'tests') +endif diff --git a/src_py/cursors.py b/src/cursors/cursors.py similarity index 100% rename from src_py/cursors.py rename to src/cursors/cursors.py diff --git a/buildconfig/stubs/pygame/cursors.pyi b/src/cursors/cursors.pyi similarity index 100% rename from buildconfig/stubs/pygame/cursors.pyi rename to src/cursors/cursors.pyi diff --git a/src_c/doc/cursors_doc.h b/src/cursors/cursors_doc.h similarity index 100% rename from src_c/doc/cursors_doc.h rename to src/cursors/cursors_doc.h diff --git a/test/cursors_test.py b/src/cursors/cursors_test.py similarity index 100% rename from test/cursors_test.py rename to src/cursors/cursors_test.py diff --git a/src/cursors/meson.build b/src/cursors/meson.build new file mode 100644 index 0000000000..22dc1fbe15 --- /dev/null +++ b/src/cursors/meson.build @@ -0,0 +1,5 @@ +py.install_sources('cursors.py', subdir: pg) +install_data('cursors.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('cursors_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/display.c b/src/display/display.c similarity index 99% rename from src_c/display.c rename to src/display/display.c index 8f72dcbcc6..a0d9239458 100644 --- a/src_c/display.c +++ b/src/display/display.c @@ -29,7 +29,7 @@ #include "pgcompat.h" #include "pgopengl.h" -#include "doc/display_doc.h" +#include "display_doc.h" #include diff --git a/buildconfig/stubs/pygame/display.pyi b/src/display/display.pyi similarity index 99% rename from buildconfig/stubs/pygame/display.pyi rename to src/display/display.pyi index b148536e50..961046cbb4 100644 --- a/buildconfig/stubs/pygame/display.pyi +++ b/src/display/display.pyi @@ -54,6 +54,8 @@ required). from collections.abc import Iterable from typing import Literal, Optional, Union, overload +from typing_extensions import deprecated # added in 3.13 + from pygame._sdl2 import Window from pygame.constants import FULLSCREEN from pygame.surface import Surface @@ -64,7 +66,6 @@ from pygame.typing import ( RectLike, SequenceLike, ) -from typing_extensions import deprecated # added in 3.13 class _VidInfo: @property diff --git a/src_c/doc/display_doc.h b/src/display/display_doc.h similarity index 100% rename from src_c/doc/display_doc.h rename to src/display/display_doc.h diff --git a/test/display_test.py b/src/display/display_test.py similarity index 100% rename from test/display_test.py rename to src/display/display_test.py diff --git a/src/display/meson.build b/src/display/meson.build new file mode 100644 index 0000000000..f9d3241a96 --- /dev/null +++ b/src/display/meson.build @@ -0,0 +1,16 @@ +# TODO: support SDL3 +if sdl_api != 3 + display = py.extension_module( + 'display', + 'display.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, + ) + install_data('display.pyi', install_dir: pg_dir, install_tag: 'pg-tag') + if not get_option('stripped') + py.install_sources('display_test.py', subdir: pg / 'tests') + endif +endif diff --git a/src/docs/README.rst b/src/docs/README.rst new file mode 100644 index 0000000000..65f21044f6 --- /dev/null +++ b/src/docs/README.rst @@ -0,0 +1 @@ +To generate docs run: `python buildconfig/make_docs.py`. diff --git a/test/docs_test.py b/src/docs/docs_test.py similarity index 100% rename from test/docs_test.py rename to src/docs/docs_test.py diff --git a/src_c/doc/examples_doc.h b/src/docs/examples_doc.h similarity index 100% rename from src_c/doc/examples_doc.h rename to src/docs/examples_doc.h diff --git a/src/docs/meson.build b/src/docs/meson.build new file mode 100644 index 0000000000..a2f2a7767f --- /dev/null +++ b/src/docs/meson.build @@ -0,0 +1,3 @@ +if not get_option('stripped') + py.install_sources('docs_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/draw.c b/src/draw/draw.c similarity index 99% rename from src_c/draw.c rename to src/draw/draw.c index c837c7a5c7..76b2f43511 100644 --- a/src_c/draw.c +++ b/src/draw/draw.c @@ -27,7 +27,7 @@ #include "pgcompat.h" -#include "doc/draw_doc.h" +#include "draw_doc.h" #include diff --git a/buildconfig/stubs/pygame/draw.pyi b/src/draw/draw.pyi similarity index 100% rename from buildconfig/stubs/pygame/draw.pyi rename to src/draw/draw.pyi diff --git a/src_c/doc/draw_doc.h b/src/draw/draw_doc.h similarity index 100% rename from src_c/doc/draw_doc.h rename to src/draw/draw_doc.h diff --git a/test/draw_test.py b/src/draw/draw_test.py similarity index 100% rename from test/draw_test.py rename to src/draw/draw_test.py diff --git a/src/draw/meson.build b/src/draw/meson.build new file mode 100644 index 0000000000..0ee8a85bd5 --- /dev/null +++ b/src/draw/meson.build @@ -0,0 +1,13 @@ +draw = py.extension_module( + 'draw', + 'draw.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('draw.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('draw_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/event.c b/src/event/event.c similarity index 99% rename from src_c/event.c rename to src/event/event.c index 79db3f51e3..cce85504ac 100644 --- a/src_c/event.c +++ b/src/event/event.c @@ -29,7 +29,7 @@ #include "pgcompat.h" -#include "doc/event_doc.h" +#include "event_doc.h" #include "structmember.h" diff --git a/buildconfig/stubs/pygame/event.pyi b/src/event/event.pyi similarity index 99% rename from buildconfig/stubs/pygame/event.pyi rename to src/event/event.pyi index 4c0674731b..ec2a3dd9a6 100644 --- a/buildconfig/stubs/pygame/event.pyi +++ b/src/event/event.pyi @@ -1,8 +1,9 @@ from typing import Any, ClassVar, Optional, Union, final -from pygame.typing import SequenceLike from typing_extensions import deprecated # added in 3.13 +from pygame.typing import SequenceLike + class _GenericEvent: # Just exists to avoid duplication of data for Event # and (deprecated) EventType diff --git a/src_c/doc/event_doc.h b/src/event/event_doc.h similarity index 100% rename from src_c/doc/event_doc.h rename to src/event/event_doc.h diff --git a/test/event_test.py b/src/event/event_test.py similarity index 100% rename from test/event_test.py rename to src/event/event_test.py diff --git a/src/event/meson.build b/src/event/meson.build new file mode 100644 index 0000000000..99613f8822 --- /dev/null +++ b/src/event/meson.build @@ -0,0 +1,13 @@ +event = py.extension_module( + 'event', + 'event.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('event.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('event_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/font.c b/src/font/font.c similarity index 99% rename from src_c/font.c rename to src/font/font.c index bbc2987365..5e85fa3ef8 100644 --- a/src_c/font.c +++ b/src/font/font.c @@ -33,7 +33,7 @@ #include "pgcompat.h" -#include "doc/font_doc.h" +#include "font_doc.h" #include "structmember.h" diff --git a/src_c/font.h b/src/font/font.h similarity index 93% rename from src_c/font.h rename to src/font/font.h index 358a66abf8..1c9f293633 100644 --- a/src_c/font.h +++ b/src/font/font.h @@ -15,7 +15,7 @@ if (!(*(int *)PyFONT_C_API[2])) \ return RAISE(pgExc_SDLError, "font system not initialized") -#include "include/pygame_font.h" +#include "pygame_font.h" #define PYGAMEAPI_FONT_NUMSLOTS 3 diff --git a/buildconfig/stubs/pygame/font.pyi b/src/font/font.pyi similarity index 99% rename from buildconfig/stubs/pygame/font.pyi rename to src/font/font.pyi index 36c1ea5ee2..bebf493111 100644 --- a/buildconfig/stubs/pygame/font.pyi +++ b/src/font/font.pyi @@ -1,9 +1,10 @@ from collections.abc import Callable, Hashable, Iterable from typing import Literal, Optional, Union +from typing_extensions import deprecated # added in 3.13 + from pygame.surface import Surface from pygame.typing import ColorLike, FileLike -from typing_extensions import deprecated # added in 3.13 # TODO: Figure out a way to type this attribute such that mypy knows it's not # always defined at runtime diff --git a/src_c/doc/font_doc.h b/src/font/font_doc.h similarity index 100% rename from src_c/doc/font_doc.h rename to src/font/font_doc.h diff --git a/test/font_test.py b/src/font/font_test.py similarity index 100% rename from test/font_test.py rename to src/font/font_test.py diff --git a/src/font/meson.build b/src/font/meson.build new file mode 100644 index 0000000000..8e9c1c8a1c --- /dev/null +++ b/src/font/meson.build @@ -0,0 +1,15 @@ +if sdl_ttf_dep.found() + font = py.extension_module( + 'font', + 'font.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps + sdl_ttf_dep, + install: true, + subdir: pg, + ) + install_data('font.pyi', install_dir: pg_dir, install_tag: 'pg-tag') + if not get_option('stripped') + py.install_sources('font_test.py', subdir: pg / 'tests') + endif +endif diff --git a/src_c/include/pygame_font.h b/src/font/pygame_font.h similarity index 100% rename from src_c/include/pygame_font.h rename to src/font/pygame_font.h diff --git a/src_py/ftfont.py b/src/ftfont/ftfont.py similarity index 100% rename from src_py/ftfont.py rename to src/ftfont/ftfont.py diff --git a/test/ftfont_test.py b/src/ftfont/ftfont_test.py similarity index 100% rename from test/ftfont_test.py rename to src/ftfont/ftfont_test.py diff --git a/src/ftfont/meson.build b/src/ftfont/meson.build new file mode 100644 index 0000000000..9e57f9114c --- /dev/null +++ b/src/ftfont/meson.build @@ -0,0 +1,9 @@ +py.install_sources('ftfont.py', subdir: pg) +if not get_option('stripped') + py.install_sources('ftfont_test.py', subdir: pg / 'tests') +endif + +# if not building font, install use ftfont for font.py +if not sdl_ttf_dep.found() and freetype_dep.found() + py.install_sources('ftfont.py', subdir: pg, rename: 'font.py') +endif diff --git a/src_c/circle.c b/src/geometry/circle.c similarity index 99% rename from src_c/circle.c rename to src/geometry/circle.c index b236da023a..611a01e2e1 100644 --- a/src_c/circle.c +++ b/src/geometry/circle.c @@ -1,4 +1,4 @@ -#include "doc/geometry_doc.h" +#include "geometry_doc.h" #include "geometry_common.h" static PyObject * diff --git a/src_c/geometry.c b/src/geometry/geometry.c similarity index 100% rename from src_c/geometry.c rename to src/geometry/geometry.c diff --git a/src_c/geometry.h b/src/geometry/geometry.h similarity index 100% rename from src_c/geometry.h rename to src/geometry/geometry.h diff --git a/buildconfig/stubs/pygame/geometry.pyi b/src/geometry/geometry.pyi similarity index 100% rename from buildconfig/stubs/pygame/geometry.pyi rename to src/geometry/geometry.pyi diff --git a/src_c/geometry_common.c b/src/geometry/geometry_common.c similarity index 100% rename from src_c/geometry_common.c rename to src/geometry/geometry_common.c diff --git a/src_c/geometry_common.h b/src/geometry/geometry_common.h similarity index 100% rename from src_c/geometry_common.h rename to src/geometry/geometry_common.h diff --git a/src_c/doc/geometry_doc.h b/src/geometry/geometry_doc.h similarity index 100% rename from src_c/doc/geometry_doc.h rename to src/geometry/geometry_doc.h diff --git a/test/geometry_test.py b/src/geometry/geometry_test.py similarity index 100% rename from test/geometry_test.py rename to src/geometry/geometry_test.py diff --git a/src_c/line.c b/src/geometry/line.c similarity index 99% rename from src_c/line.c rename to src/geometry/line.c index ad25ed4866..24c5e36016 100644 --- a/src_c/line.c +++ b/src/geometry/line.c @@ -1,4 +1,4 @@ -#include "doc/geometry_doc.h" +#include "geometry_doc.h" #include "geometry_common.h" static double diff --git a/src/geometry/meson.build b/src/geometry/meson.build new file mode 100644 index 0000000000..daa9f93096 --- /dev/null +++ b/src/geometry/meson.build @@ -0,0 +1,13 @@ +geometry = py.extension_module( + 'geometry', + 'geometry.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('geometry.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('geometry_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/SDL_gfx/SDL_gfxPrimitives.c b/src/gfxdraw/SDL_gfxPrimitives.c similarity index 100% rename from src_c/SDL_gfx/SDL_gfxPrimitives.c rename to src/gfxdraw/SDL_gfxPrimitives.c diff --git a/src_c/SDL_gfx/SDL_gfxPrimitives.h b/src/gfxdraw/SDL_gfxPrimitives.h similarity index 100% rename from src_c/SDL_gfx/SDL_gfxPrimitives.h rename to src/gfxdraw/SDL_gfxPrimitives.h diff --git a/src_c/SDL_gfx/SDL_gfxPrimitives_font.h b/src/gfxdraw/SDL_gfxPrimitives_font.h similarity index 100% rename from src_c/SDL_gfx/SDL_gfxPrimitives_font.h rename to src/gfxdraw/SDL_gfxPrimitives_font.h diff --git a/src_c/gfxdraw.c b/src/gfxdraw/gfxdraw.c similarity index 99% rename from src_c/gfxdraw.c rename to src/gfxdraw/gfxdraw.c index 09cbb050b8..399dcbf1ff 100644 --- a/src_c/gfxdraw.c +++ b/src/gfxdraw/gfxdraw.c @@ -32,13 +32,13 @@ #include "pygame.h" -#include "doc/gfxdraw_doc.h" +#include "gfxdraw_doc.h" -#include "surface.h" +#include "../surface/surface.h" #include "pgcompat.h" -#include "SDL_gfx/SDL_gfxPrimitives.h" +#include "SDL_gfxPrimitives.h" static PyObject * _gfx_pixelcolor(PyObject *self, PyObject *args); diff --git a/buildconfig/stubs/pygame/gfxdraw.pyi b/src/gfxdraw/gfxdraw.pyi similarity index 100% rename from buildconfig/stubs/pygame/gfxdraw.pyi rename to src/gfxdraw/gfxdraw.pyi diff --git a/src_c/doc/gfxdraw_doc.h b/src/gfxdraw/gfxdraw_doc.h similarity index 100% rename from src_c/doc/gfxdraw_doc.h rename to src/gfxdraw/gfxdraw_doc.h diff --git a/test/gfxdraw_test.py b/src/gfxdraw/gfxdraw_test.py similarity index 100% rename from test/gfxdraw_test.py rename to src/gfxdraw/gfxdraw_test.py diff --git a/src/gfxdraw/meson.build b/src/gfxdraw/meson.build new file mode 100644 index 0000000000..b114d8787a --- /dev/null +++ b/src/gfxdraw/meson.build @@ -0,0 +1,16 @@ +# TODO: support SDL3 +if sdl_api != 3 + gfxdraw = py.extension_module( + 'gfxdraw', + ['gfxdraw.c', 'SDL_gfxPrimitives.c'], + include_directories: '../include', + # c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, + ) + install_data('gfxdraw.pyi', install_dir: pg_dir, install_tag: 'pg-tag') + if not get_option('stripped') + py.install_sources('gfxdraw_test.py', subdir: pg / 'tests') + endif +endif diff --git a/src_c/image.c b/src/image/image.c similarity index 99% rename from src_c/image.c rename to src/image/image.c index e4f9cf70f9..ddcf35d571 100644 --- a/src_c/image.c +++ b/src/image/image.c @@ -28,7 +28,7 @@ #include "pgcompat.h" -#include "doc/image_doc.h" +#include "image_doc.h" #if PG_COMPILE_SSE4_2 #include diff --git a/buildconfig/stubs/pygame/image.pyi b/src/image/image.pyi similarity index 99% rename from buildconfig/stubs/pygame/image.pyi rename to src/image/image.pyi index 599ae07cb9..0f02ec0977 100644 --- a/buildconfig/stubs/pygame/image.pyi +++ b/src/image/image.pyi @@ -1,9 +1,10 @@ from typing import Literal, Optional, Union +from typing_extensions import deprecated # added in 3.13 + from pygame.bufferproxy import BufferProxy from pygame.surface import Surface from pygame.typing import FileLike, IntPoint, Point -from typing_extensions import deprecated # added in 3.13 _BufferLike = Union[BufferProxy, bytes, bytearray, memoryview] _from_buffer_format = Literal["P", "RGB", "BGR", "BGRA", "RGBX", "RGBA", "ARGB"] diff --git a/test/image__save_gl_surface_test.py b/src/image/image__save_gl_surface_test.py similarity index 100% rename from test/image__save_gl_surface_test.py rename to src/image/image__save_gl_surface_test.py diff --git a/src_c/doc/image_doc.h b/src/image/image_doc.h similarity index 100% rename from src_c/doc/image_doc.h rename to src/image/image_doc.h diff --git a/test/image_test.py b/src/image/image_test.py similarity index 100% rename from test/image_test.py rename to src/image/image_test.py diff --git a/src_c/imageext.c b/src/image/imageext.c similarity index 99% rename from src_c/imageext.c rename to src/image/imageext.c index 5e39e62d02..d841b2248b 100644 --- a/src_c/imageext.c +++ b/src/image/imageext.c @@ -42,7 +42,7 @@ #include "pgcompat.h" -#include "doc/image_doc.h" +#include "image_doc.h" #include "pgopengl.h" diff --git a/test/imageext_test.py b/src/image/imageext_test.py similarity index 100% rename from test/imageext_test.py rename to src/image/imageext_test.py diff --git a/src/image/meson.build b/src/image/meson.build new file mode 100644 index 0000000000..d6d8a4dd7e --- /dev/null +++ b/src/image/meson.build @@ -0,0 +1,28 @@ +image = py.extension_module( + 'image', + 'image.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) + +if sdl_image_dep.found() + imageext = py.extension_module( + 'imageext', + 'imageext.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps + sdl_image_dep, + install: true, + subdir: pg, + ) +endif + +install_data('image.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('image_test.py', subdir: pg / 'tests') + py.install_sources('imageext_test.py', subdir: pg / 'tests') + py.install_sources('image__save_gl_surface_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/include/_pygame.h b/src/include/_pygame.h similarity index 99% rename from src_c/include/_pygame.h rename to src/include/_pygame.h index 6f9942cb6c..b929dce5e4 100644 --- a/src_c/include/_pygame.h +++ b/src/include/_pygame.h @@ -100,7 +100,7 @@ typedef struct pg_bufferinfo_s { } pg_buffer; #include "pgimport.h" -#include "../pgcompat_rect.h" +#include "../rect/pgcompat_rect.h" /* * BASE module @@ -633,8 +633,6 @@ PYGAMEAPI_EXTERN_SLOTS(geometry); #endif /* ~PYGAME_H */ -#endif /* PYGAME_H */ - /* Use the end of this file for other cross module inline utility * functions There seems to be no good reason to stick to macro only * functions in Python 3. @@ -799,3 +797,5 @@ pg_PointList_FromArrayDouble(double const *array, int arr_length) __cached_exception_traceback = NULL; #endif + +#endif /* PYGAME_H */ diff --git a/src_c/_pygame.h b/src/include/_pygame_internal.h similarity index 99% rename from src_c/_pygame.h rename to src/include/_pygame_internal.h index f0518ccfe2..e524837f22 100644 --- a/src_c/_pygame.h +++ b/src/include/_pygame_internal.h @@ -33,7 +33,7 @@ */ #define PY_SSIZE_T_CLEAN #include -#include "include/pythoncapi_compat.h" +#include "pythoncapi_compat.h" /* Ensure PyPy-specific code is not in use when running on GraalPython (PR * #2580) */ @@ -606,7 +606,7 @@ typedef enum { /* * include public API */ -#include "include/_pygame.h" +#include "_pygame.h" /* Slot counts. * Remember to keep these constants up to date. diff --git a/src_c/include/bitmask.h b/src/include/bitmask.h similarity index 100% rename from src_c/include/bitmask.h rename to src/include/bitmask.h diff --git a/src_c/palette.h b/src/include/palette.h similarity index 100% rename from src_c/palette.h rename to src/include/palette.h diff --git a/src_c/pgarrinter.h b/src/include/pgarrinter.h similarity index 100% rename from src_c/pgarrinter.h rename to src/include/pgarrinter.h diff --git a/src_c/include/pgcompat.h b/src/include/pgcompat.h similarity index 75% rename from src_c/include/pgcompat.h rename to src/include/pgcompat.h index aa7a2e37e1..9ee86913a2 100644 --- a/src_c/include/pgcompat.h +++ b/src/include/pgcompat.h @@ -1,3 +1,8 @@ +/* Python 2.x/3.x compatibility tools (internal) + */ +#ifndef PGCOMPAT_INTERNAL_H +#define PGCOMPAT_INTERNAL_H + #if !defined(PGCOMPAT_H) #define PGCOMPAT_H @@ -51,3 +56,17 @@ typedef uint8_t Uint8; #endif #endif /* ~defined(PGCOMPAT_H) */ + +/* Module init function returns new module instance. */ +#define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC PyInit_##mod_name(void) + +/* Defaults for unicode file path encoding */ +#if defined(MS_WIN32) +#define UNICODE_DEF_FS_ERROR "replace" +#else +#define UNICODE_DEF_FS_ERROR "surrogateescape" +#endif + +#define RELATIVE_MODULE(m) ("." m) + +#endif /* ~PGCOMPAT_INTERNAL_H */ diff --git a/src_c/include/pgimport.h b/src/include/pgimport.h similarity index 100% rename from src_c/include/pgimport.h rename to src/include/pgimport.h diff --git a/src_c/pgopengl.h b/src/include/pgopengl.h similarity index 100% rename from src_c/pgopengl.h rename to src/include/pgopengl.h diff --git a/src_c/include/pgplatform.h b/src/include/pgplatform.h similarity index 82% rename from src_c/include/pgplatform.h rename to src/include/pgplatform.h index 4c299dac21..1041793e61 100644 --- a/src_c/include/pgplatform.h +++ b/src/include/pgplatform.h @@ -1,3 +1,7 @@ +/* platform/compiler adjustments (internal) */ +#ifndef PG_PLATFORM_INTERNAL_H +#define PG_PLATFORM_INTERNAL_H + /* platform/compiler adjustments */ #ifndef PG_PLATFORM_H #define PG_PLATFORM_H @@ -85,3 +89,21 @@ intrinsics #define PG_FUNCTION_TARGET_SSE4_2 __attribute__((target("sse4.2"))) #endif #endif /* ~PG_PLATFORM_H */ + +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif +#ifndef ABS +#define ABS(a) (((a) < 0) ? -(a) : (a)) +#endif + +/* warnings */ +#define PG_STRINGIZE_HELPER(x) #x +#define PG_STRINGIZE(x) PG_STRINGIZE_HELPER(x) +#define PG_WARN(desc) \ + message(__FILE__ "(" PG_STRINGIZE(__LINE__) "): WARNING: " #desc) + +#endif /* ~PG_PLATFORM_INTERNAL_H */ diff --git a/src_c/pygame.h b/src/include/pygame.h similarity index 97% rename from src_c/pygame.h rename to src/include/pygame.h index 8f6460b543..f4a48a1408 100644 --- a/src_c/pygame.h +++ b/src/include/pygame.h @@ -27,6 +27,6 @@ #define PYGAME_INTERNAL_H #define PYGAME_H -#include "_pygame.h" +#include "_pygame_internal.h" #endif /* ~PYGAME_INTERNAL_H */ diff --git a/src_c/include/pygame_mask.h b/src/include/pygame_mask.h similarity index 100% rename from src_c/include/pygame_mask.h rename to src/include/pygame_mask.h diff --git a/src_c/include/pythoncapi_compat.h b/src/include/pythoncapi_compat.h similarity index 100% rename from src_c/include/pythoncapi_compat.h rename to src/include/pythoncapi_compat.h diff --git a/src_c/simd_shared.h b/src/include/simd_shared.h similarity index 97% rename from src_c/simd_shared.h rename to src/include/simd_shared.h index a697fffb0c..aa0ebba789 100644 --- a/src_c/simd_shared.h +++ b/src/include/simd_shared.h @@ -2,7 +2,7 @@ #ifndef SIMD_SHARED_H #define SIMD_SHARED_H -#include "_surface.h" +#include "../surface/_surface.h" int pg_sse2_at_runtime_but_uncompiled(); diff --git a/src_c/include/sse2neon.h b/src/include/sse2neon.h similarity index 100% rename from src_c/include/sse2neon.h rename to src/include/sse2neon.h diff --git a/src_c/joystick.c b/src/joystick/joystick.c similarity index 99% rename from src_c/joystick.c rename to src/joystick/joystick.c index 42451f46ef..84895c157b 100644 --- a/src_c/joystick.c +++ b/src/joystick/joystick.c @@ -25,7 +25,7 @@ #include "pgcompat.h" -#include "doc/joystick_doc.h" +#include "joystick_doc.h" static pgJoystickObject *joylist_head = NULL; static PyTypeObject pgJoystick_Type; diff --git a/buildconfig/stubs/pygame/joystick.pyi b/src/joystick/joystick.pyi similarity index 100% rename from buildconfig/stubs/pygame/joystick.pyi rename to src/joystick/joystick.pyi diff --git a/src_c/doc/joystick_doc.h b/src/joystick/joystick_doc.h similarity index 100% rename from src_c/doc/joystick_doc.h rename to src/joystick/joystick_doc.h diff --git a/test/joystick_test.py b/src/joystick/joystick_test.py similarity index 100% rename from test/joystick_test.py rename to src/joystick/joystick_test.py diff --git a/src/joystick/meson.build b/src/joystick/meson.build new file mode 100644 index 0000000000..7604dd36aa --- /dev/null +++ b/src/joystick/meson.build @@ -0,0 +1,13 @@ +joystick = py.extension_module( + 'joystick', + 'joystick.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('joystick.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('joystick_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/key.c b/src/key/key.c similarity index 99% rename from src_c/key.c rename to src/key/key.c index 18e3b41a70..6d8caff024 100644 --- a/src_c/key.c +++ b/src/key/key.c @@ -27,7 +27,7 @@ #include "pgcompat.h" -#include "doc/key_doc.h" +#include "key_doc.h" /* keyboard module functions */ static PyObject * diff --git a/buildconfig/stubs/pygame/key.pyi b/src/key/key.pyi similarity index 100% rename from buildconfig/stubs/pygame/key.pyi rename to src/key/key.pyi diff --git a/src_c/doc/key_doc.h b/src/key/key_doc.h similarity index 100% rename from src_c/doc/key_doc.h rename to src/key/key_doc.h diff --git a/test/key_test.py b/src/key/key_test.py similarity index 100% rename from test/key_test.py rename to src/key/key_test.py diff --git a/src/key/meson.build b/src/key/meson.build new file mode 100644 index 0000000000..e28e87b84b --- /dev/null +++ b/src/key/meson.build @@ -0,0 +1,13 @@ +key = py.extension_module( + 'key', + 'key.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('key.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('key_test.py', subdir: pg / 'tests') +endif diff --git a/src_py/locals.py b/src/locals/locals.py similarity index 100% rename from src_py/locals.py rename to src/locals/locals.py diff --git a/buildconfig/stubs/pygame/locals.pyi b/src/locals/locals.pyi similarity index 100% rename from buildconfig/stubs/pygame/locals.pyi rename to src/locals/locals.pyi diff --git a/src_c/doc/locals_doc.h b/src/locals/locals_doc.h similarity index 100% rename from src_c/doc/locals_doc.h rename to src/locals/locals_doc.h diff --git a/test/locals_test.py b/src/locals/locals_test.py similarity index 100% rename from test/locals_test.py rename to src/locals/locals_test.py diff --git a/src/locals/meson.build b/src/locals/meson.build new file mode 100644 index 0000000000..e64e70a67b --- /dev/null +++ b/src/locals/meson.build @@ -0,0 +1,5 @@ +py.install_sources('locals.py', subdir: pg) +install_data('locals.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('locals_test.py', subdir: pg / 'tests') +endif diff --git a/src_py/macosx.py b/src/macosx/macosx.py similarity index 100% rename from src_py/macosx.py rename to src/macosx/macosx.py diff --git a/src/macosx/meson.build b/src/macosx/meson.build new file mode 100644 index 0000000000..4bcc649627 --- /dev/null +++ b/src/macosx/meson.build @@ -0,0 +1 @@ +py.install_sources('macosx.py', subdir: pg) diff --git a/src_c/bitmask.c b/src/mask/bitmask.c similarity index 99% rename from src_c/bitmask.c rename to src/mask/bitmask.c index 2246538fa8..f50706b43e 100644 --- a/src_c/bitmask.c +++ b/src/mask/bitmask.c @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "include/bitmask.h" +#include "bitmask.h" #include #include #include diff --git a/src_c/mask.c b/src/mask/mask.c similarity index 99% rename from src_c/mask.c rename to src/mask/mask.c index 92c2cf9acd..987270c3cd 100644 --- a/src_c/mask.c +++ b/src/mask/mask.c @@ -33,7 +33,7 @@ #include "pgcompat.h" -#include "doc/mask_doc.h" +#include "mask_doc.h" #include "structmember.h" @@ -127,7 +127,7 @@ mask_get_size(PyObject *self, PyObject *_null) * Returns: * Rect object or NULL to indicate a fail * - * Ref: src_c/surface.c surf_get_rect() + * Ref: src/surface.c surf_get_rect() */ static PyObject * mask_get_rect(PyObject *self, PyObject *args, PyObject *kwargs) @@ -747,7 +747,7 @@ get_pixel_color(Uint8 *pixel, Uint8 bpp) * bpp: bytes per pixel * color: color to set * - * Ref: src_c/draw.c set_pixel_32() + * Ref: src/draw/draw.c set_pixel_32() */ static void set_pixel_color(Uint8 *pixel, Uint8 bpp, Uint32 color) diff --git a/src_c/mask.h b/src/mask/mask.h similarity index 78% rename from src_c/mask.h rename to src/mask/mask.h index 45ad8c515e..b84cb87492 100644 --- a/src_c/mask.h +++ b/src/mask/mask.h @@ -1,7 +1,7 @@ #ifndef PGMASK_INTERNAL_H #define PGMASK_INTERNAL_H -#include "include/pygame_mask.h" +#include "pygame_mask.h" #define PYGAMEAPI_MASK_NUMSLOTS 1 #endif /* ~PGMASK_INTERNAL_H */ diff --git a/buildconfig/stubs/pygame/mask.pyi b/src/mask/mask.pyi similarity index 99% rename from buildconfig/stubs/pygame/mask.pyi rename to src/mask/mask.pyi index 3dd1b109f2..7ec0862bb9 100644 --- a/buildconfig/stubs/pygame/mask.pyi +++ b/src/mask/mask.pyi @@ -1,9 +1,10 @@ from typing import Any, Optional, Union +from typing_extensions import deprecated # added in 3.13 + from pygame.rect import Rect from pygame.surface import Surface from pygame.typing import ColorLike, Point, RectLike -from typing_extensions import deprecated # added in 3.13 def from_surface(surface: Surface, threshold: int = 127) -> Mask: ... def from_threshold( diff --git a/src_c/doc/mask_doc.h b/src/mask/mask_doc.h similarity index 100% rename from src_c/doc/mask_doc.h rename to src/mask/mask_doc.h diff --git a/test/mask_test.py b/src/mask/mask_test.py similarity index 100% rename from test/mask_test.py rename to src/mask/mask_test.py diff --git a/src/mask/meson.build b/src/mask/meson.build new file mode 100644 index 0000000000..e959b04637 --- /dev/null +++ b/src/mask/meson.build @@ -0,0 +1,13 @@ +mask = py.extension_module( + 'mask', + ['mask.c', 'bitmask.c'], + include_directories: '../include', + c_args: warnings_error + warnings_temp_mask, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('mask.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('mask_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/math.c b/src/math/math.c similarity index 99% rename from src_c/math.c rename to src/math/math.c index 036c34173c..099b551df4 100644 --- a/src_c/math.c +++ b/src/math/math.c @@ -31,7 +31,7 @@ #define PYGAMEAPI_MATH_INTERNAL #define NO_PYGAME_C_API -#include "doc/math_doc.h" +#include "math_doc.h" #include "pygame.h" diff --git a/buildconfig/stubs/pygame/math.pyi b/src/math/math.pyi similarity index 99% rename from buildconfig/stubs/pygame/math.pyi rename to src/math/math.pyi index aed0449bc8..70b156d269 100644 --- a/buildconfig/stubs/pygame/math.pyi +++ b/src/math/math.pyi @@ -12,9 +12,10 @@ from typing import ( overload, ) -from pygame.typing import SequenceLike from typing_extensions import deprecated # added in 3.13 +from pygame.typing import SequenceLike + def clamp(value: float, min: float, max: float, /) -> float: ... _TVec = TypeVar("_TVec", bound=_GenericVector) diff --git a/src_c/doc/math_doc.h b/src/math/math_doc.h similarity index 100% rename from src_c/doc/math_doc.h rename to src/math/math_doc.h diff --git a/test/math_test.py b/src/math/math_test.py similarity index 100% rename from test/math_test.py rename to src/math/math_test.py diff --git a/src/math/meson.build b/src/math/meson.build new file mode 100644 index 0000000000..bd95e569af --- /dev/null +++ b/src/math/meson.build @@ -0,0 +1,13 @@ +math = py.extension_module( + 'math', + 'math.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('math.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('math_test.py', subdir: pg / 'tests') +endif diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000000..20e7e0539a --- /dev/null +++ b/src/meson.build @@ -0,0 +1,110 @@ +# first the "required" modules + +subdir('base') + +subdir('color') + +subdir('constants') + +subdir('display') + +subdir('event') + +subdir('key') + +subdir('mouse') + +subdir('rect') + +subdir('rwobject') + +subdir('surface') + +subdir('surflock') + +subdir('time') + +subdir('joystick') + +subdir('draw') + +subdir('image') + +subdir('transform') + +subdir('mask') + +subdir('bufferproxy') + +subdir('pixelarray') + +subdir('math') + +subdir('locals') + +subdir('pixelcopy') + +subdir('surfarray') + +subdir('sndarray') + +subdir('newbuffer') + +subdir('typing') + +subdir('sprite') + +subdir('cursors') + +subdir('version') + +# new/experimental/uncommon stuff, but built by default +subdir('_debug') + +subdir('system') + +subdir('tests') + +subdir('geometry') + +subdir('window') + +subdir('_render') + +subdir('gfxdraw') + +subdir('midi') + +subdir('_sdl2') + +subdir('camera') + +subdir('scrap') + +subdir('pkgdata') + +# optional modules +subdir('font') + +subdir('sysfont') + +subdir('ftfont') + +subdir('mixer') + +subdir('_freetype') + +subdir('pypm') + +subdir('macosx') + +subdir('docs') + +subdir('resources') + +subdir('__briefcase') + +subdir('__pyinstaller') + +# init +subdir('pygame') diff --git a/src/midi/meson.build b/src/midi/meson.build new file mode 100644 index 0000000000..df855abd73 --- /dev/null +++ b/src/midi/meson.build @@ -0,0 +1,5 @@ +py.install_sources('midi.py', subdir: pg) +install_data('midi.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('midi_test.py', subdir: pg / 'tests') +endif diff --git a/src_py/midi.py b/src/midi/midi.py similarity index 100% rename from src_py/midi.py rename to src/midi/midi.py diff --git a/buildconfig/stubs/pygame/midi.pyi b/src/midi/midi.pyi similarity index 100% rename from buildconfig/stubs/pygame/midi.pyi rename to src/midi/midi.pyi diff --git a/src_c/doc/midi_doc.h b/src/midi/midi_doc.h similarity index 100% rename from src_c/doc/midi_doc.h rename to src/midi/midi_doc.h diff --git a/test/midi_test.py b/src/midi/midi_test.py similarity index 100% rename from test/midi_test.py rename to src/midi/midi_test.py diff --git a/src/mixer/meson.build b/src/mixer/meson.build new file mode 100644 index 0000000000..eaac2c7803 --- /dev/null +++ b/src/mixer/meson.build @@ -0,0 +1,32 @@ +# TODO: support SDL3 +if sdl_api != 3 + if sdl_mixer_dep.found() + mixer = py.extension_module( + 'mixer', + 'mixer.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps + sdl_mixer_dep, + install: true, + subdir: pg, + ) + install_data('mixer.pyi', install_dir: pg_dir, install_tag: 'pg-tag') + if not get_option('stripped') + py.install_sources('mixer_test.py', subdir: pg / 'tests') + endif + + mixer_music = py.extension_module( + 'mixer_music', + 'music.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps + sdl_mixer_dep, + install: true, + subdir: pg, + ) + install_data('mixer_music.pyi', install_dir: pg_dir, install_tag: 'pg-tag') + if not get_option('stripped') + py.install_sources('mixer_music_test.py', subdir: pg / 'tests') + endif + endif +endif diff --git a/src_c/mixer.c b/src/mixer/mixer.c similarity index 99% rename from src_c/mixer.c rename to src/mixer/mixer.c index 38672af019..14f4aef525 100644 --- a/src_c/mixer.c +++ b/src/mixer/mixer.c @@ -28,7 +28,7 @@ #include "pgcompat.h" -#include "doc/mixer_doc.h" +#include "mixer_doc.h" #include "mixer.h" diff --git a/src_c/mixer.h b/src/mixer/mixer.h similarity index 90% rename from src_c/mixer.h rename to src/mixer/mixer.h index 97f5a0f1d0..848af943e7 100644 --- a/src_c/mixer.h +++ b/src/mixer/mixer.h @@ -9,6 +9,6 @@ return RAISE(pgExc_SDLError, "mixer not initialized") #define PYGAMEAPI_MIXER_NUMSLOTS 5 -#include "include/pygame_mixer.h" +#include "pygame_mixer.h" #endif /* ~MIXER_INTERNAL_H */ diff --git a/buildconfig/stubs/pygame/mixer.pyi b/src/mixer/mixer.pyi similarity index 99% rename from buildconfig/stubs/pygame/mixer.pyi rename to src/mixer/mixer.pyi index 445b3c77cf..45e55ebb5b 100644 --- a/buildconfig/stubs/pygame/mixer.pyi +++ b/src/mixer/mixer.pyi @@ -1,9 +1,10 @@ from typing import Any, Optional, Union, overload import numpy +from typing_extensions import deprecated # added in 3.13 + from pygame.event import Event from pygame.typing import FileLike -from typing_extensions import deprecated # added in 3.13 from . import mixer_music diff --git a/src_c/doc/mixer_doc.h b/src/mixer/mixer_doc.h similarity index 100% rename from src_c/doc/mixer_doc.h rename to src/mixer/mixer_doc.h diff --git a/buildconfig/stubs/pygame/mixer_music.pyi b/src/mixer/mixer_music.pyi similarity index 100% rename from buildconfig/stubs/pygame/mixer_music.pyi rename to src/mixer/mixer_music.pyi diff --git a/test/mixer_music_test.py b/src/mixer/mixer_music_test.py similarity index 100% rename from test/mixer_music_test.py rename to src/mixer/mixer_music_test.py diff --git a/test/mixer_test.py b/src/mixer/mixer_test.py similarity index 100% rename from test/mixer_test.py rename to src/mixer/mixer_test.py diff --git a/src_c/music.c b/src/mixer/music.c similarity index 99% rename from src_c/music.c rename to src/mixer/music.c index 5cc41390bf..766831da41 100644 --- a/src_c/music.c +++ b/src/mixer/music.c @@ -28,7 +28,7 @@ #include "pgcompat.h" -#include "doc/music_doc.h" +#include "music_doc.h" #include "mixer.h" diff --git a/src_c/doc/music_doc.h b/src/mixer/music_doc.h similarity index 100% rename from src_c/doc/music_doc.h rename to src/mixer/music_doc.h diff --git a/src_c/include/pygame_mixer.h b/src/mixer/pygame_mixer.h similarity index 98% rename from src_c/include/pygame_mixer.h rename to src/mixer/pygame_mixer.h index feeffc9470..e261247b01 100644 --- a/src_c/include/pygame_mixer.h +++ b/src/mixer/pygame_mixer.h @@ -43,7 +43,7 @@ typedef struct { #define pgSound_AsChunk(x) (((pgSoundObject *)x)->chunk) #define pgChannel_AsInt(x) (((pgChannelObject *)x)->chan) -#include "pgimport.h" +#include "../include/pgimport.h" #ifndef PYGAMEAPI_MIXER_INTERNAL diff --git a/src/mouse/meson.build b/src/mouse/meson.build new file mode 100644 index 0000000000..e2ed983590 --- /dev/null +++ b/src/mouse/meson.build @@ -0,0 +1,13 @@ +mouse = py.extension_module( + 'mouse', + 'mouse.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('mouse.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('mouse_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/mouse.c b/src/mouse/mouse.c similarity index 99% rename from src_c/mouse.c rename to src/mouse/mouse.c index 62d1ea6b77..972408206e 100644 --- a/src_c/mouse.c +++ b/src/mouse/mouse.c @@ -27,7 +27,7 @@ #include "pgcompat.h" -#include "doc/mouse_doc.h" +#include "mouse_doc.h" /* mouse module functions */ static PyObject * diff --git a/buildconfig/stubs/pygame/mouse.pyi b/src/mouse/mouse.pyi similarity index 99% rename from buildconfig/stubs/pygame/mouse.pyi rename to src/mouse/mouse.pyi index d383b9ff01..6d902cea9c 100644 --- a/buildconfig/stubs/pygame/mouse.pyi +++ b/src/mouse/mouse.pyi @@ -1,9 +1,10 @@ from typing import Literal, overload +from typing_extensions import deprecated # added in 3.13 + from pygame.cursors import Cursor from pygame.surface import Surface from pygame.typing import IntPoint, Point, SequenceLike -from typing_extensions import deprecated # added in 3.13 @overload def get_pressed( diff --git a/src_c/doc/mouse_doc.h b/src/mouse/mouse_doc.h similarity index 100% rename from src_c/doc/mouse_doc.h rename to src/mouse/mouse_doc.h diff --git a/test/mouse_test.py b/src/mouse/mouse_test.py similarity index 100% rename from test/mouse_test.py rename to src/mouse/mouse_test.py diff --git a/src/newbuffer/meson.build b/src/newbuffer/meson.build new file mode 100644 index 0000000000..e6b71d0e05 --- /dev/null +++ b/src/newbuffer/meson.build @@ -0,0 +1,9 @@ +newbuffer = py.extension_module( + 'newbuffer', + 'newbuffer.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) diff --git a/src_c/newbuffer.c b/src/newbuffer/newbuffer.c similarity index 100% rename from src_c/newbuffer.c rename to src/newbuffer/newbuffer.c diff --git a/src/pixelarray/meson.build b/src/pixelarray/meson.build new file mode 100644 index 0000000000..27645a9d44 --- /dev/null +++ b/src/pixelarray/meson.build @@ -0,0 +1,13 @@ +pixelarray = py.extension_module( + 'pixelarray', + 'pixelarray.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('pixelarray.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('pixelarray_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/pixelarray.c b/src/pixelarray/pixelarray.c similarity index 99% rename from src_c/pixelarray.c rename to src/pixelarray/pixelarray.c index 1486031de6..f86eca08fb 100644 --- a/src_c/pixelarray.c +++ b/src/pixelarray/pixelarray.c @@ -25,9 +25,9 @@ #include "pgcompat.h" #include -#include "doc/pixelarray_doc.h" +#include "pixelarray_doc.h" -#include "surface.h" +#include "../surface/surface.h" #if !defined(BUILD_STATIC) static char FormatUint8[] = "B"; static char FormatUint16[] = "=H"; diff --git a/buildconfig/stubs/pygame/pixelarray.pyi b/src/pixelarray/pixelarray.pyi similarity index 100% rename from buildconfig/stubs/pygame/pixelarray.pyi rename to src/pixelarray/pixelarray.pyi diff --git a/src_c/doc/pixelarray_doc.h b/src/pixelarray/pixelarray_doc.h similarity index 100% rename from src_c/doc/pixelarray_doc.h rename to src/pixelarray/pixelarray_doc.h diff --git a/src_c/pixelarray_methods.c b/src/pixelarray/pixelarray_methods.c similarity index 100% rename from src_c/pixelarray_methods.c rename to src/pixelarray/pixelarray_methods.c diff --git a/test/pixelarray_test.py b/src/pixelarray/pixelarray_test.py similarity index 100% rename from test/pixelarray_test.py rename to src/pixelarray/pixelarray_test.py diff --git a/src/pixelcopy/meson.build b/src/pixelcopy/meson.build new file mode 100644 index 0000000000..e1b87a6e88 --- /dev/null +++ b/src/pixelcopy/meson.build @@ -0,0 +1,13 @@ +pixelcopy = py.extension_module( + 'pixelcopy', + 'pixelcopy.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('pixelcopy.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('pixelcopy_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/pixelcopy.c b/src/pixelcopy/pixelcopy.c similarity index 99% rename from src_c/pixelcopy.c rename to src/pixelcopy/pixelcopy.c index 75982bc8e5..350b920e43 100644 --- a/src_c/pixelcopy.c +++ b/src/pixelcopy/pixelcopy.c @@ -26,7 +26,7 @@ #include "pgcompat.h" -#include "doc/pixelcopy_doc.h" +#include "pixelcopy_doc.h" typedef enum { PXC_VIEWKIND_RED, diff --git a/buildconfig/stubs/pygame/pixelcopy.pyi b/src/pixelcopy/pixelcopy.pyi similarity index 99% rename from buildconfig/stubs/pygame/pixelcopy.pyi rename to src/pixelcopy/pixelcopy.pyi index f28a208586..4c2f59ce7e 100644 --- a/buildconfig/stubs/pygame/pixelcopy.pyi +++ b/src/pixelcopy/pixelcopy.pyi @@ -1,6 +1,7 @@ from typing import Literal import numpy + from pygame.surface import Surface _kind = Literal["P", "p", "R", "r", "G", "g", "B", "b", "A", "a", "C", "c"] diff --git a/src_c/doc/pixelcopy_doc.h b/src/pixelcopy/pixelcopy_doc.h similarity index 100% rename from src_c/doc/pixelcopy_doc.h rename to src/pixelcopy/pixelcopy_doc.h diff --git a/test/pixelcopy_test.py b/src/pixelcopy/pixelcopy_test.py similarity index 100% rename from test/pixelcopy_test.py rename to src/pixelcopy/pixelcopy_test.py diff --git a/src/pkgdata/meson.build b/src/pkgdata/meson.build new file mode 100644 index 0000000000..d770a8ba22 --- /dev/null +++ b/src/pkgdata/meson.build @@ -0,0 +1 @@ +py.install_sources('pkgdata.py', subdir: pg) diff --git a/src_py/pkgdata.py b/src/pkgdata/pkgdata.py similarity index 100% rename from src_py/pkgdata.py rename to src/pkgdata/pkgdata.py diff --git a/src_py/__init__.py b/src/pygame/__init__.py similarity index 100% rename from src_py/__init__.py rename to src/pygame/__init__.py diff --git a/src/pygame/__init__.pyi b/src/pygame/__init__.pyi new file mode 100644 index 0000000000..8611d810da --- /dev/null +++ b/src/pygame/__init__.pyi @@ -0,0 +1,656 @@ +# buildconfig/stubs/gen_stubs.py +# A script to auto-generate locals.pyi, constants.pyi and __init__.pyi typestubs +# IMPORTANT NOTE: Do not edit this file by hand! +# ruff: noqa: I001 + +from . import ( + display as display, + draw as draw, + event as event, + font as font, + image as image, + key as key, + mixer as mixer, + mouse as mouse, + time as time, + cursors as cursors, + joystick as joystick, + math as math, + mask as mask, + pixelcopy as pixelcopy, + sndarray as sndarray, + sprite as sprite, + surfarray as surfarray, + transform as transform, + scrap as scrap, + version as version, + base as base, + bufferproxy as bufferproxy, + color as color, + colordict as colordict, + mixer_music as mixer_music, + pixelarray as pixelarray, + rect as rect, + rwobject as rwobject, + surface as surface, + surflock as surflock, + sysfont as sysfont, + _debug as _debug, + system as system, + geometry as geometry, + window as window, + typing as typing, +) + +from .rect import Rect as Rect, FRect as FRect +from .surface import Surface as Surface, SurfaceType as SurfaceType +from .color import Color as Color +from .pixelarray import PixelArray as PixelArray +from .math import Vector2 as Vector2, Vector3 as Vector3 +from .cursors import Cursor as Cursor +from .bufferproxy import BufferProxy as BufferProxy +from .mask import Mask as Mask +from ._debug import print_debug_info as print_debug_info +from .event import Event as Event +from .font import Font as Font +from .mixer import Sound as Sound, Channel as Channel +from .time import Clock as Clock +from .joystick import Joystick as Joystick +from .window import Window as Window +from .base import ( + __version__ as __version__, + BufferError as BufferError, + HAVE_NEWBUF as HAVE_NEWBUF, + error as error, + get_array_interface as get_array_interface, + get_error as get_error, + get_init as get_init, + get_sdl_byteorder as get_sdl_byteorder, + get_sdl_version as get_sdl_version, + init as init, + quit as quit, + register_quit as register_quit, + set_error as set_error, +) + +from .rwobject import ( + encode_file_path as encode_file_path, + encode_string as encode_string, +) + +from .version import SDL as SDL, rev as rev, ver as ver, vernum as vernum +from .constants import ( + ACTIVEEVENT as ACTIVEEVENT, + ANYFORMAT as ANYFORMAT, + APPACTIVE as APPACTIVE, + APPINPUTFOCUS as APPINPUTFOCUS, + APPMOUSEFOCUS as APPMOUSEFOCUS, + APP_DIDENTERBACKGROUND as APP_DIDENTERBACKGROUND, + APP_DIDENTERFOREGROUND as APP_DIDENTERFOREGROUND, + APP_LOWMEMORY as APP_LOWMEMORY, + APP_TERMINATING as APP_TERMINATING, + APP_WILLENTERBACKGROUND as APP_WILLENTERBACKGROUND, + APP_WILLENTERFOREGROUND as APP_WILLENTERFOREGROUND, + ASYNCBLIT as ASYNCBLIT, + AUDIODEVICEADDED as AUDIODEVICEADDED, + AUDIODEVICEREMOVED as AUDIODEVICEREMOVED, + AUDIO_ALLOW_ANY_CHANGE as AUDIO_ALLOW_ANY_CHANGE, + AUDIO_ALLOW_CHANNELS_CHANGE as AUDIO_ALLOW_CHANNELS_CHANGE, + AUDIO_ALLOW_FORMAT_CHANGE as AUDIO_ALLOW_FORMAT_CHANGE, + AUDIO_ALLOW_FREQUENCY_CHANGE as AUDIO_ALLOW_FREQUENCY_CHANGE, + AUDIO_S16 as AUDIO_S16, + AUDIO_S16LSB as AUDIO_S16LSB, + AUDIO_S16MSB as AUDIO_S16MSB, + AUDIO_S16SYS as AUDIO_S16SYS, + AUDIO_S8 as AUDIO_S8, + AUDIO_U16 as AUDIO_U16, + AUDIO_U16LSB as AUDIO_U16LSB, + AUDIO_U16MSB as AUDIO_U16MSB, + AUDIO_U16SYS as AUDIO_U16SYS, + AUDIO_U8 as AUDIO_U8, + BIG_ENDIAN as BIG_ENDIAN, + BLENDMODE_ADD as BLENDMODE_ADD, + BLENDMODE_BLEND as BLENDMODE_BLEND, + BLENDMODE_MOD as BLENDMODE_MOD, + BLENDMODE_MUL as BLENDMODE_MUL, + BLENDMODE_NONE as BLENDMODE_NONE, + BLEND_ADD as BLEND_ADD, + BLEND_ALPHA_SDL2 as BLEND_ALPHA_SDL2, + BLEND_MAX as BLEND_MAX, + BLEND_MIN as BLEND_MIN, + BLEND_MULT as BLEND_MULT, + BLEND_PREMULTIPLIED as BLEND_PREMULTIPLIED, + BLEND_RGBA_ADD as BLEND_RGBA_ADD, + BLEND_RGBA_MAX as BLEND_RGBA_MAX, + BLEND_RGBA_MIN as BLEND_RGBA_MIN, + BLEND_RGBA_MULT as BLEND_RGBA_MULT, + BLEND_RGBA_SUB as BLEND_RGBA_SUB, + BLEND_RGB_ADD as BLEND_RGB_ADD, + BLEND_RGB_MAX as BLEND_RGB_MAX, + BLEND_RGB_MIN as BLEND_RGB_MIN, + BLEND_RGB_MULT as BLEND_RGB_MULT, + BLEND_RGB_SUB as BLEND_RGB_SUB, + BLEND_SUB as BLEND_SUB, + BUTTON_LEFT as BUTTON_LEFT, + BUTTON_MIDDLE as BUTTON_MIDDLE, + BUTTON_RIGHT as BUTTON_RIGHT, + BUTTON_WHEELDOWN as BUTTON_WHEELDOWN, + BUTTON_WHEELUP as BUTTON_WHEELUP, + BUTTON_X1 as BUTTON_X1, + BUTTON_X2 as BUTTON_X2, + CLIPBOARDUPDATE as CLIPBOARDUPDATE, + CONTROLLERAXISMOTION as CONTROLLERAXISMOTION, + CONTROLLERBUTTONDOWN as CONTROLLERBUTTONDOWN, + CONTROLLERBUTTONUP as CONTROLLERBUTTONUP, + CONTROLLERDEVICEADDED as CONTROLLERDEVICEADDED, + CONTROLLERDEVICEREMAPPED as CONTROLLERDEVICEREMAPPED, + CONTROLLERDEVICEREMOVED as CONTROLLERDEVICEREMOVED, + CONTROLLERSENSORUPDATE as CONTROLLERSENSORUPDATE, + CONTROLLERTOUCHPADDOWN as CONTROLLERTOUCHPADDOWN, + CONTROLLERTOUCHPADMOTION as CONTROLLERTOUCHPADMOTION, + CONTROLLERTOUCHPADUP as CONTROLLERTOUCHPADUP, + CONTROLLER_AXIS_INVALID as CONTROLLER_AXIS_INVALID, + CONTROLLER_AXIS_LEFTX as CONTROLLER_AXIS_LEFTX, + CONTROLLER_AXIS_LEFTY as CONTROLLER_AXIS_LEFTY, + CONTROLLER_AXIS_MAX as CONTROLLER_AXIS_MAX, + CONTROLLER_AXIS_RIGHTX as CONTROLLER_AXIS_RIGHTX, + CONTROLLER_AXIS_RIGHTY as CONTROLLER_AXIS_RIGHTY, + CONTROLLER_AXIS_TRIGGERLEFT as CONTROLLER_AXIS_TRIGGERLEFT, + CONTROLLER_AXIS_TRIGGERRIGHT as CONTROLLER_AXIS_TRIGGERRIGHT, + CONTROLLER_BUTTON_A as CONTROLLER_BUTTON_A, + CONTROLLER_BUTTON_B as CONTROLLER_BUTTON_B, + CONTROLLER_BUTTON_BACK as CONTROLLER_BUTTON_BACK, + CONTROLLER_BUTTON_DPAD_DOWN as CONTROLLER_BUTTON_DPAD_DOWN, + CONTROLLER_BUTTON_DPAD_LEFT as CONTROLLER_BUTTON_DPAD_LEFT, + CONTROLLER_BUTTON_DPAD_RIGHT as CONTROLLER_BUTTON_DPAD_RIGHT, + CONTROLLER_BUTTON_DPAD_UP as CONTROLLER_BUTTON_DPAD_UP, + CONTROLLER_BUTTON_GUIDE as CONTROLLER_BUTTON_GUIDE, + CONTROLLER_BUTTON_INVALID as CONTROLLER_BUTTON_INVALID, + CONTROLLER_BUTTON_LEFTSHOULDER as CONTROLLER_BUTTON_LEFTSHOULDER, + CONTROLLER_BUTTON_LEFTSTICK as CONTROLLER_BUTTON_LEFTSTICK, + CONTROLLER_BUTTON_MAX as CONTROLLER_BUTTON_MAX, + CONTROLLER_BUTTON_RIGHTSHOULDER as CONTROLLER_BUTTON_RIGHTSHOULDER, + CONTROLLER_BUTTON_RIGHTSTICK as CONTROLLER_BUTTON_RIGHTSTICK, + CONTROLLER_BUTTON_START as CONTROLLER_BUTTON_START, + CONTROLLER_BUTTON_X as CONTROLLER_BUTTON_X, + CONTROLLER_BUTTON_Y as CONTROLLER_BUTTON_Y, + DIRECTION_BTT as DIRECTION_BTT, + DIRECTION_LTR as DIRECTION_LTR, + DIRECTION_RTL as DIRECTION_RTL, + DIRECTION_TTB as DIRECTION_TTB, + DOUBLEBUF as DOUBLEBUF, + DROPBEGIN as DROPBEGIN, + DROPCOMPLETE as DROPCOMPLETE, + DROPFILE as DROPFILE, + DROPTEXT as DROPTEXT, + FINGERDOWN as FINGERDOWN, + FINGERMOTION as FINGERMOTION, + FINGERUP as FINGERUP, + FLASH_BRIEFLY as FLASH_BRIEFLY, + FLASH_CANCEL as FLASH_CANCEL, + FLASH_UNTIL_FOCUSED as FLASH_UNTIL_FOCUSED, + FONT_CENTER as FONT_CENTER, + FONT_LEFT as FONT_LEFT, + FONT_RIGHT as FONT_RIGHT, + FULLSCREEN as FULLSCREEN, + GL_ACCELERATED_VISUAL as GL_ACCELERATED_VISUAL, + GL_ACCUM_ALPHA_SIZE as GL_ACCUM_ALPHA_SIZE, + GL_ACCUM_BLUE_SIZE as GL_ACCUM_BLUE_SIZE, + GL_ACCUM_GREEN_SIZE as GL_ACCUM_GREEN_SIZE, + GL_ACCUM_RED_SIZE as GL_ACCUM_RED_SIZE, + GL_ALPHA_SIZE as GL_ALPHA_SIZE, + GL_BLUE_SIZE as GL_BLUE_SIZE, + GL_BUFFER_SIZE as GL_BUFFER_SIZE, + GL_CONTEXT_DEBUG_FLAG as GL_CONTEXT_DEBUG_FLAG, + GL_CONTEXT_FLAGS as GL_CONTEXT_FLAGS, + GL_CONTEXT_FORWARD_COMPATIBLE_FLAG as GL_CONTEXT_FORWARD_COMPATIBLE_FLAG, + GL_CONTEXT_MAJOR_VERSION as GL_CONTEXT_MAJOR_VERSION, + GL_CONTEXT_MINOR_VERSION as GL_CONTEXT_MINOR_VERSION, + GL_CONTEXT_PROFILE_COMPATIBILITY as GL_CONTEXT_PROFILE_COMPATIBILITY, + GL_CONTEXT_PROFILE_CORE as GL_CONTEXT_PROFILE_CORE, + GL_CONTEXT_PROFILE_ES as GL_CONTEXT_PROFILE_ES, + GL_CONTEXT_PROFILE_MASK as GL_CONTEXT_PROFILE_MASK, + GL_CONTEXT_RELEASE_BEHAVIOR as GL_CONTEXT_RELEASE_BEHAVIOR, + GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH as GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH, + GL_CONTEXT_RELEASE_BEHAVIOR_NONE as GL_CONTEXT_RELEASE_BEHAVIOR_NONE, + GL_CONTEXT_RESET_ISOLATION_FLAG as GL_CONTEXT_RESET_ISOLATION_FLAG, + GL_CONTEXT_ROBUST_ACCESS_FLAG as GL_CONTEXT_ROBUST_ACCESS_FLAG, + GL_DEPTH_SIZE as GL_DEPTH_SIZE, + GL_DOUBLEBUFFER as GL_DOUBLEBUFFER, + GL_FRAMEBUFFER_SRGB_CAPABLE as GL_FRAMEBUFFER_SRGB_CAPABLE, + GL_GREEN_SIZE as GL_GREEN_SIZE, + GL_MULTISAMPLEBUFFERS as GL_MULTISAMPLEBUFFERS, + GL_MULTISAMPLESAMPLES as GL_MULTISAMPLESAMPLES, + GL_RED_SIZE as GL_RED_SIZE, + GL_SHARE_WITH_CURRENT_CONTEXT as GL_SHARE_WITH_CURRENT_CONTEXT, + GL_STENCIL_SIZE as GL_STENCIL_SIZE, + GL_STEREO as GL_STEREO, + GL_SWAP_CONTROL as GL_SWAP_CONTROL, + HAT_CENTERED as HAT_CENTERED, + HAT_DOWN as HAT_DOWN, + HAT_LEFT as HAT_LEFT, + HAT_LEFTDOWN as HAT_LEFTDOWN, + HAT_LEFTUP as HAT_LEFTUP, + HAT_RIGHT as HAT_RIGHT, + HAT_RIGHTDOWN as HAT_RIGHTDOWN, + HAT_RIGHTUP as HAT_RIGHTUP, + HAT_UP as HAT_UP, + HIDDEN as HIDDEN, + HWACCEL as HWACCEL, + HWPALETTE as HWPALETTE, + HWSURFACE as HWSURFACE, + IS_CE as IS_CE, + JOYAXISMOTION as JOYAXISMOTION, + JOYBALLMOTION as JOYBALLMOTION, + JOYBUTTONDOWN as JOYBUTTONDOWN, + JOYBUTTONUP as JOYBUTTONUP, + JOYDEVICEADDED as JOYDEVICEADDED, + JOYDEVICEREMOVED as JOYDEVICEREMOVED, + JOYHATMOTION as JOYHATMOTION, + KEYDOWN as KEYDOWN, + KEYMAPCHANGED as KEYMAPCHANGED, + KEYUP as KEYUP, + KMOD_ALT as KMOD_ALT, + KMOD_CAPS as KMOD_CAPS, + KMOD_CTRL as KMOD_CTRL, + KMOD_GUI as KMOD_GUI, + KMOD_LALT as KMOD_LALT, + KMOD_LCTRL as KMOD_LCTRL, + KMOD_LGUI as KMOD_LGUI, + KMOD_LMETA as KMOD_LMETA, + KMOD_LSHIFT as KMOD_LSHIFT, + KMOD_META as KMOD_META, + KMOD_MODE as KMOD_MODE, + KMOD_NONE as KMOD_NONE, + KMOD_NUM as KMOD_NUM, + KMOD_RALT as KMOD_RALT, + KMOD_RCTRL as KMOD_RCTRL, + KMOD_RGUI as KMOD_RGUI, + KMOD_RMETA as KMOD_RMETA, + KMOD_RSHIFT as KMOD_RSHIFT, + KMOD_SHIFT as KMOD_SHIFT, + KSCAN_0 as KSCAN_0, + KSCAN_1 as KSCAN_1, + KSCAN_2 as KSCAN_2, + KSCAN_3 as KSCAN_3, + KSCAN_4 as KSCAN_4, + KSCAN_5 as KSCAN_5, + KSCAN_6 as KSCAN_6, + KSCAN_7 as KSCAN_7, + KSCAN_8 as KSCAN_8, + KSCAN_9 as KSCAN_9, + KSCAN_A as KSCAN_A, + KSCAN_AC_BACK as KSCAN_AC_BACK, + KSCAN_APOSTROPHE as KSCAN_APOSTROPHE, + KSCAN_B as KSCAN_B, + KSCAN_BACKSLASH as KSCAN_BACKSLASH, + KSCAN_BACKSPACE as KSCAN_BACKSPACE, + KSCAN_BREAK as KSCAN_BREAK, + KSCAN_C as KSCAN_C, + KSCAN_CAPSLOCK as KSCAN_CAPSLOCK, + KSCAN_CLEAR as KSCAN_CLEAR, + KSCAN_COMMA as KSCAN_COMMA, + KSCAN_CURRENCYSUBUNIT as KSCAN_CURRENCYSUBUNIT, + KSCAN_CURRENCYUNIT as KSCAN_CURRENCYUNIT, + KSCAN_D as KSCAN_D, + KSCAN_DELETE as KSCAN_DELETE, + KSCAN_DOWN as KSCAN_DOWN, + KSCAN_E as KSCAN_E, + KSCAN_END as KSCAN_END, + KSCAN_EQUALS as KSCAN_EQUALS, + KSCAN_ESCAPE as KSCAN_ESCAPE, + KSCAN_EURO as KSCAN_EURO, + KSCAN_F as KSCAN_F, + KSCAN_F1 as KSCAN_F1, + KSCAN_F10 as KSCAN_F10, + KSCAN_F11 as KSCAN_F11, + KSCAN_F12 as KSCAN_F12, + KSCAN_F13 as KSCAN_F13, + KSCAN_F14 as KSCAN_F14, + KSCAN_F15 as KSCAN_F15, + KSCAN_F2 as KSCAN_F2, + KSCAN_F3 as KSCAN_F3, + KSCAN_F4 as KSCAN_F4, + KSCAN_F5 as KSCAN_F5, + KSCAN_F6 as KSCAN_F6, + KSCAN_F7 as KSCAN_F7, + KSCAN_F8 as KSCAN_F8, + KSCAN_F9 as KSCAN_F9, + KSCAN_G as KSCAN_G, + KSCAN_GRAVE as KSCAN_GRAVE, + KSCAN_H as KSCAN_H, + KSCAN_HELP as KSCAN_HELP, + KSCAN_HOME as KSCAN_HOME, + KSCAN_I as KSCAN_I, + KSCAN_INSERT as KSCAN_INSERT, + KSCAN_INTERNATIONAL1 as KSCAN_INTERNATIONAL1, + KSCAN_INTERNATIONAL2 as KSCAN_INTERNATIONAL2, + KSCAN_INTERNATIONAL3 as KSCAN_INTERNATIONAL3, + KSCAN_INTERNATIONAL4 as KSCAN_INTERNATIONAL4, + KSCAN_INTERNATIONAL5 as KSCAN_INTERNATIONAL5, + KSCAN_INTERNATIONAL6 as KSCAN_INTERNATIONAL6, + KSCAN_INTERNATIONAL7 as KSCAN_INTERNATIONAL7, + KSCAN_INTERNATIONAL8 as KSCAN_INTERNATIONAL8, + KSCAN_INTERNATIONAL9 as KSCAN_INTERNATIONAL9, + KSCAN_J as KSCAN_J, + KSCAN_K as KSCAN_K, + KSCAN_KP0 as KSCAN_KP0, + KSCAN_KP1 as KSCAN_KP1, + KSCAN_KP2 as KSCAN_KP2, + KSCAN_KP3 as KSCAN_KP3, + KSCAN_KP4 as KSCAN_KP4, + KSCAN_KP5 as KSCAN_KP5, + KSCAN_KP6 as KSCAN_KP6, + KSCAN_KP7 as KSCAN_KP7, + KSCAN_KP8 as KSCAN_KP8, + KSCAN_KP9 as KSCAN_KP9, + KSCAN_KP_0 as KSCAN_KP_0, + KSCAN_KP_1 as KSCAN_KP_1, + KSCAN_KP_2 as KSCAN_KP_2, + KSCAN_KP_3 as KSCAN_KP_3, + KSCAN_KP_4 as KSCAN_KP_4, + KSCAN_KP_5 as KSCAN_KP_5, + KSCAN_KP_6 as KSCAN_KP_6, + KSCAN_KP_7 as KSCAN_KP_7, + KSCAN_KP_8 as KSCAN_KP_8, + KSCAN_KP_9 as KSCAN_KP_9, + KSCAN_KP_DIVIDE as KSCAN_KP_DIVIDE, + KSCAN_KP_ENTER as KSCAN_KP_ENTER, + KSCAN_KP_EQUALS as KSCAN_KP_EQUALS, + KSCAN_KP_MINUS as KSCAN_KP_MINUS, + KSCAN_KP_MULTIPLY as KSCAN_KP_MULTIPLY, + KSCAN_KP_PERIOD as KSCAN_KP_PERIOD, + KSCAN_KP_PLUS as KSCAN_KP_PLUS, + KSCAN_L as KSCAN_L, + KSCAN_LALT as KSCAN_LALT, + KSCAN_LANG1 as KSCAN_LANG1, + KSCAN_LANG2 as KSCAN_LANG2, + KSCAN_LANG3 as KSCAN_LANG3, + KSCAN_LANG4 as KSCAN_LANG4, + KSCAN_LANG5 as KSCAN_LANG5, + KSCAN_LANG6 as KSCAN_LANG6, + KSCAN_LANG7 as KSCAN_LANG7, + KSCAN_LANG8 as KSCAN_LANG8, + KSCAN_LANG9 as KSCAN_LANG9, + KSCAN_LCTRL as KSCAN_LCTRL, + KSCAN_LEFT as KSCAN_LEFT, + KSCAN_LEFTBRACKET as KSCAN_LEFTBRACKET, + KSCAN_LGUI as KSCAN_LGUI, + KSCAN_LMETA as KSCAN_LMETA, + KSCAN_LSHIFT as KSCAN_LSHIFT, + KSCAN_LSUPER as KSCAN_LSUPER, + KSCAN_M as KSCAN_M, + KSCAN_MENU as KSCAN_MENU, + KSCAN_MINUS as KSCAN_MINUS, + KSCAN_MODE as KSCAN_MODE, + KSCAN_N as KSCAN_N, + KSCAN_NONUSBACKSLASH as KSCAN_NONUSBACKSLASH, + KSCAN_NONUSHASH as KSCAN_NONUSHASH, + KSCAN_NUMLOCK as KSCAN_NUMLOCK, + KSCAN_NUMLOCKCLEAR as KSCAN_NUMLOCKCLEAR, + KSCAN_O as KSCAN_O, + KSCAN_P as KSCAN_P, + KSCAN_PAGEDOWN as KSCAN_PAGEDOWN, + KSCAN_PAGEUP as KSCAN_PAGEUP, + KSCAN_PAUSE as KSCAN_PAUSE, + KSCAN_PERIOD as KSCAN_PERIOD, + KSCAN_POWER as KSCAN_POWER, + KSCAN_PRINT as KSCAN_PRINT, + KSCAN_PRINTSCREEN as KSCAN_PRINTSCREEN, + KSCAN_Q as KSCAN_Q, + KSCAN_R as KSCAN_R, + KSCAN_RALT as KSCAN_RALT, + KSCAN_RCTRL as KSCAN_RCTRL, + KSCAN_RETURN as KSCAN_RETURN, + KSCAN_RGUI as KSCAN_RGUI, + KSCAN_RIGHT as KSCAN_RIGHT, + KSCAN_RIGHTBRACKET as KSCAN_RIGHTBRACKET, + KSCAN_RMETA as KSCAN_RMETA, + KSCAN_RSHIFT as KSCAN_RSHIFT, + KSCAN_RSUPER as KSCAN_RSUPER, + KSCAN_S as KSCAN_S, + KSCAN_SCROLLLOCK as KSCAN_SCROLLLOCK, + KSCAN_SCROLLOCK as KSCAN_SCROLLOCK, + KSCAN_SEMICOLON as KSCAN_SEMICOLON, + KSCAN_SLASH as KSCAN_SLASH, + KSCAN_SPACE as KSCAN_SPACE, + KSCAN_SYSREQ as KSCAN_SYSREQ, + KSCAN_T as KSCAN_T, + KSCAN_TAB as KSCAN_TAB, + KSCAN_U as KSCAN_U, + KSCAN_UNKNOWN as KSCAN_UNKNOWN, + KSCAN_UP as KSCAN_UP, + KSCAN_V as KSCAN_V, + KSCAN_W as KSCAN_W, + KSCAN_X as KSCAN_X, + KSCAN_Y as KSCAN_Y, + KSCAN_Z as KSCAN_Z, + K_0 as K_0, + K_1 as K_1, + K_2 as K_2, + K_3 as K_3, + K_4 as K_4, + K_5 as K_5, + K_6 as K_6, + K_7 as K_7, + K_8 as K_8, + K_9 as K_9, + K_AC_BACK as K_AC_BACK, + K_AMPERSAND as K_AMPERSAND, + K_ASTERISK as K_ASTERISK, + K_AT as K_AT, + K_BACKQUOTE as K_BACKQUOTE, + K_BACKSLASH as K_BACKSLASH, + K_BACKSPACE as K_BACKSPACE, + K_BREAK as K_BREAK, + K_CAPSLOCK as K_CAPSLOCK, + K_CARET as K_CARET, + K_CLEAR as K_CLEAR, + K_COLON as K_COLON, + K_COMMA as K_COMMA, + K_CURRENCYSUBUNIT as K_CURRENCYSUBUNIT, + K_CURRENCYUNIT as K_CURRENCYUNIT, + K_DELETE as K_DELETE, + K_DOLLAR as K_DOLLAR, + K_DOWN as K_DOWN, + K_END as K_END, + K_EQUALS as K_EQUALS, + K_ESCAPE as K_ESCAPE, + K_EURO as K_EURO, + K_EXCLAIM as K_EXCLAIM, + K_F1 as K_F1, + K_F10 as K_F10, + K_F11 as K_F11, + K_F12 as K_F12, + K_F13 as K_F13, + K_F14 as K_F14, + K_F15 as K_F15, + K_F2 as K_F2, + K_F3 as K_F3, + K_F4 as K_F4, + K_F5 as K_F5, + K_F6 as K_F6, + K_F7 as K_F7, + K_F8 as K_F8, + K_F9 as K_F9, + K_GREATER as K_GREATER, + K_HASH as K_HASH, + K_HELP as K_HELP, + K_HOME as K_HOME, + K_INSERT as K_INSERT, + K_KP0 as K_KP0, + K_KP1 as K_KP1, + K_KP2 as K_KP2, + K_KP3 as K_KP3, + K_KP4 as K_KP4, + K_KP5 as K_KP5, + K_KP6 as K_KP6, + K_KP7 as K_KP7, + K_KP8 as K_KP8, + K_KP9 as K_KP9, + K_KP_0 as K_KP_0, + K_KP_1 as K_KP_1, + K_KP_2 as K_KP_2, + K_KP_3 as K_KP_3, + K_KP_4 as K_KP_4, + K_KP_5 as K_KP_5, + K_KP_6 as K_KP_6, + K_KP_7 as K_KP_7, + K_KP_8 as K_KP_8, + K_KP_9 as K_KP_9, + K_KP_DIVIDE as K_KP_DIVIDE, + K_KP_ENTER as K_KP_ENTER, + K_KP_EQUALS as K_KP_EQUALS, + K_KP_MINUS as K_KP_MINUS, + K_KP_MULTIPLY as K_KP_MULTIPLY, + K_KP_PERIOD as K_KP_PERIOD, + K_KP_PLUS as K_KP_PLUS, + K_LALT as K_LALT, + K_LCTRL as K_LCTRL, + K_LEFT as K_LEFT, + K_LEFTBRACKET as K_LEFTBRACKET, + K_LEFTPAREN as K_LEFTPAREN, + K_LESS as K_LESS, + K_LGUI as K_LGUI, + K_LMETA as K_LMETA, + K_LSHIFT as K_LSHIFT, + K_LSUPER as K_LSUPER, + K_MENU as K_MENU, + K_MINUS as K_MINUS, + K_MODE as K_MODE, + K_NUMLOCK as K_NUMLOCK, + K_NUMLOCKCLEAR as K_NUMLOCKCLEAR, + K_PAGEDOWN as K_PAGEDOWN, + K_PAGEUP as K_PAGEUP, + K_PAUSE as K_PAUSE, + K_PERCENT as K_PERCENT, + K_PERIOD as K_PERIOD, + K_PLUS as K_PLUS, + K_POWER as K_POWER, + K_PRINT as K_PRINT, + K_PRINTSCREEN as K_PRINTSCREEN, + K_QUESTION as K_QUESTION, + K_QUOTE as K_QUOTE, + K_QUOTEDBL as K_QUOTEDBL, + K_RALT as K_RALT, + K_RCTRL as K_RCTRL, + K_RETURN as K_RETURN, + K_RGUI as K_RGUI, + K_RIGHT as K_RIGHT, + K_RIGHTBRACKET as K_RIGHTBRACKET, + K_RIGHTPAREN as K_RIGHTPAREN, + K_RMETA as K_RMETA, + K_RSHIFT as K_RSHIFT, + K_RSUPER as K_RSUPER, + K_SCROLLLOCK as K_SCROLLLOCK, + K_SCROLLOCK as K_SCROLLOCK, + K_SEMICOLON as K_SEMICOLON, + K_SLASH as K_SLASH, + K_SPACE as K_SPACE, + K_SYSREQ as K_SYSREQ, + K_TAB as K_TAB, + K_UNDERSCORE as K_UNDERSCORE, + K_UNKNOWN as K_UNKNOWN, + K_UP as K_UP, + K_a as K_a, + K_b as K_b, + K_c as K_c, + K_d as K_d, + K_e as K_e, + K_f as K_f, + K_g as K_g, + K_h as K_h, + K_i as K_i, + K_j as K_j, + K_k as K_k, + K_l as K_l, + K_m as K_m, + K_n as K_n, + K_o as K_o, + K_p as K_p, + K_q as K_q, + K_r as K_r, + K_s as K_s, + K_t as K_t, + K_u as K_u, + K_v as K_v, + K_w as K_w, + K_x as K_x, + K_y as K_y, + K_z as K_z, + LIL_ENDIAN as LIL_ENDIAN, + LOCALECHANGED as LOCALECHANGED, + MIDIIN as MIDIIN, + MIDIOUT as MIDIOUT, + MOUSEBUTTONDOWN as MOUSEBUTTONDOWN, + MOUSEBUTTONUP as MOUSEBUTTONUP, + MOUSEMOTION as MOUSEMOTION, + MOUSEWHEEL as MOUSEWHEEL, + MULTIGESTURE as MULTIGESTURE, + NOEVENT as NOEVENT, + NOFRAME as NOFRAME, + NULL_VIDEODRIVER as NULL_VIDEODRIVER, + NUMEVENTS as NUMEVENTS, + OPENGL as OPENGL, + OPENGLBLIT as OPENGLBLIT, + PREALLOC as PREALLOC, + QUIT as QUIT, + RENDER_DEVICE_RESET as RENDER_DEVICE_RESET, + RENDER_TARGETS_RESET as RENDER_TARGETS_RESET, + RESIZABLE as RESIZABLE, + RLEACCEL as RLEACCEL, + RLEACCELOK as RLEACCELOK, + SCALED as SCALED, + SCRAP_BMP as SCRAP_BMP, + SCRAP_CLIPBOARD as SCRAP_CLIPBOARD, + SCRAP_PBM as SCRAP_PBM, + SCRAP_PPM as SCRAP_PPM, + SCRAP_SELECTION as SCRAP_SELECTION, + SCRAP_TEXT as SCRAP_TEXT, + SCROLL_ERASE as SCROLL_ERASE, + SCROLL_REPEAT as SCROLL_REPEAT, + SHOWN as SHOWN, + SRCALPHA as SRCALPHA, + SRCCOLORKEY as SRCCOLORKEY, + SWSURFACE as SWSURFACE, + SYSTEM_CURSOR_ARROW as SYSTEM_CURSOR_ARROW, + SYSTEM_CURSOR_CROSSHAIR as SYSTEM_CURSOR_CROSSHAIR, + SYSTEM_CURSOR_HAND as SYSTEM_CURSOR_HAND, + SYSTEM_CURSOR_IBEAM as SYSTEM_CURSOR_IBEAM, + SYSTEM_CURSOR_NO as SYSTEM_CURSOR_NO, + SYSTEM_CURSOR_SIZEALL as SYSTEM_CURSOR_SIZEALL, + SYSTEM_CURSOR_SIZENESW as SYSTEM_CURSOR_SIZENESW, + SYSTEM_CURSOR_SIZENS as SYSTEM_CURSOR_SIZENS, + SYSTEM_CURSOR_SIZENWSE as SYSTEM_CURSOR_SIZENWSE, + SYSTEM_CURSOR_SIZEWE as SYSTEM_CURSOR_SIZEWE, + SYSTEM_CURSOR_WAIT as SYSTEM_CURSOR_WAIT, + SYSTEM_CURSOR_WAITARROW as SYSTEM_CURSOR_WAITARROW, + SYSWMEVENT as SYSWMEVENT, + TEXTEDITING as TEXTEDITING, + TEXTINPUT as TEXTINPUT, + TIMER_RESOLUTION as TIMER_RESOLUTION, + USEREVENT as USEREVENT, + USEREVENT_DROPFILE as USEREVENT_DROPFILE, + VIDEOEXPOSE as VIDEOEXPOSE, + VIDEORESIZE as VIDEORESIZE, + WINDOWCLOSE as WINDOWCLOSE, + WINDOWDISPLAYCHANGED as WINDOWDISPLAYCHANGED, + WINDOWENTER as WINDOWENTER, + WINDOWEXPOSED as WINDOWEXPOSED, + WINDOWFOCUSGAINED as WINDOWFOCUSGAINED, + WINDOWFOCUSLOST as WINDOWFOCUSLOST, + WINDOWHIDDEN as WINDOWHIDDEN, + WINDOWHITTEST as WINDOWHITTEST, + WINDOWICCPROFCHANGED as WINDOWICCPROFCHANGED, + WINDOWLEAVE as WINDOWLEAVE, + WINDOWMAXIMIZED as WINDOWMAXIMIZED, + WINDOWMINIMIZED as WINDOWMINIMIZED, + WINDOWMOVED as WINDOWMOVED, + WINDOWPOS_CENTERED as WINDOWPOS_CENTERED, + WINDOWPOS_UNDEFINED as WINDOWPOS_UNDEFINED, + WINDOWRESIZED as WINDOWRESIZED, + WINDOWRESTORED as WINDOWRESTORED, + WINDOWSHOWN as WINDOWSHOWN, + WINDOWSIZECHANGED as WINDOWSIZECHANGED, + WINDOWTAKEFOCUS as WINDOWTAKEFOCUS, +) diff --git a/src/pygame/meson.build b/src/pygame/meson.build new file mode 100644 index 0000000000..d33c16ae7d --- /dev/null +++ b/src/pygame/meson.build @@ -0,0 +1,2 @@ +py.install_sources('__init__.py', subdir: pg) +install_data('__init__.pyi', install_dir: pg_dir, install_tag: 'pg-tag') diff --git a/src/pypm/meson.build b/src/pypm/meson.build new file mode 100644 index 0000000000..75e2263d83 --- /dev/null +++ b/src/pypm/meson.build @@ -0,0 +1,10 @@ +if portmidi_dep.found() + pypm = py.extension_module( + 'pypm', + fs.is_file('pypm.c') ? 'pypm.c' : 'pypm.pyx', + include_directories: '../include', + dependencies: pg_base_deps + portmidi_deps, + install: true, + subdir: pg, + ) +endif diff --git a/src_c/cython/pygame/pypm.pyx b/src/pypm/pypm.pyx similarity index 100% rename from src_c/cython/pygame/pypm.pyx rename to src/pypm/pypm.pyx diff --git a/src/rect/meson.build b/src/rect/meson.build new file mode 100644 index 0000000000..6fec08077e --- /dev/null +++ b/src/rect/meson.build @@ -0,0 +1,13 @@ +rect = py.extension_module( + 'rect', + ['rect.c', 'pgcompat_rect.c'], + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('rect.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('rect_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/pgcompat_rect.c b/src/rect/pgcompat_rect.c similarity index 100% rename from src_c/pgcompat_rect.c rename to src/rect/pgcompat_rect.c diff --git a/src_c/pgcompat_rect.h b/src/rect/pgcompat_rect.h similarity index 100% rename from src_c/pgcompat_rect.h rename to src/rect/pgcompat_rect.h diff --git a/src_c/rect.c b/src/rect/rect.c similarity index 99% rename from src_c/rect.c rename to src/rect/rect.c index f3e22f69d8..a5659ba0c1 100644 --- a/src_c/rect.c +++ b/src/rect/rect.c @@ -26,7 +26,7 @@ #define PYGAMEAPI_RECT_INTERNAL #include "pygame.h" -#include "doc/rect_doc.h" +#include "rect_doc.h" #include "structmember.h" diff --git a/buildconfig/stubs/pygame/rect.pyi b/src/rect/rect.pyi similarity index 99% rename from buildconfig/stubs/pygame/rect.pyi rename to src/rect/rect.pyi index 5dc6736ec0..b4ce67b767 100644 --- a/buildconfig/stubs/pygame/rect.pyi +++ b/src/rect/rect.pyi @@ -10,9 +10,10 @@ from typing import ( overload, ) -from pygame.typing import Point, RectLike, SequenceLike from typing_extensions import deprecated # added in 3.13 +from pygame.typing import Point, RectLike, SequenceLike + if sys.version_info >= (3, 11): from typing import Self else: diff --git a/src_c/doc/rect_doc.h b/src/rect/rect_doc.h similarity index 100% rename from src_c/doc/rect_doc.h rename to src/rect/rect_doc.h diff --git a/src_c/rect_impl.h b/src/rect/rect_impl.h similarity index 100% rename from src_c/rect_impl.h rename to src/rect/rect_impl.h diff --git a/test/rect_test.py b/src/rect/rect_test.py similarity index 100% rename from test/rect_test.py rename to src/rect/rect_test.py diff --git a/src_py/freesansbold.ttf b/src/resources/freesansbold.ttf similarity index 100% rename from src_py/freesansbold.ttf rename to src/resources/freesansbold.ttf diff --git a/src/resources/meson.build b/src/resources/meson.build new file mode 100644 index 0000000000..b0c61ede7d --- /dev/null +++ b/src/resources/meson.build @@ -0,0 +1,9 @@ +data_files = files( + 'freesansbold.ttf', + 'pygame_icon.bmp', +) +if plat == 'mac' + data_files += 'pygame_icon_mac.bmp' +endif + +install_data(data_files, install_dir: pg_dir, install_tag: 'pg-tag') diff --git a/src_py/pygame.ico b/src/resources/pygame.ico similarity index 100% rename from src_py/pygame.ico rename to src/resources/pygame.ico diff --git a/src_py/pygame_icon.bmp b/src/resources/pygame_icon.bmp similarity index 100% rename from src_py/pygame_icon.bmp rename to src/resources/pygame_icon.bmp diff --git a/src_py/pygame_icon.icns b/src/resources/pygame_icon.icns similarity index 100% rename from src_py/pygame_icon.icns rename to src/resources/pygame_icon.icns diff --git a/src_py/pygame_icon_mac.bmp b/src/resources/pygame_icon_mac.bmp similarity index 100% rename from src_py/pygame_icon_mac.bmp rename to src/resources/pygame_icon_mac.bmp diff --git a/src/rwobject/meson.build b/src/rwobject/meson.build new file mode 100644 index 0000000000..ef87dd4c4d --- /dev/null +++ b/src/rwobject/meson.build @@ -0,0 +1,13 @@ +rwobject = py.extension_module( + 'rwobject', + 'rwobject.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('rwobject.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('rwobject_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/rwobject.c b/src/rwobject/rwobject.c similarity index 99% rename from src_c/rwobject.c rename to src/rwobject/rwobject.c index 61e05b9428..eb703802d1 100644 --- a/src_c/rwobject.c +++ b/src/rwobject/rwobject.c @@ -29,7 +29,7 @@ #include "pgcompat.h" -#include "doc/pygame_doc.h" +#include "../base/pygame_doc.h" typedef struct { PyObject *read; diff --git a/buildconfig/stubs/pygame/rwobject.pyi b/src/rwobject/rwobject.pyi similarity index 100% rename from buildconfig/stubs/pygame/rwobject.pyi rename to src/rwobject/rwobject.pyi diff --git a/test/rwobject_test.py b/src/rwobject/rwobject_test.py similarity index 100% rename from test/rwobject_test.py rename to src/rwobject/rwobject_test.py diff --git a/src/scrap/meson.build b/src/scrap/meson.build new file mode 100644 index 0000000000..2b81d07faf --- /dev/null +++ b/src/scrap/meson.build @@ -0,0 +1,18 @@ +pg_scrap_link = [] # TODO: should this link logic be improved/made meson-ey? +if plat == 'win' + pg_scrap_link += ['-luser32', '-lgdi32'] +endif + +scrap = py.extension_module( + 'scrap', + 'scrap.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('scrap.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('scrap_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/scrap.c b/src/scrap/scrap.c similarity index 99% rename from src_c/scrap.c rename to src/scrap/scrap.c index 43fd96b915..3de31b89e1 100644 --- a/src_c/scrap.c +++ b/src/scrap/scrap.c @@ -34,7 +34,7 @@ #include "pgcompat.h" -#include "doc/scrap_doc.h" +#include "scrap_doc.h" #include "scrap.h" diff --git a/src_c/scrap.h b/src/scrap/scrap.h similarity index 100% rename from src_c/scrap.h rename to src/scrap/scrap.h diff --git a/buildconfig/stubs/pygame/scrap.pyi b/src/scrap/scrap.pyi similarity index 100% rename from buildconfig/stubs/pygame/scrap.pyi rename to src/scrap/scrap.pyi diff --git a/src_c/doc/scrap_doc.h b/src/scrap/scrap_doc.h similarity index 100% rename from src_c/doc/scrap_doc.h rename to src/scrap/scrap_doc.h diff --git a/src_c/scrap_sdl2.c b/src/scrap/scrap_sdl2.c similarity index 100% rename from src_c/scrap_sdl2.c rename to src/scrap/scrap_sdl2.c diff --git a/test/scrap_test.py b/src/scrap/scrap_test.py similarity index 100% rename from test/scrap_test.py rename to src/scrap/scrap_test.py diff --git a/src_c/scrap_win.c b/src/scrap/scrap_win.c similarity index 100% rename from src_c/scrap_win.c rename to src/scrap/scrap_win.c diff --git a/src/sndarray/meson.build b/src/sndarray/meson.build new file mode 100644 index 0000000000..5d75a07121 --- /dev/null +++ b/src/sndarray/meson.build @@ -0,0 +1,5 @@ +py.install_sources('sndarray.py', subdir: pg) +install_data('sndarray.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('sndarray_test.py', subdir: pg / 'tests') +endif diff --git a/src_py/sndarray.py b/src/sndarray/sndarray.py similarity index 99% rename from src_py/sndarray.py rename to src/sndarray/sndarray.py index b19d00d58d..09144a1caa 100644 --- a/src_py/sndarray.py +++ b/src/sndarray/sndarray.py @@ -40,6 +40,7 @@ import warnings import numpy + from pygame import mixer __all__ = [ diff --git a/buildconfig/stubs/pygame/sndarray.pyi b/src/sndarray/sndarray.pyi similarity index 99% rename from buildconfig/stubs/pygame/sndarray.pyi rename to src/sndarray/sndarray.pyi index f87b8e5e9b..48bbca9804 100644 --- a/buildconfig/stubs/pygame/sndarray.pyi +++ b/src/sndarray/sndarray.pyi @@ -1,7 +1,8 @@ import numpy -from pygame.mixer import Sound from typing_extensions import deprecated # added in 3.13 +from pygame.mixer import Sound + def array(sound: Sound) -> numpy.ndarray: ... def samples(sound: Sound) -> numpy.ndarray: ... def make_sound(array: numpy.ndarray) -> Sound: ... diff --git a/src_c/doc/sndarray_doc.h b/src/sndarray/sndarray_doc.h similarity index 100% rename from src_c/doc/sndarray_doc.h rename to src/sndarray/sndarray_doc.h diff --git a/test/sndarray_test.py b/src/sndarray/sndarray_test.py similarity index 99% rename from test/sndarray_test.py rename to src/sndarray/sndarray_test.py index 639224fbec..17a4bce9f8 100644 --- a/test/sndarray_test.py +++ b/src/sndarray/sndarray_test.py @@ -1,8 +1,9 @@ import unittest +from numpy import all as np_all, array, float32, int8, int16, uint8, uint16 + import pygame import pygame.sndarray -from numpy import all as np_all, array, float32, int8, int16, uint8, uint16 class SndarrayTest(unittest.TestCase): diff --git a/src_py/_sprite.py b/src/sprite/_sprite.py similarity index 100% rename from src_py/_sprite.py rename to src/sprite/_sprite.py diff --git a/src/sprite/meson.build b/src/sprite/meson.build new file mode 100644 index 0000000000..af155678d6 --- /dev/null +++ b/src/sprite/meson.build @@ -0,0 +1,9 @@ +python_sources = files( + '_sprite.py', + 'sprite.py' +) +py.install_sources(python_sources, subdir: pg) +install_data('sprite.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('sprite_test.py', subdir: pg / 'tests') +endif diff --git a/src_py/sprite.py b/src/sprite/sprite.py similarity index 100% rename from src_py/sprite.py rename to src/sprite/sprite.py diff --git a/buildconfig/stubs/pygame/sprite.pyi b/src/sprite/sprite.pyi similarity index 99% rename from buildconfig/stubs/pygame/sprite.pyi rename to src/sprite/sprite.pyi index 3d27f65889..0ae433ed88 100644 --- a/buildconfig/stubs/pygame/sprite.pyi +++ b/src/sprite/sprite.pyi @@ -10,11 +10,12 @@ from typing import ( Union, ) +from typing_extensions import deprecated # added in 3.13 + from pygame.mask import Mask from pygame.rect import FRect, Rect from pygame.surface import Surface from pygame.typing import Point, RectLike -from typing_extensions import deprecated # added in 3.13 # non-generic Group, used in Sprite _Group = AbstractGroup[_SpriteSupportsGroup] diff --git a/src_c/doc/sprite_doc.h b/src/sprite/sprite_doc.h similarity index 100% rename from src_c/doc/sprite_doc.h rename to src/sprite/sprite_doc.h diff --git a/test/sprite_test.py b/src/sprite/sprite_test.py similarity index 100% rename from test/sprite_test.py rename to src/sprite/sprite_test.py diff --git a/src_c/static.c b/src/static/static.c similarity index 98% rename from src_c/static.c rename to src/static/static.c index 2a2a6fe1aa..5bc613c18e 100644 --- a/src_c/static.c +++ b/src/static/static.c @@ -346,7 +346,7 @@ PyInit_pygame_static() #undef pgSurface_Prep #undef pgSurface_Unprep -#include "surflock.c" +#include "surflock/surflock.c" #undef pgColor_New #undef pgColor_NewLength @@ -386,7 +386,7 @@ PyInit_pygame_static() #undef pgRWops_FromFileObject #undef pgRWops_FromObject -#include "rwobject.c" +#include "rwobject/rwobject.c" #define pgSurface_New(surface) (pgSurfaceObject *)pgSurface_New2((surface), 1) #include "image.c" @@ -414,7 +414,7 @@ PyInit_pygame_static() #include "system.c" #include "geometry.c" -#include "_freetype.c" +#include "freetype/freetype.c" #include "freetype/ft_wrap.c" #include "freetype/ft_render.c" #include "freetype/ft_render_cb.c" @@ -434,7 +434,7 @@ PyInit_pygame_static() #include "surface_fill.c" #include "pixelarray.c" -#include "pixelcopy.c" +#include "pixelcopy/pixelcopy.c" #include "newbuffer.c" #include "_sdl2/controller.c" diff --git a/src_c/void.c b/src/static/void.c similarity index 100% rename from src_c/void.c rename to src/static/void.c diff --git a/src_c/_blit_info.h b/src/surface/_blit_info.h similarity index 100% rename from src_c/_blit_info.h rename to src/surface/_blit_info.h diff --git a/src_c/_surface.h b/src/surface/_surface.h similarity index 95% rename from src_c/_surface.h rename to src/surface/_surface.h index bb07437d0f..fcfa7aa403 100644 --- a/src_c/_surface.h +++ b/src/surface/_surface.h @@ -24,7 +24,7 @@ #ifndef _SURFACE_H #define _SURFACE_H -#include "_pygame.h" +#include "../include/_pygame_internal.h" #include "surface.h" #endif diff --git a/src_c/alphablit.c b/src/surface/alphablit.c similarity index 100% rename from src_c/alphablit.c rename to src/surface/alphablit.c diff --git a/test/blit_test.py b/src/surface/blit_test.py similarity index 100% rename from test/blit_test.py rename to src/surface/blit_test.py diff --git a/src/surface/meson.build b/src/surface/meson.build new file mode 100644 index 0000000000..934c18e326 --- /dev/null +++ b/src/surface/meson.build @@ -0,0 +1,55 @@ +# TODO: support SDL3 +if sdl_api != 3 + simd_blitters_avx2 = static_library( + 'simd_blitters_avx2', + 'simd_blitters_avx2.c', + dependencies: pg_base_deps, + c_args: simd_avx2_flags + warnings_error, + ) + + simd_blitters_sse2 = static_library( + 'simd_blitters_sse2', + 'simd_blitters_sse2.c', + dependencies: pg_base_deps, + c_args: simd_sse2_neon_flags + warnings_error, + ) + + simd_surface_fill_avx2 = static_library( + 'simd_surface_fill_avx2', + 'simd_surface_fill_avx2.c', + dependencies: pg_base_deps, + c_args: simd_avx2_flags + warnings_error, + ) + + simd_surface_fill_sse2 = static_library( + 'simd_surface_fill_sse2', + 'simd_surface_fill_sse2.c', + dependencies: pg_base_deps, + c_args: simd_sse2_neon_flags + warnings_error, + ) + + surface = py.extension_module( + 'surface', + [ + 'surface.c', + 'alphablit.c', + 'surface_fill.c', + ], + include_directories: '../include', + c_args: warnings_error, + link_with: [ + simd_blitters_avx2, + simd_blitters_sse2, + simd_surface_fill_avx2, + simd_surface_fill_sse2, + ], + dependencies: pg_base_deps, + install: true, + subdir: pg, + ) + install_data('surface.pyi', install_dir: pg_dir, install_tag: 'pg-tag') + if not get_option('stripped') + py.install_sources('surface_test.py', subdir: pg / 'tests') + py.install_sources('blit_test.py', subdir: pg / 'tests') + endif +endif diff --git a/src_c/simd_blitters.h b/src/surface/simd_blitters.h similarity index 100% rename from src_c/simd_blitters.h rename to src/surface/simd_blitters.h diff --git a/src_c/simd_blitters_avx2.c b/src/surface/simd_blitters_avx2.c similarity index 100% rename from src_c/simd_blitters_avx2.c rename to src/surface/simd_blitters_avx2.c diff --git a/src_c/simd_blitters_sse2.c b/src/surface/simd_blitters_sse2.c similarity index 99% rename from src_c/simd_blitters_sse2.c rename to src/surface/simd_blitters_sse2.c index 65bb926721..b1c9fcf7a8 100644 --- a/src_c/simd_blitters_sse2.c +++ b/src/surface/simd_blitters_sse2.c @@ -2,7 +2,7 @@ #if PG_ENABLE_ARM_NEON // sse2neon.h is from here: https://github.com/DLTcollab/sse2neon -#include "include/sse2neon.h" +#include "../include/sse2neon.h" #endif /* PG_ENABLE_ARM_NEON */ /* See if we are compiled 64 bit on GCC or MSVC */ diff --git a/src_c/simd_fill.h b/src/surface/simd_fill.h similarity index 100% rename from src_c/simd_fill.h rename to src/surface/simd_fill.h diff --git a/src_c/simd_surface_fill_avx2.c b/src/surface/simd_surface_fill_avx2.c similarity index 100% rename from src_c/simd_surface_fill_avx2.c rename to src/surface/simd_surface_fill_avx2.c diff --git a/src_c/simd_surface_fill_sse2.c b/src/surface/simd_surface_fill_sse2.c similarity index 99% rename from src_c/simd_surface_fill_sse2.c rename to src/surface/simd_surface_fill_sse2.c index 7e4a80b030..9fcb94788c 100644 --- a/src_c/simd_surface_fill_sse2.c +++ b/src/surface/simd_surface_fill_sse2.c @@ -2,7 +2,7 @@ #if PG_ENABLE_ARM_NEON // sse2neon.h is from here: https://github.com/DLTcollab/sse2neon -#include "include/sse2neon.h" +#include "../include/sse2neon.h" #endif /* PG_ENABLE_ARM_NEON */ #define BAD_SSE2_FUNCTION_CALL \ diff --git a/src_c/surface.c b/src/surface/surface.c similarity index 99% rename from src_c/surface.c rename to src/surface/surface.c index aaecc7e93f..cb95a84cd3 100644 --- a/src_c/surface.c +++ b/src/surface/surface.c @@ -29,7 +29,7 @@ #include "structmember.h" #include "pgcompat.h" -#include "doc/surface_doc.h" +#include "surface_doc.h" /* stdint.h is missing from some versions of MSVC. */ #ifdef _MSC_VER diff --git a/src_c/surface.h b/src/surface/surface.h similarity index 99% rename from src_c/surface.h rename to src/surface/surface.h index d3cf9e322b..f7024923cc 100644 --- a/src_c/surface.h +++ b/src/surface/surface.h @@ -35,7 +35,7 @@ #include #endif -#include "pygame.h" +#include "../include/pygame.h" /* Blend modes */ #define PYGAME_BLEND_ADD 0x1 diff --git a/buildconfig/stubs/pygame/surface.pyi b/src/surface/surface.pyi similarity index 99% rename from buildconfig/stubs/pygame/surface.pyi rename to src/surface/surface.pyi index b8f00805e3..de55bc3675 100644 --- a/buildconfig/stubs/pygame/surface.pyi +++ b/src/surface/surface.pyi @@ -1,6 +1,8 @@ from collections.abc import Iterable from typing import Any, Literal, Optional, Union, overload +from typing_extensions import deprecated # added in 3.13 + from pygame.bufferproxy import BufferProxy from pygame.color import Color from pygame.rect import FRect, Rect @@ -10,7 +12,6 @@ from pygame.typing import ( RectLike, SequenceLike, ) -from typing_extensions import deprecated # added in 3.13 _ViewKind = Literal[ "0", diff --git a/src_c/doc/surface_doc.h b/src/surface/surface_doc.h similarity index 100% rename from src_c/doc/surface_doc.h rename to src/surface/surface_doc.h diff --git a/src_c/surface_fill.c b/src/surface/surface_fill.c similarity index 100% rename from src_c/surface_fill.c rename to src/surface/surface_fill.c diff --git a/test/surface_test.py b/src/surface/surface_test.py similarity index 100% rename from test/surface_test.py rename to src/surface/surface_test.py diff --git a/src/surfarray/meson.build b/src/surfarray/meson.build new file mode 100644 index 0000000000..e34eb5f929 --- /dev/null +++ b/src/surfarray/meson.build @@ -0,0 +1,5 @@ +py.install_sources('surfarray.py', subdir: pg) +install_data('surfarray.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('surfarray_test.py', subdir: pg / 'tests') +endif diff --git a/src_py/surfarray.py b/src/surfarray/surfarray.py similarity index 99% rename from src_py/surfarray.py rename to src/surfarray/surfarray.py index df78d3c316..f7942716dd 100644 --- a/src_py/surfarray.py +++ b/src/surfarray/surfarray.py @@ -46,6 +46,7 @@ ndarray as numpy_ndarray, uint32 as numpy_uint32, ) + from pygame.pixelcopy import ( array_to_surface, make_surface as pix_make_surface, diff --git a/buildconfig/stubs/pygame/surfarray.pyi b/src/surfarray/surfarray.pyi similarity index 100% rename from buildconfig/stubs/pygame/surfarray.pyi rename to src/surfarray/surfarray.pyi index fe11163af2..53c57d17c9 100644 --- a/buildconfig/stubs/pygame/surfarray.pyi +++ b/src/surfarray/surfarray.pyi @@ -1,4 +1,5 @@ import numpy +from typing_extensions import deprecated # added in 3.13 # importing this way exports the functions in the typestubs from pygame.pixelcopy import ( @@ -6,7 +7,6 @@ from pygame.pixelcopy import ( surface_to_array as surface_to_array, ) from pygame.surface import Surface -from typing_extensions import deprecated # added in 3.13 def array2d(surface: Surface) -> numpy.ndarray: ... def pixels2d(surface: Surface) -> numpy.ndarray: ... diff --git a/src_c/doc/surfarray_doc.h b/src/surfarray/surfarray_doc.h similarity index 100% rename from src_c/doc/surfarray_doc.h rename to src/surfarray/surfarray_doc.h diff --git a/test/surfarray_test.py b/src/surfarray/surfarray_test.py similarity index 99% rename from test/surfarray_test.py rename to src/surfarray/surfarray_test.py index f51a411179..aa0765de37 100644 --- a/test/surfarray_test.py +++ b/src/surfarray/surfarray_test.py @@ -1,8 +1,6 @@ import platform import unittest -import pygame -import pygame.surfarray from numpy import ( __version__ as np_version, all as np_all, @@ -16,6 +14,9 @@ uint64, zeros, ) + +import pygame +import pygame.surfarray from pygame.locals import * IS_PYPY = "PyPy" == platform.python_implementation() diff --git a/src/surflock/meson.build b/src/surflock/meson.build new file mode 100644 index 0000000000..5e0bcf3a54 --- /dev/null +++ b/src/surflock/meson.build @@ -0,0 +1,13 @@ +surflock = py.extension_module( + 'surflock', + 'surflock.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('surflock.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('surflock_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/surflock.c b/src/surflock/surflock.c similarity index 100% rename from src_c/surflock.c rename to src/surflock/surflock.c diff --git a/buildconfig/stubs/pygame/surflock.pyi b/src/surflock/surflock.pyi similarity index 100% rename from buildconfig/stubs/pygame/surflock.pyi rename to src/surflock/surflock.pyi diff --git a/test/surflock_test.py b/src/surflock/surflock_test.py similarity index 100% rename from test/surflock_test.py rename to src/surflock/surflock_test.py diff --git a/src/sysfont/meson.build b/src/sysfont/meson.build new file mode 100644 index 0000000000..32dd18a285 --- /dev/null +++ b/src/sysfont/meson.build @@ -0,0 +1,4 @@ +py.install_sources('sysfont.py', subdir: pg) +if not get_option('stripped') + py.install_sources('sysfont_test.py', subdir: pg / 'tests') +endif diff --git a/src_py/sysfont.py b/src/sysfont/sysfont.py similarity index 100% rename from src_py/sysfont.py rename to src/sysfont/sysfont.py diff --git a/test/sysfont_test.py b/src/sysfont/sysfont_test.py similarity index 100% rename from test/sysfont_test.py rename to src/sysfont/sysfont_test.py diff --git a/src_py/_data_classes.py b/src/system/_data_classes.py similarity index 100% rename from src_py/_data_classes.py rename to src/system/_data_classes.py diff --git a/src/system/meson.build b/src/system/meson.build new file mode 100644 index 0000000000..59b6d48a7b --- /dev/null +++ b/src/system/meson.build @@ -0,0 +1,14 @@ +system = py.extension_module( + 'system', + 'system.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +py.install_sources('_data_classes.py', subdir: pg) +install_data('system.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('system_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/system.c b/src/system/system.c similarity index 99% rename from src_c/system.c rename to src/system/system.c index 2c9e2b4e5f..349b7355b9 100644 --- a/src_c/system.c +++ b/src/system/system.c @@ -2,7 +2,7 @@ #include "pgcompat.h" -#include "doc/system_doc.h" +#include "system_doc.h" static PyObject * pg_system_get_cpu_instruction_sets(PyObject *self, PyObject *_null) diff --git a/buildconfig/stubs/pygame/system.pyi b/src/system/system.pyi similarity index 100% rename from buildconfig/stubs/pygame/system.pyi rename to src/system/system.pyi diff --git a/src_c/doc/system_doc.h b/src/system/system_doc.h similarity index 100% rename from src_c/doc/system_doc.h rename to src/system/system_doc.h diff --git a/test/system_test.py b/src/system/system_test.py similarity index 100% rename from test/system_test.py rename to src/system/system_test.py diff --git a/test/README.rst b/src/tests/README.rst similarity index 100% rename from test/README.rst rename to src/tests/README.rst diff --git a/test/__init__.py b/src/tests/__init__.py similarity index 100% rename from test/__init__.py rename to src/tests/__init__.py diff --git a/test/__main__.py b/src/tests/__main__.py similarity index 100% rename from test/__main__.py rename to src/tests/__main__.py diff --git a/test/fixtures/fonts/A_PyGameMono-8.png b/src/tests/fixtures/fonts/A_PyGameMono-8.png similarity index 100% rename from test/fixtures/fonts/A_PyGameMono-8.png rename to src/tests/fixtures/fonts/A_PyGameMono-8.png diff --git a/test/fixtures/fonts/PlayfairDisplaySemibold.ttf b/src/tests/fixtures/fonts/PlayfairDisplaySemibold.ttf similarity index 100% rename from test/fixtures/fonts/PlayfairDisplaySemibold.ttf rename to src/tests/fixtures/fonts/PlayfairDisplaySemibold.ttf diff --git a/test/fixtures/fonts/PyGameMono-18-100dpi.bdf b/src/tests/fixtures/fonts/PyGameMono-18-100dpi.bdf similarity index 100% rename from test/fixtures/fonts/PyGameMono-18-100dpi.bdf rename to src/tests/fixtures/fonts/PyGameMono-18-100dpi.bdf diff --git a/test/fixtures/fonts/PyGameMono-18-75dpi.bdf b/src/tests/fixtures/fonts/PyGameMono-18-75dpi.bdf similarity index 100% rename from test/fixtures/fonts/PyGameMono-18-75dpi.bdf rename to src/tests/fixtures/fonts/PyGameMono-18-75dpi.bdf diff --git a/test/fixtures/fonts/PyGameMono-8.bdf b/src/tests/fixtures/fonts/PyGameMono-8.bdf similarity index 100% rename from test/fixtures/fonts/PyGameMono-8.bdf rename to src/tests/fixtures/fonts/PyGameMono-8.bdf diff --git a/test/fixtures/fonts/PyGameMono.otf b/src/tests/fixtures/fonts/PyGameMono.otf similarity index 100% rename from test/fixtures/fonts/PyGameMono.otf rename to src/tests/fixtures/fonts/PyGameMono.otf diff --git a/test/fixtures/fonts/PyGameMono.sfd b/src/tests/fixtures/fonts/PyGameMono.sfd similarity index 100% rename from test/fixtures/fonts/PyGameMono.sfd rename to src/tests/fixtures/fonts/PyGameMono.sfd diff --git a/test/fixtures/fonts/test_fixed.otf b/src/tests/fixtures/fonts/test_fixed.otf similarity index 100% rename from test/fixtures/fonts/test_fixed.otf rename to src/tests/fixtures/fonts/test_fixed.otf diff --git a/test/fixtures/fonts/test_sans.ttf b/src/tests/fixtures/fonts/test_sans.ttf similarity index 100% rename from test/fixtures/fonts/test_sans.ttf rename to src/tests/fixtures/fonts/test_sans.ttf diff --git a/test/fixtures/fonts/u13079_PyGameMono-8.png b/src/tests/fixtures/fonts/u13079_PyGameMono-8.png similarity index 100% rename from test/fixtures/fonts/u13079_PyGameMono-8.png rename to src/tests/fixtures/fonts/u13079_PyGameMono-8.png diff --git a/test/fixtures/xbm_cursors/white_sizing.xbm b/src/tests/fixtures/xbm_cursors/white_sizing.xbm similarity index 100% rename from test/fixtures/xbm_cursors/white_sizing.xbm rename to src/tests/fixtures/xbm_cursors/white_sizing.xbm diff --git a/test/fixtures/xbm_cursors/white_sizing_mask.xbm b/src/tests/fixtures/xbm_cursors/white_sizing_mask.xbm similarity index 100% rename from test/fixtures/xbm_cursors/white_sizing_mask.xbm rename to src/tests/fixtures/xbm_cursors/white_sizing_mask.xbm diff --git a/src/tests/meson.build b/src/tests/meson.build new file mode 100644 index 0000000000..bdbe055af4 --- /dev/null +++ b/src/tests/meson.build @@ -0,0 +1,11 @@ +if not get_option('stripped') + test_files = files( + '__init__.py', + '__main__.py', + ) + + py.install_sources(test_files, subdir: pg / 'tests') + + install_subdir('fixtures', install_dir: pg_dir / 'tests', install_tag: 'pg-tag') + subdir('test_utils') +endif diff --git a/test/test_utils/__init__.py b/src/tests/test_utils/__init__.py similarity index 100% rename from test/test_utils/__init__.py rename to src/tests/test_utils/__init__.py diff --git a/test/test_utils/arrinter.py b/src/tests/test_utils/arrinter.py similarity index 100% rename from test/test_utils/arrinter.py rename to src/tests/test_utils/arrinter.py diff --git a/test/test_utils/async_sub.py b/src/tests/test_utils/async_sub.py similarity index 100% rename from test/test_utils/async_sub.py rename to src/tests/test_utils/async_sub.py diff --git a/test/test_utils/buftools.py b/src/tests/test_utils/buftools.py similarity index 100% rename from test/test_utils/buftools.py rename to src/tests/test_utils/buftools.py diff --git a/test/test_utils/meson.build b/src/tests/test_utils/meson.build similarity index 100% rename from test/test_utils/meson.build rename to src/tests/test_utils/meson.build diff --git a/test/test_utils/png.py b/src/tests/test_utils/png.py similarity index 100% rename from test/test_utils/png.py rename to src/tests/test_utils/png.py diff --git a/test/test_utils/run_tests.py b/src/tests/test_utils/run_tests.py similarity index 100% rename from test/test_utils/run_tests.py rename to src/tests/test_utils/run_tests.py diff --git a/test/test_utils/test_machinery.py b/src/tests/test_utils/test_machinery.py similarity index 100% rename from test/test_utils/test_machinery.py rename to src/tests/test_utils/test_machinery.py diff --git a/test/test_utils/test_runner.py b/src/tests/test_utils/test_runner.py similarity index 100% rename from test/test_utils/test_runner.py rename to src/tests/test_utils/test_runner.py diff --git a/src_c/doc/tests_doc.h b/src/tests/tests_doc.h similarity index 100% rename from src_c/doc/tests_doc.h rename to src/tests/tests_doc.h diff --git a/src/time/meson.build b/src/time/meson.build new file mode 100644 index 0000000000..424305efd8 --- /dev/null +++ b/src/time/meson.build @@ -0,0 +1,13 @@ +time = py.extension_module( + 'time', + 'time.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('time.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('time_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/time.c b/src/time/time.c similarity index 99% rename from src_c/time.c rename to src/time/time.c index b89e43e9de..42b896634c 100644 --- a/src_c/time.c +++ b/src/time/time.c @@ -24,7 +24,7 @@ #include "pgcompat.h" -#include "doc/time_doc.h" +#include "time_doc.h" #define WORST_CLOCK_ACCURACY 12 diff --git a/buildconfig/stubs/pygame/time.pyi b/src/time/time.pyi similarity index 100% rename from buildconfig/stubs/pygame/time.pyi rename to src/time/time.pyi diff --git a/src_c/doc/time_doc.h b/src/time/time_doc.h similarity index 100% rename from src_c/doc/time_doc.h rename to src/time/time_doc.h diff --git a/test/time_test.py b/src/time/time_test.py similarity index 100% rename from test/time_test.py rename to src/time/time_test.py diff --git a/src/transform/meson.build b/src/transform/meson.build new file mode 100644 index 0000000000..025b5851c9 --- /dev/null +++ b/src/transform/meson.build @@ -0,0 +1,45 @@ +simd_transform_avx2 = static_library( + 'simd_transform_avx2', + 'simd_transform_avx2.c', + dependencies: pg_base_deps, + c_args: simd_avx2_flags + warnings_error, +) + +simd_transform_sse2 = static_library( + 'simd_transform_sse2', + 'simd_transform_sse2.c', + dependencies: pg_base_deps, + c_args: simd_sse2_neon_flags + warnings_error, +) + +transform_sources = ['transform.c', 'rotozoom.c', 'scale2x.c'] +transform_objs = [] + +if ( + cc.get_argument_syntax() == 'msvc' + and host_machine.cpu_family().startswith('x86') +) + if host_machine.cpu_family() == 'x86' + transform_objs += '../../buildconfig/obj/win32/scale_mmx.obj' + else + transform_objs += '../../buildconfig/obj/win64/scale_mmx.obj' + endif +else + transform_sources += 'scale_mmx.c' +endif + +transform = py.extension_module( + 'transform', + transform_sources, + include_directories: '../include', + c_args: warnings_error, + link_with: [simd_transform_avx2, simd_transform_sse2], + objects: transform_objs, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('transform.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('transform_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/rotozoom.c b/src/transform/rotozoom.c similarity index 99% rename from src_c/rotozoom.c rename to src/transform/rotozoom.c index b888a84963..a4452a4f24 100644 --- a/src_c/rotozoom.c +++ b/src/transform/rotozoom.c @@ -11,9 +11,7 @@ */ -#include "_pygame.h" -#define NO_PYGAME_C_API -#include "pygame.h" +#include "_pygame_internal.h" #include "math.h" diff --git a/src_c/scale.h b/src/transform/scale.h similarity index 100% rename from src_c/scale.h rename to src/transform/scale.h diff --git a/src_c/scale2x.c b/src/transform/scale2x.c similarity index 100% rename from src_c/scale2x.c rename to src/transform/scale2x.c diff --git a/src_c/scale_mmx.c b/src/transform/scale_mmx.c similarity index 100% rename from src_c/scale_mmx.c rename to src/transform/scale_mmx.c diff --git a/src_c/scale_mmx32.c b/src/transform/scale_mmx32.c similarity index 100% rename from src_c/scale_mmx32.c rename to src/transform/scale_mmx32.c diff --git a/src_c/scale_mmx64.c b/src/transform/scale_mmx64.c similarity index 100% rename from src_c/scale_mmx64.c rename to src/transform/scale_mmx64.c diff --git a/src_c/scale_mmx64_gcc.c b/src/transform/scale_mmx64_gcc.c similarity index 100% rename from src_c/scale_mmx64_gcc.c rename to src/transform/scale_mmx64_gcc.c diff --git a/src_c/scale_mmx64_msvc.c b/src/transform/scale_mmx64_msvc.c similarity index 100% rename from src_c/scale_mmx64_msvc.c rename to src/transform/scale_mmx64_msvc.c diff --git a/src_c/simd_transform.h b/src/transform/simd_transform.h similarity index 98% rename from src_c/simd_transform.h rename to src/transform/simd_transform.h index 30f0379568..7ca998e89b 100644 --- a/src_c/simd_transform.h +++ b/src/transform/simd_transform.h @@ -1,5 +1,5 @@ #define NO_PYGAME_C_API -#include "_surface.h" +#include "../surface/_surface.h" /* TODO: This compat code should probably go in some place like simd_shared.h * That header file however is inconsistently used at the moment and not diff --git a/src_c/simd_transform_avx2.c b/src/transform/simd_transform_avx2.c similarity index 100% rename from src_c/simd_transform_avx2.c rename to src/transform/simd_transform_avx2.c diff --git a/src_c/simd_transform_sse2.c b/src/transform/simd_transform_sse2.c similarity index 99% rename from src_c/simd_transform_sse2.c rename to src/transform/simd_transform_sse2.c index 5aebb26d1b..677d52a3a7 100644 --- a/src_c/simd_transform_sse2.c +++ b/src/transform/simd_transform_sse2.c @@ -2,7 +2,7 @@ #if PG_ENABLE_ARM_NEON // sse2neon.h is from here: https://github.com/DLTcollab/sse2neon -#include "include/sse2neon.h" +#include "../include/sse2neon.h" #endif /* PG_ENABLE_ARM_NEON */ /* This returns 1 when sse2 is available at runtime but support for it isn't diff --git a/src_c/transform.c b/src/transform/transform.c similarity index 99% rename from src_c/transform.c rename to src/transform/transform.c index 30a9e73022..b2c13fe1e3 100644 --- a/src_c/transform.c +++ b/src/transform/transform.c @@ -28,7 +28,7 @@ #include "pgcompat.h" -#include "doc/transform_doc.h" +#include "transform_doc.h" #include #include diff --git a/buildconfig/stubs/pygame/transform.pyi b/src/transform/transform.pyi similarity index 100% rename from buildconfig/stubs/pygame/transform.pyi rename to src/transform/transform.pyi diff --git a/src_c/doc/transform_doc.h b/src/transform/transform_doc.h similarity index 100% rename from src_c/doc/transform_doc.h rename to src/transform/transform_doc.h diff --git a/test/transform_test.py b/src/transform/transform_test.py similarity index 100% rename from test/transform_test.py rename to src/transform/transform_test.py diff --git a/src/typing/meson.build b/src/typing/meson.build new file mode 100644 index 0000000000..a591a5632b --- /dev/null +++ b/src/typing/meson.build @@ -0,0 +1,5 @@ +py.install_sources('typing.py', subdir: pg) +install_data('typing.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('typing_test.py', subdir: pg / 'tests') +endif diff --git a/src_py/typing.py b/src/typing/typing.py similarity index 100% rename from src_py/typing.py rename to src/typing/typing.py diff --git a/buildconfig/stubs/pygame/typing.pyi b/src/typing/typing.pyi similarity index 100% rename from buildconfig/stubs/pygame/typing.pyi rename to src/typing/typing.pyi diff --git a/src_c/doc/typing_doc.h b/src/typing/typing_doc.h similarity index 100% rename from src_c/doc/typing_doc.h rename to src/typing/typing_doc.h diff --git a/test/typing_test.py b/src/typing/typing_test.py similarity index 100% rename from test/typing_test.py rename to src/typing/typing_test.py diff --git a/src/version/meson.build b/src/version/meson.build new file mode 100644 index 0000000000..69fa7288a5 --- /dev/null +++ b/src/version/meson.build @@ -0,0 +1,5 @@ +py.install_sources('version.py', subdir: pg) +install_data('version.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('version_test.py', subdir: pg / 'tests') +endif diff --git a/src_py/version.py b/src/version/version.py similarity index 100% rename from src_py/version.py rename to src/version/version.py diff --git a/buildconfig/stubs/pygame/version.pyi b/src/version/version.pyi similarity index 100% rename from buildconfig/stubs/pygame/version.pyi rename to src/version/version.pyi diff --git a/test/version_test.py b/src/version/version_test.py similarity index 94% rename from test/version_test.py rename to src/version/version_test.py index d03f68d0dd..c8f880c87c 100644 --- a/test/version_test.py +++ b/src/version/version_test.py @@ -4,7 +4,7 @@ import pygame -pg_header = os.path.join("src_c", "include", "_pygame.h") +pg_header = os.path.join("src", "include", "_pygame.h") class VersionTest(unittest.TestCase): diff --git a/src/window/meson.build b/src/window/meson.build new file mode 100644 index 0000000000..e082ef795b --- /dev/null +++ b/src/window/meson.build @@ -0,0 +1,13 @@ +window = py.extension_module( + 'window', + 'window.c', + include_directories: '../include', + c_args: warnings_error, + dependencies: pg_base_deps, + install: true, + subdir: pg, +) +install_data('window.pyi', install_dir: pg_dir, install_tag: 'pg-tag') +if not get_option('stripped') + py.install_sources('window_test.py', subdir: pg / 'tests') +endif diff --git a/src_c/window.c b/src/window/window.c similarity index 99% rename from src_c/window.c rename to src/window/window.c index 8e0b1bde50..317969aae5 100644 --- a/src_c/window.c +++ b/src/window/window.c @@ -5,8 +5,8 @@ #include "pgcompat.h" #include "pgopengl.h" -#include "doc/sdl2_video_doc.h" -#include "doc/window_doc.h" +#include "../_sdl2/video/sdl2_video_doc.h" +#include "window_doc.h" static int is_window_mod_init = 0; diff --git a/buildconfig/stubs/pygame/window.pyi b/src/window/window.pyi similarity index 99% rename from buildconfig/stubs/pygame/window.pyi rename to src/window/window.pyi index f671a8ebb0..e9e950e330 100644 --- a/buildconfig/stubs/pygame/window.pyi +++ b/src/window/window.pyi @@ -1,10 +1,11 @@ from typing import Optional, Union +from typing_extensions import deprecated # added in 3.13 + from pygame.locals import WINDOWPOS_UNDEFINED from pygame.rect import Rect from pygame.surface import Surface from pygame.typing import Point, RectLike -from typing_extensions import deprecated # added in 3.13 def get_grabbed_window() -> Optional[Window]: ... diff --git a/src_c/doc/window_doc.h b/src/window/window_doc.h similarity index 100% rename from src_c/doc/window_doc.h rename to src/window/window_doc.h diff --git a/test/window_test.py b/src/window/window_test.py similarity index 100% rename from test/window_test.py rename to src/window/window_test.py diff --git a/src_c/_sdl2/meson.build b/src_c/_sdl2/meson.build deleted file mode 100644 index 2ad443e993..0000000000 --- a/src_c/_sdl2/meson.build +++ /dev/null @@ -1,67 +0,0 @@ -cython_base = '../cython/pygame/_sdl2' - -_sdl2_audio = py.extension_module( - 'audio', - fs.is_file('audio.c') ? 'audio.c' : cython_base / 'audio.pyx', - dependencies: pg_base_deps, - include_directories: '..', - install: true, - subdir: pg / '_sdl2', -) - -_sdl2_video = py.extension_module( - 'video', - fs.is_file('video.c') ? 'video.c' : cython_base / 'video.pyx', - dependencies: pg_base_deps, - include_directories: '..', - install: true, - subdir: pg / '_sdl2', -) - -_sdl2_controller_old = py.extension_module( - 'controller_old', - fs.is_file('controller_old.c') ? 'controller_old.c' : cython_base / 'controller_old.pyx', - dependencies: pg_base_deps, - include_directories: '..', - install: true, - subdir: pg / '_sdl2', -) - -if sdl_mixer_dep.found() - _sdl2_mixer = py.extension_module( - 'mixer', - fs.is_file('mixer.c') ? 'mixer.c' : cython_base / 'mixer.pyx', - dependencies: pg_base_deps + sdl_mixer_dep, - include_directories: '..', - install: true, - subdir: pg / '_sdl2', - ) -endif - -_sdl2_sdl2 = py.extension_module( - 'sdl2', - fs.is_file('sdl2.c') ? 'sdl2.c' : cython_base / 'sdl2.pyx', - dependencies: pg_base_deps, - include_directories: '..', - install: true, - subdir: pg / '_sdl2', -) - -# This is not a cython file -_sdl2_touch = py.extension_module( - 'touch', - 'touch.c', - dependencies: pg_base_deps, - include_directories: '..', - install: true, - subdir: pg / '_sdl2', -) - -_sdl2_controller = py.extension_module( - 'controller', - 'controller.c', - dependencies: pg_base_deps, - include_directories: '..', - install: true, - subdir: pg / '_sdl2', -) diff --git a/src_c/cython/pygame/__init__.pxd b/src_c/cython/pygame/__init__.pxd deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src_c/cython/pygame/_sdl2/__init__.pxd b/src_c/cython/pygame/_sdl2/__init__.pxd deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src_c/doc/README.rst b/src_c/doc/README.rst deleted file mode 100644 index 4143227b0f..0000000000 --- a/src_c/doc/README.rst +++ /dev/null @@ -1,5 +0,0 @@ -These files are generated from the rst files in docs/reST/ref/ - -Both the .rst file and the generated .h file should be committed. - -To generate docs run: `python buildconfig/make_docs.py`. diff --git a/src_c/include/pygame.h b/src_c/include/pygame.h deleted file mode 100644 index a520b48e82..0000000000 --- a/src_c/include/pygame.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - pygame-ce - Python Game Library - Copyright (C) 2000-2001 Pete Shinners - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Pete Shinners - pete@shinners.org -*/ - -/* To allow the Pygame C api to be globally shared by all code within an - * extension module built from multiple C files, only include the pygame.h - * header within the top level C file, the one which calls the - * 'import_pygame_*' macros. All other C source files of the module should - * include _pygame.h instead. - */ -#ifndef PYGAME_H -#define PYGAME_H - -#include "_pygame.h" - -#endif diff --git a/src_c/meson.build b/src_c/meson.build deleted file mode 100644 index 0c1479a812..0000000000 --- a/src_c/meson.build +++ /dev/null @@ -1,460 +0,0 @@ -# first the "required" modules - -base = py.extension_module( - 'base', - 'base.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -color = py.extension_module( - 'color', - 'color.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -constants = py.extension_module( - 'constants', - 'constants.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -# TODO: support SDL3 -if sdl_api != 3 -display = py.extension_module( - 'display', - 'display.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) -endif - -event = py.extension_module( - 'event', - 'event.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -key = py.extension_module( - 'key', - 'key.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -mouse = py.extension_module( - 'mouse', - 'mouse.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -rect = py.extension_module( - 'rect', - ['rect.c', 'pgcompat_rect.c'], - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -rwobject = py.extension_module( - 'rwobject', - 'rwobject.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -# TODO: support SDL3 -if sdl_api != 3 -simd_blitters_avx2 = static_library( - 'simd_blitters_avx2', - 'simd_blitters_avx2.c', - dependencies: pg_base_deps, - c_args: simd_avx2_flags + warnings_error, -) - -simd_blitters_sse2 = static_library( - 'simd_blitters_sse2', - 'simd_blitters_sse2.c', - dependencies: pg_base_deps, - c_args: simd_sse2_neon_flags + warnings_error, -) - -simd_surface_fill_avx2 = static_library( - 'simd_surface_fill_avx2', - 'simd_surface_fill_avx2.c', - dependencies: pg_base_deps, - c_args: simd_avx2_flags + warnings_error, -) - -simd_surface_fill_sse2 = static_library( - 'simd_surface_fill_sse2', - 'simd_surface_fill_sse2.c', - dependencies: pg_base_deps, - c_args: simd_sse2_neon_flags + warnings_error, -) - -surface = py.extension_module( - 'surface', - [ - 'surface.c', - 'alphablit.c', - 'surface_fill.c', - ], - c_args: warnings_error, - link_with: [ - simd_blitters_avx2, - simd_blitters_sse2, - simd_surface_fill_avx2, - simd_surface_fill_sse2, - ], - dependencies: pg_base_deps, - install: true, - subdir: pg, -) -endif - -surflock = py.extension_module( - 'surflock', - 'surflock.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -time = py.extension_module( - 'time', - 'time.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -joystick = py.extension_module( - 'joystick', - 'joystick.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -draw = py.extension_module( - 'draw', - 'draw.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -image = py.extension_module( - 'image', - 'image.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -simd_transform_avx2 = static_library( - 'simd_transform_avx2', - 'simd_transform_avx2.c', - dependencies: pg_base_deps, - c_args: simd_avx2_flags + warnings_error, -) - -simd_transform_sse2 = static_library( - 'simd_transform_sse2', - 'simd_transform_sse2.c', - dependencies: pg_base_deps, - c_args: simd_sse2_neon_flags + warnings_error, -) - -transform_sources = ['transform.c', 'rotozoom.c', 'scale2x.c'] -transform_objs = [] - -if ( - cc.get_argument_syntax() == 'msvc' - and host_machine.cpu_family().startswith('x86') -) - if host_machine.cpu_family() == 'x86' - transform_objs += '../buildconfig/obj/win32/scale_mmx.obj' - else - transform_objs += '../buildconfig/obj/win64/scale_mmx.obj' - endif -else - transform_sources += 'scale_mmx.c' -endif - -transform = py.extension_module( - 'transform', - transform_sources, - c_args: warnings_error, - link_with: [simd_transform_avx2, simd_transform_sse2], - objects: transform_objs, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -mask = py.extension_module( - 'mask', - ['mask.c', 'bitmask.c'], - c_args: warnings_error + warnings_temp_mask, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -bufferproxy = py.extension_module( - 'bufferproxy', - 'bufferproxy.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -pixelarray = py.extension_module( - 'pixelarray', - 'pixelarray.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -math = py.extension_module( - 'math', - 'math.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -pixelcopy = py.extension_module( - 'pixelcopy', - 'pixelcopy.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -newbuffer = py.extension_module( - 'newbuffer', - 'newbuffer.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -# new/experimental/uncommon stuff, but built by default -system = py.extension_module( - 'system', - 'system.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -geometry = py.extension_module( - 'geometry', - 'geometry.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -window = py.extension_module( - 'window', - 'window.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) - -# TODO: support SDL3 -if sdl_api != 3 -_render = py.extension_module( - '_render', - 'render.c', - c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) -endif - -# TODO: support SDL3 -if sdl_api != 3 -gfxdraw = py.extension_module( - 'gfxdraw', - ['gfxdraw.c', 'SDL_gfx/SDL_gfxPrimitives.c'], - # c_args: warnings_error, - dependencies: pg_base_deps, - install: true, - subdir: pg, -) -endif - -# pygame._sdl2 -# TODO: support SDL3 -if sdl_api != 3 -subdir('_sdl2') -endif - -# pygame._camera -pg_camera_sources = ['_camera.c'] -pg_camera_link = [] -if plat == 'win' - pg_camera_sources += 'camera_windows.c' - # TODO: should this link logic be improved/made meson-ey? - pg_camera_link = [] - foreach link_arg : [ - '-lMfplat', - '-lMf', - '-lMfuuid', - '-lMfreadwrite', - '-lOle32', - ] - if cc.has_link_argument(link_arg) - pg_camera_link += link_arg - endif - endforeach -elif plat == 'linux' - pg_camera_sources += 'camera_v4l2.c' -endif - -_camera = py.extension_module( - '_camera', - pg_camera_sources, - c_args: warnings_error, - dependencies: pg_base_deps, - link_args: pg_camera_link, - install: true, - subdir: pg, -) - -# pygame.scrap -pg_scrap_link = [] # TODO: should this link logic be improved/made meson-ey? -if plat == 'win' - pg_scrap_link += ['-luser32', '-lgdi32'] -endif - -scrap = py.extension_module( - 'scrap', - 'scrap.c', - c_args: warnings_error, - dependencies: pg_base_deps, - link_args: pg_scrap_link, - install: true, - subdir: pg, -) - -# optional modules - -if sdl_image_dep.found() - imageext = py.extension_module( - 'imageext', - 'imageext.c', - c_args: warnings_error, - dependencies: pg_base_deps + sdl_image_dep, - install: true, - subdir: pg, - ) -endif - -if sdl_ttf_dep.found() - font = py.extension_module( - 'font', - 'font.c', - c_args: warnings_error, - dependencies: pg_base_deps + sdl_ttf_dep, - install: true, - subdir: pg, - ) -endif - -# TODO: support SDL3 -if sdl_api != 3 - -if sdl_mixer_dep.found() - mixer = py.extension_module( - 'mixer', - 'mixer.c', - c_args: warnings_error, - dependencies: pg_base_deps + sdl_mixer_dep, - install: true, - subdir: pg, - ) - - mixer_music = py.extension_module( - 'mixer_music', - 'music.c', - c_args: warnings_error, - dependencies: pg_base_deps + sdl_mixer_dep, - install: true, - subdir: pg, - ) -endif - -if freetype_dep.found() - _freetype = py.extension_module( - '_freetype', - [ - 'freetype/ft_cache.c', - 'freetype/ft_wrap.c', - 'freetype/ft_render.c', - 'freetype/ft_render_cb.c', - 'freetype/ft_layout.c', - 'freetype/ft_unicode.c', - '_freetype.c', - ], - c_args: warnings_error + warnings_temp_freetype, - dependencies: pg_base_deps + freetype_dep, - install: true, - subdir: pg, - ) -endif - -endif - -if portmidi_dep.found() - pypm = py.extension_module( - 'pypm', - fs.is_file('pypm.c') ? 'pypm.c' : 'cython/pygame/pypm.pyx', - # c_args: warnings_error, - dependencies: pg_base_deps + portmidi_deps, - install: true, - subdir: pg, - ) -endif diff --git a/src_c/pgcompat.c b/src_c/pgcompat.c deleted file mode 100644 index 178102e186..0000000000 --- a/src_c/pgcompat.c +++ /dev/null @@ -1,5 +0,0 @@ -#ifdef PG_SDL3 -#include -#else -#include -#endif diff --git a/src_c/pgcompat.h b/src_c/pgcompat.h deleted file mode 100644 index f2f1c8787e..0000000000 --- a/src_c/pgcompat.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Python 2.x/3.x compatibility tools (internal) - */ -#ifndef PGCOMPAT_INTERNAL_H -#define PGCOMPAT_INTERNAL_H - -#include "include/pgcompat.h" - -/* Module init function returns new module instance. */ -#define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC PyInit_##mod_name(void) - -/* Defaults for unicode file path encoding */ -#if defined(MS_WIN32) -#define UNICODE_DEF_FS_ERROR "replace" -#else -#define UNICODE_DEF_FS_ERROR "surrogateescape" -#endif - -#define RELATIVE_MODULE(m) ("." m) - -#endif /* ~PGCOMPAT_INTERNAL_H */ diff --git a/src_c/pgplatform.h b/src_c/pgplatform.h deleted file mode 100644 index 54310eb672..0000000000 --- a/src_c/pgplatform.h +++ /dev/null @@ -1,23 +0,0 @@ -/* platform/compiler adjustments (internal) */ -#ifndef PG_PLATFORM_INTERNAL_H -#define PG_PLATFORM_INTERNAL_H - -#include "include/pgplatform.h" - -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif -#ifndef ABS -#define ABS(a) (((a) < 0) ? -(a) : (a)) -#endif - -/* warnings */ -#define PG_STRINGIZE_HELPER(x) #x -#define PG_STRINGIZE(x) PG_STRINGIZE_HELPER(x) -#define PG_WARN(desc) \ - message(__FILE__ "(" PG_STRINGIZE(__LINE__) "): WARNING: " #desc) - -#endif /* ~PG_PLATFORM_INTERNAL_H */ diff --git a/src_py/_sdl2/meson.build b/src_py/_sdl2/meson.build deleted file mode 100644 index 766b1161fe..0000000000 --- a/src_py/_sdl2/meson.build +++ /dev/null @@ -1,6 +0,0 @@ -# pure python sources -python_sources = files( - '__init__.py', - 'window.py', -) -py.install_sources(python_sources, subdir: pg / '_sdl2') diff --git a/src_py/meson.build b/src_py/meson.build deleted file mode 100644 index 541c54cd69..0000000000 --- a/src_py/meson.build +++ /dev/null @@ -1,43 +0,0 @@ -# pure python sources -python_sources = files( - '__init__.py', - '_camera_opencv.py', - '_data_classes.py', - '_debug.py', - '_sprite.py', - 'camera.py', - 'colordict.py', - 'cursors.py', - 'freetype.py', - 'ftfont.py', - 'locals.py', - 'macosx.py', - 'midi.py', - 'pkgdata.py', - 'sndarray.py', - 'sprite.py', - 'surfarray.py', - 'sysfont.py', - 'typing.py', - 'version.py', -) -py.install_sources(python_sources, subdir: pg) - -# if not building font, install use ftfont for font.py -if not sdl_ttf_dep.found() and freetype_dep.found() - py.install_sources('ftfont.py', subdir: pg, rename: 'font.py') -endif - -data_files = files( - 'freesansbold.ttf', - 'pygame_icon.bmp', -) -if plat == 'mac' - data_files += 'pygame_icon_mac.bmp' -endif - -install_data(data_files, install_dir: pg_dir, install_tag: 'pg-tag') - -subdir('_sdl2') -subdir('__pyinstaller') -subdir('__briefcase') diff --git a/test/meson.build b/test/meson.build deleted file mode 100644 index d789ad01e0..0000000000 --- a/test/meson.build +++ /dev/null @@ -1,62 +0,0 @@ -# pure python sources -test_files = files( - '__init__.py', - '__main__.py', - 'base_test.py', - 'blit_test.py', - 'bufferproxy_test.py', - 'camera_test.py', - 'color_test.py', - 'constants_test.py', - 'controller_test.py', - 'cursors_test.py', - 'debug_test.py', - 'display_test.py', - 'docs_test.py', - 'draw_test.py', - 'event_test.py', - 'font_test.py', - 'freetype_test.py', - 'ftfont_test.py', - 'geometry_test.py', - 'gfxdraw_test.py', - 'image__save_gl_surface_test.py', - 'image_test.py', - 'imageext_test.py', - 'joystick_test.py', - 'key_test.py', - 'locals_test.py', - 'mask_test.py', - 'math_test.py', - 'midi_test.py', - 'mixer_music_test.py', - 'mixer_test.py', - 'mouse_test.py', - 'pixelarray_test.py', - 'pixelcopy_test.py', - 'rect_test.py', - 'rwobject_test.py', - 'scrap_tags.py', - 'scrap_test.py', - 'sndarray_tags.py', - 'sndarray_test.py', - 'sprite_test.py', - 'surface_test.py', - 'surfarray_tags.py', - 'surfarray_test.py', - 'surflock_test.py', - 'sysfont_test.py', - 'system_test.py', - 'time_test.py', - 'touch_test.py', - 'transform_test.py', - 'typing_test.py', - 'version_test.py', - 'video_test.py', - 'window_test.py', -) - -py.install_sources(test_files, subdir: pg / 'tests') - -install_subdir('fixtures', install_dir: pg_dir / 'tests', install_tag: 'pg-tag') -subdir('test_utils') diff --git a/test/scrap_tags.py b/test/scrap_tags.py deleted file mode 100644 index 66a18ec2cc..0000000000 --- a/test/scrap_tags.py +++ /dev/null @@ -1,26 +0,0 @@ -# __tags__ = ["ignore", "subprocess_ignore"] - -# TODO: make scrap_test.py work -# This test used to work only on linux and windows. -# Currently it only work in windows, and in linux it throws: -# `pygame.error: content could not be placed in clipboard.` -# The old test and tags kept here for reference when fixing. - -# import sys -# -# exclude = False -# -# if sys.platform == "win32" or sys.platform.startswith("linux"): -# try: -# import pygame -# -# pygame.scrap._NOT_IMPLEMENTED_ -# except AttributeError: -# pass -# else: -# exclude = True -# else: -# exclude = True -# -# if exclude: -# __tags__.extend(["ignore", "subprocess_ignore"]) diff --git a/test/sndarray_tags.py b/test/sndarray_tags.py deleted file mode 100644 index 5e24b93580..0000000000 --- a/test/sndarray_tags.py +++ /dev/null @@ -1,11 +0,0 @@ -__tags__ = ["array"] - -exclude = False - -try: - import numpy -except ImportError: - exclude = True - -if exclude: - __tags__.extend(("ignore", "subprocess_ignore")) diff --git a/test/surfarray_tags.py b/test/surfarray_tags.py deleted file mode 100644 index 5e24b93580..0000000000 --- a/test/surfarray_tags.py +++ /dev/null @@ -1,11 +0,0 @@ -__tags__ = ["array"] - -exclude = False - -try: - import numpy -except ImportError: - exclude = True - -if exclude: - __tags__.extend(("ignore", "subprocess_ignore"))