From 6f598c002d2913284c25300d86d67a06654a78d8 Mon Sep 17 00:00:00 2001 From: Ankith Date: Thu, 26 Sep 2024 20:14:16 +0530 Subject: [PATCH 1/3] Fix cppcheck warnings in color lerp --- src_c/color.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src_c/color.c b/src_c/color.c index 80761a4b0d..850504f252 100644 --- a/src_c/color.c +++ b/src_c/color.c @@ -47,12 +47,16 @@ #include +static inline double +pg_round(double d) +{ #if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && \ !defined(round) -#define pg_round(d) (((d < 0) ? (ceil((d) - 0.5)) : (floor((d) + 0.5)))) + return (((d < 0) ? (ceil((d)-0.5)) : (floor((d) + 0.5)))); #else -#define pg_round(d) round(d) + return round(d); #endif +} typedef enum { TRISTATE_SUCCESS, TRISTATE_FAIL, TRISTATE_ERROR } tristate; @@ -813,10 +817,10 @@ _color_lerp(pgColorObject *self, PyObject *args, PyObject *kw) return RAISE(PyExc_ValueError, "Argument 2 must be in range [0, 1]"); } - new_rgba[0] = (Uint8)pg_round(self->data[0] * (1 - amt) + rgba[0] * amt); - new_rgba[1] = (Uint8)pg_round(self->data[1] * (1 - amt) + rgba[1] * amt); - new_rgba[2] = (Uint8)pg_round(self->data[2] * (1 - amt) + rgba[2] * amt); - new_rgba[3] = (Uint8)pg_round(self->data[3] * (1 - amt) + rgba[3] * amt); + for (int i = 0; i < 4; i++) { + new_rgba[i] = + (Uint8)pg_round(self->data[i] * (1 - amt) + rgba[i] * amt); + } return (PyObject *)_color_new_internal(Py_TYPE(self), new_rgba); } From 4d4819d864be1d84482797f471679dcb44d4f4a4 Mon Sep 17 00:00:00 2001 From: Ankith Date: Thu, 26 Sep 2024 20:14:24 +0530 Subject: [PATCH 2/3] Bump ubuntu to 24.04 on CI --- .github/workflows/build-debian-multiarch.yml | 4 ++-- .github/workflows/build-manylinux.yml | 2 +- .github/workflows/build-ubuntu-coverage.yml | 7 ++++++- .github/workflows/build-ubuntu-sdist.yml | 10 +++++++--- .github/workflows/cppcheck.yml | 12 ++++++++---- .github/workflows/format-lint.yml | 7 ++++++- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-debian-multiarch.yml b/.github/workflows/build-debian-multiarch.yml index 0ce4cd8315..d4291bbedb 100644 --- a/.github/workflows/build-debian-multiarch.yml +++ b/.github/workflows/build-debian-multiarch.yml @@ -49,7 +49,7 @@ env: jobs: build-multiarch: name: Debian (Bookworm - 12) [${{ matrix.arch }}] - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false # if a particular matrix build fails, don't skip the rest @@ -120,7 +120,7 @@ jobs: test-armv7-on-armv6: needs: build-multiarch name: Debian (Bookworm - 12) [build - armv7, test - armv6] - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Download all multiarch artifacts uses: actions/download-artifact@v4 diff --git a/.github/workflows/build-manylinux.yml b/.github/workflows/build-manylinux.yml index 0868664a08..0da361e794 100644 --- a/.github/workflows/build-manylinux.yml +++ b/.github/workflows/build-manylinux.yml @@ -38,7 +38,7 @@ concurrency: jobs: build: name: ${{ matrix.arch }} - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 permissions: contents: read packages: write diff --git a/.github/workflows/build-ubuntu-coverage.yml b/.github/workflows/build-ubuntu-coverage.yml index b01f623c2f..de2e902a27 100644 --- a/.github/workflows/build-ubuntu-coverage.yml +++ b/.github/workflows/build-ubuntu-coverage.yml @@ -48,7 +48,12 @@ jobs: strategy: fail-fast: false # if a particular matrix build fails, don't skip the rest matrix: - os: [ubuntu-22.04] + os: [ubuntu-24.04] + + env: + # Pip now forces us to either make a venv or set this flag, so we will do + # this + PIP_BREAK_SYSTEM_PACKAGES: 1 steps: - uses: actions/checkout@v4.1.7 diff --git a/.github/workflows/build-ubuntu-sdist.yml b/.github/workflows/build-ubuntu-sdist.yml index 3d90e3fdbc..8d2f6b3bd2 100644 --- a/.github/workflows/build-ubuntu-sdist.yml +++ b/.github/workflows/build-ubuntu-sdist.yml @@ -48,7 +48,12 @@ jobs: strategy: fail-fast: false # if a particular matrix build fails, don't skip the rest matrix: - os: [ubuntu-20.04, ubuntu-22.04] + os: [ubuntu-24.04, ubuntu-22.04] + + env: + # Pip now forces us to either make a venv or set this flag, so we will do + # this + PIP_BREAK_SYSTEM_PACKAGES: 1 steps: - uses: actions/checkout@v4.1.7 @@ -76,14 +81,13 @@ jobs: run: python3 -m pygame.tests -v --exclude opengl,music,timing --time_out 300 - name: Test typestubs - if: matrix.os == 'ubuntu-22.04' # run stubtest only once run: | pip3 install mypy python3 buildconfig/stubs/stubcheck.py # We upload the generated files under github actions assets - name: Upload sdist - if: matrix.os == 'ubuntu-20.04' # upload sdist only once + if: matrix.os == 'ubuntu-24.04' # upload sdist only once uses: actions/upload-artifact@v4 with: name: pygame-wheels-sdist diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml index 2450c43108..e817abd4c0 100644 --- a/.github/workflows/cppcheck.yml +++ b/.github/workflows/cppcheck.yml @@ -19,7 +19,7 @@ concurrency: # TODO: Any more static checkers can be added here jobs: run-cppcheck: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4.1.7 @@ -32,6 +32,10 @@ jobs: sudo apt install cppcheck - name: Run Static Checker - # skip cppcheck on SDL_gfx and scrap for now - run: cppcheck src_c --force --enable=performance,portability,warning \ - --suppress=*:src_c/SDL_gfx/* --suppress=*:src_c/scrap* + # 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/* \ + --suppress=missingReturn --suppress=syntaxError -DWITH_THREAD -j $(nproc) \ + -DPG_MAJOR_VERSION -DPG_MINOR_VERSION -DPG_PATCH_VERSION -DPG_VERSION_TAG diff --git a/.github/workflows/format-lint.yml b/.github/workflows/format-lint.yml index dd4e542641..d3276470bb 100644 --- a/.github/workflows/format-lint.yml +++ b/.github/workflows/format-lint.yml @@ -37,7 +37,12 @@ jobs: - uses: pre-commit/action@v3.0.1 format-lint-code-check: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 + + env: + # Pip now forces us to either make a venv or set this flag, so we will do + # this + PIP_BREAK_SYSTEM_PACKAGES: 1 steps: - uses: actions/checkout@v4.1.7 From 14f45350c4f208c55014c367d8f77f50d1e95ad0 Mon Sep 17 00:00:00 2001 From: Ankith Date: Fri, 27 Sep 2024 15:43:29 +0530 Subject: [PATCH 3/3] Skip wavpack tests with system deps --- .github/workflows/build-ubuntu-coverage.yml | 2 ++ .github/workflows/build-ubuntu-sdist.yml | 2 ++ test/mixer_music_test.py | 18 ++++++++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-ubuntu-coverage.yml b/.github/workflows/build-ubuntu-coverage.yml index de2e902a27..effda21e2b 100644 --- a/.github/workflows/build-ubuntu-coverage.yml +++ b/.github/workflows/build-ubuntu-coverage.yml @@ -54,6 +54,8 @@ jobs: # Pip now forces us to either make a venv or set this flag, so we will do # this PIP_BREAK_SYSTEM_PACKAGES: 1 + # We are using dependencies installed from apt + PG_DEPS_FROM_SYSTEM: 1 steps: - uses: actions/checkout@v4.1.7 diff --git a/.github/workflows/build-ubuntu-sdist.yml b/.github/workflows/build-ubuntu-sdist.yml index 8d2f6b3bd2..9a45ca55ce 100644 --- a/.github/workflows/build-ubuntu-sdist.yml +++ b/.github/workflows/build-ubuntu-sdist.yml @@ -54,6 +54,8 @@ jobs: # Pip now forces us to either make a venv or set this flag, so we will do # this PIP_BREAK_SYSTEM_PACKAGES: 1 + # We are using dependencies installed from apt + PG_DEPS_FROM_SYSTEM: 1 steps: - uses: actions/checkout@v4.1.7 diff --git a/test/mixer_music_test.py b/test/mixer_music_test.py index d777fbab02..f9cb722b4b 100644 --- a/test/mixer_music_test.py +++ b/test/mixer_music_test.py @@ -40,8 +40,10 @@ def test_load_flac(self): "|tags:music|" self.music_load("house_lo.flac") + # system installed SDL_mixer may not support wavpack @unittest.skipIf( - pygame.mixer.get_sdl_mixer_version() < (2, 8, 0), + pygame.mixer.get_sdl_mixer_version() < (2, 8, 0) + or "PG_DEPS_FROM_SYSTEM" in os.environ, "WavPack support added in SDL_mixer 2.8.0", ) def test_load_wv(self): @@ -85,7 +87,10 @@ def test_load_object(self): if pygame.mixer.get_sdl_mixer_version() >= (2, 6, 0): filenames.append("house_lo.mp3") - if pygame.mixer.get_sdl_mixer_version() >= (2, 8, 0): + if ( + pygame.mixer.get_sdl_mixer_version() >= (2, 8, 0) + and "PG_DEPS_FROM_SYSTEM" not in os.environ + ): filenames.append("house_lo.wv") if pygame.mixer.get_soundfont() is not None: @@ -113,7 +118,10 @@ def test_object_namehint(self): if pygame.mixer.get_sdl_mixer_version() >= (2, 6, 0): filenames.append("house_lo.mp3") - if pygame.mixer.get_sdl_mixer_version() >= (2, 8, 0): + if ( + pygame.mixer.get_sdl_mixer_version() >= (2, 8, 0) + and "PG_DEPS_FROM_SYSTEM" not in os.environ + ): filenames.append("house_lo.wv") if pygame.mixer.get_soundfont() is not None: @@ -208,8 +216,10 @@ def test_queue_flac(self): filename = example_path(os.path.join("data", "house_lo.flac")) pygame.mixer.music.queue(filename) + # system installed SDL_mixer may not support wavpack @unittest.skipIf( - pygame.mixer.get_sdl_mixer_version() < (2, 8, 0), + pygame.mixer.get_sdl_mixer_version() < (2, 8, 0) + or "PG_DEPS_FROM_SYSTEM" in os.environ, "WavPack support added in SDL_mixer 2.8.0", ) def test_queue_wv(self):