From 4394fda206a29530d2dd94ad680a2ed43c8fb62c Mon Sep 17 00:00:00 2001 From: KSJ2000 Date: Sat, 18 Jan 2025 08:23:23 +0200 Subject: [PATCH 1/2] pygame-sdl2: 2.1.0 -> 8.3.1.24090601 --- .../python-modules/pygame-sdl2/default.nix | 39 +++++++------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/pkgs/development/python-modules/pygame-sdl2/default.nix b/pkgs/development/python-modules/pygame-sdl2/default.nix index 43ce26585f30..67affee61c65 100644 --- a/pkgs/development/python-modules/pygame-sdl2/default.nix +++ b/pkgs/development/python-modules/pygame-sdl2/default.nix @@ -1,8 +1,7 @@ { lib, buildPythonPackage, - fetchurl, - isPy27, + fetchFromGitHub, renpy, cython_0, SDL2, @@ -13,32 +12,19 @@ libpng, setuptools, }: -let - pname = "pygame-sdl2"; - version = "2.1.0"; - renpy_version = renpy.base_version; -in -buildPythonPackage { - inherit pname version; - name = "${pname}-${version}-${renpy_version}"; +buildPythonPackage rec { + pname = "pygame-sdl2"; + version = "8.3.1.24090601"; pyproject = true; - src = fetchurl { - url = "https://www.renpy.org/dl/${renpy_version}/pygame_sdl2-${version}+renpy${renpy_version}.tar.gz"; - hash = "sha256-bcTrdXWLTCnZQ/fP5crKIPoqJiyz+o6s0PzRChV7TQE="; + src = fetchFromGitHub { + owner = "renpy"; + repo = "pygame_sdl2"; + tag = "renpy-${version}"; + hash = "sha256-0itOmDScM+4HmWTpjkln56pv+yXDPB1KIDbE6ub2Tls="; }; - # force rebuild of headers needed for install - prePatch = '' - rm -rf gen gen3 - ''; - - # Remove build tag which produces invaild version - postPatch = '' - sed -i '2d' setup.cfg - ''; - nativeBuildInputs = [ SDL2.dev cython_0 @@ -54,7 +40,12 @@ buildPythonPackage { libpng ]; - doCheck = isPy27; # python3 tests are non-functional + doCheck = true; + + preBuild = '' + sed -i "s/2.1.0/${version}/" setup.py + sed -i "s/2, 1, 0/$(echo ${version} | sed 's/\./,\ /g')/g" src/pygame_sdl2/version.py + ''; meta = { description = "Reimplementation of parts of pygame API using SDL2"; From d1fb7e8474a30cedf2089722a97ff418333bfe01 Mon Sep 17 00:00:00 2001 From: KSJ2000 Date: Sat, 18 Jan 2025 08:28:25 +0200 Subject: [PATCH 2/2] pygame-sdl2: modernize derivation --- .../python-modules/pygame-sdl2/default.nix | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/pkgs/development/python-modules/pygame-sdl2/default.nix b/pkgs/development/python-modules/pygame-sdl2/default.nix index 67affee61c65..e8bea65a499f 100644 --- a/pkgs/development/python-modules/pygame-sdl2/default.nix +++ b/pkgs/development/python-modules/pygame-sdl2/default.nix @@ -1,15 +1,15 @@ { - lib, buildPythonPackage, - fetchFromGitHub, - renpy, cython_0, - SDL2, - SDL2_image, - SDL2_ttf, - SDL2_mixer, + fetchFromGitHub, + lib, libjpeg, libpng, + nix-update-script, + SDL2, + SDL2_image, + SDL2_mixer, + SDL2_ttf, setuptools, }: @@ -25,35 +25,40 @@ buildPythonPackage rec { hash = "sha256-0itOmDScM+4HmWTpjkln56pv+yXDPB1KIDbE6ub2Tls="; }; - nativeBuildInputs = [ - SDL2.dev + build-system = [ cython_0 + SDL2 setuptools ]; - buildInputs = [ - SDL2 - SDL2_image - SDL2_ttf - SDL2_mixer + dependencies = [ libjpeg libpng + SDL2 + SDL2_image + SDL2_mixer + SDL2_ttf ]; doCheck = true; preBuild = '' - sed -i "s/2.1.0/${version}/" setup.py - sed -i "s/2, 1, 0/$(echo ${version} | sed 's/\./,\ /g')/g" src/pygame_sdl2/version.py + substituteInPlace setup.py --replace-fail "2.1.0" "${version}" + substituteInPlace src/pygame_sdl2/version.py --replace-fail "2, 1, 0" "${ + builtins.replaceStrings [ "." ] [ ", " ] version + }" ''; + passthru.updateScript = nix-update-script { extraArgs = [ "--version-regex=renpy-(.*)" ]; }; + meta = { - description = "Reimplementation of parts of pygame API using SDL2"; + description = "Reimplementation of the Pygame API using SDL2 and related libraries"; homepage = "https://github.com/renpy/pygame_sdl2"; license = with lib.licenses; [ lgpl2 zlib ]; + platforms = lib.platforms.unix; maintainers = with lib.maintainers; [ raskin ]; }; }