diff --git a/pkgs/development/python-modules/pettingzoo/default.nix b/pkgs/development/python-modules/pettingzoo/default.nix index ad3ab0ca58e9..9ce13d12861b 100644 --- a/pkgs/development/python-modules/pettingzoo/default.nix +++ b/pkgs/development/python-modules/pettingzoo/default.nix @@ -12,7 +12,7 @@ numpy, # optional-dependencies - pygame, + pygame-ce, pymunk, chess, rlcard, @@ -31,16 +31,17 @@ pytestCheckHook, }: -buildPythonPackage rec { +buildPythonPackage (finalAttrs: { pname = "pettingzoo"; - version = "1.25.0"; + version = "1.26.1"; pyproject = true; + __structuredAttrs = true; src = fetchFromGitHub { owner = "Farama-Foundation"; repo = "PettingZoo"; - tag = version; - hash = "sha256-hQe/TMlLG//Bn8aaSo0/FPOUvOEyKfztuTIS7SMsUQ4="; + tag = finalAttrs.version; + hash = "sha256-WrfjkDnmir6bZvtMD7MVQKVoGvK+lutlOoNe9SNQ8jU="; }; build-system = [ @@ -53,26 +54,25 @@ buildPythonPackage rec { ]; optional-dependencies = { - all = lib.concatAttrValues (lib.removeAttrs optional-dependencies [ "all" ]); atari = [ # multi-agent-ale-py - pygame + pygame-ce ]; butterfly = [ - pygame + pygame-ce pymunk ]; classic = [ chess - pygame + pygame-ce rlcard shimmy ]; - mpe = [ pygame ]; + mpe = [ pygame-ce ]; other = [ pillow ]; sisl = [ pybox2d - pygame + pygame-ce pymunk scipy ]; @@ -91,7 +91,7 @@ buildPythonPackage rec { nativeCheckInputs = [ chess - pygame + pygame-ce pymunk pytest-markdown-docs pytest-xdist @@ -118,8 +118,8 @@ buildPythonPackage rec { meta = { description = "API standard for multi-agent reinforcement learning environments, with popular reference environments and related utilities"; homepage = "https://github.com/Farama-Foundation/PettingZoo"; - changelog = "https://github.com/Farama-Foundation/PettingZoo/releases/tag/${version}"; + changelog = "https://github.com/Farama-Foundation/PettingZoo/releases/tag/${finalAttrs.src.tag}"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ GaetanLepage ]; }; -} +}) diff --git a/pkgs/development/python-modules/pygame-ce/default.nix b/pkgs/development/python-modules/pygame-ce/default.nix index 76810dad5f8c..fd6efdd93aee 100644 --- a/pkgs/development/python-modules/pygame-ce/default.nix +++ b/pkgs/development/python-modules/pygame-ce/default.nix @@ -1,18 +1,25 @@ { - stdenv, lib, - replaceVars, - fetchFromGitHub, + stdenv, buildPythonPackage, + fetchFromGitHub, + replaceVars, python, - pkg-config, - setuptools, - cython, - ninja, - meson-python, - pyproject-metadata, - nix-update-script, + # build-system + cython, + meson-python, + ninja, + pyproject-metadata, + setuptools, + sphinx, + sphinx-autoapi, + + # nativeBuildInputs + astroid, + pkg-config, + + # buildInputs fontconfig, freetype, libjpeg, @@ -23,22 +30,27 @@ SDL2_image, SDL2_mixer, SDL2_ttf, - numpy, - astroid, + # tests + numpy, + writableTmpDirAsHomeHook, + + # passthru + nix-update-script, pygame-gui, }: -buildPythonPackage rec { +buildPythonPackage (finalAttrs: { pname = "pygame-ce"; - version = "2.5.6"; + version = "2.5.7"; pyproject = true; + __structuredAttrs = true; src = fetchFromGitHub { owner = "pygame-community"; repo = "pygame-ce"; - tag = version; - hash = "sha256-0DNvAs1E6OhN6wTvbMCDt9YAEFoBZp1r7hI4GSnJUl8="; + tag = finalAttrs.version; + hash = "sha256-Yjs2SLgPVMOy8DCS+Pfk0fs0G//sY20jfGQNJ5rN58Q="; # Unicode files cause different checksums on HFS+ vs. other filesystems postFetch = "rm -rf $out/docs/reST"; }; @@ -50,52 +62,66 @@ buildPythonPackage rec { "${lib.getDev dep}/" "${lib.getDev dep}/include" "${lib.getDev dep}/include/SDL2" - ]) buildInputs + ]) finalAttrs.buildInputs ); buildinputs_lib = builtins.toJSON ( builtins.concatMap (dep: [ "${lib.getLib dep}/" "${lib.getLib dep}/lib" - ]) buildInputs + ]) finalAttrs.buildInputs ); }) - - # https://github.com/pygame-community/pygame-ce/pull/3680#issuecomment-3796052119 - ./skip-failing-tests.patch ]; - postPatch = '' + postPatch = # "pyproject-metadata!=0.9.1" was pinned due to https://github.com/pygame-community/pygame-ce/pull/3395 # cython was pinned to fix windows build hangs (pygame-community/pygame-ce/pull/3015) - substituteInPlace pyproject.toml \ - --replace-fail '"pyproject-metadata!=0.9.1",' '"pyproject-metadata",' \ - --replace-fail '"meson<=1.9.1",' '"meson",' \ - --replace-fail '"meson-python<=0.18.0",' '"meson-python",' \ - --replace-fail '"ninja<=1.13.0",' "" \ - --replace-fail '"astroid<4.0.0",' "" \ - --replace-fail '"cython<=3.1.4",' '"cython",' \ - --replace-fail '"sphinx<=8.2.3",' "" \ - --replace-fail '"sphinx-autoapi<=3.6.0",' "" - substituteInPlace buildconfig/config_{unix,darwin}.py \ - --replace-fail 'from distutils' 'from setuptools._distutils' - substituteInPlace src_py/sysfont.py \ - --replace-fail 'path="fc-list"' 'path="${fontconfig}/bin/fc-list"' \ - --replace-fail /usr/X11/bin/fc-list ${fontconfig}/bin/fc-list - '' - + lib.optionalString stdenv.hostPlatform.isDarwin '' + '' + substituteInPlace pyproject.toml \ + --replace-fail "meson-python<=0.18.0" "meson-python" \ + --replace-fail "meson<=1.10.0" "meson" \ + --replace-fail "ninja<=1.13.0" "ninja" \ + --replace-fail "cython<=3.2.4" "cython" \ + --replace-fail "sphinx<=8.2.3" "sphinx" \ + --replace-fail "astroid<4.0.0" "astroid" \ + --replace-fail "sphinx-autoapi<=3.6.0" "sphinx-autoapi" \ + --replace-fail "pyproject-metadata!=0.9.1" "pyproject-metadata" + '' + # distutils now lives under setuptools._distutils + + '' + substituteInPlace buildconfig/config_{unix,darwin}.py \ + --replace-fail 'from distutils' 'from setuptools._distutils' + '' + # Inject the path to fc-list + + '' + substituteInPlace src_py/sysfont.py \ + --replace-fail \ + 'path="fc-list"' \ + 'path="${lib.getExe' fontconfig "fc-list"}"' \ + --replace-fail \ + '/usr/X11/bin/fc-list' \ + '${lib.getExe' fontconfig "fc-list"}' + '' # flaky - rm test/system_test.py - substituteInPlace test/meson.build \ - --replace-fail "'system_test.py'," "" - ''; + + lib.optionalString stdenv.hostPlatform.isDarwin '' + rm test/system_test.py + substituteInPlace test/meson.build \ + --replace-fail "'system_test.py'," "" + ''; + + build-system = [ + astroid + cython + meson-python + ninja + pyproject-metadata + setuptools + sphinx + sphinx-autoapi + ]; nativeBuildInputs = [ pkg-config - cython - setuptools - ninja - meson-python - pyproject-metadata ]; buildInputs = [ @@ -108,11 +134,11 @@ buildPythonPackage rec { (SDL2_image.override { enableSTB = false; }) SDL2_mixer SDL2_ttf - astroid ]; nativeCheckInputs = [ numpy + writableTmpDirAsHomeHook ]; preConfigure = '' @@ -127,7 +153,6 @@ buildPythonPackage rec { }; preCheck = '' - export HOME=$(mktemp -d) # No audio or video device in test environment export SDL_VIDEODRIVER=dummy export SDL_AUDIODRIVER=disk @@ -158,18 +183,19 @@ buildPythonPackage rec { "pygame.version" ]; - passthru.updateScript = nix-update-script { }; - - passthru.tests = { - inherit pygame-gui; + passthru = { + updateScript = nix-update-script { }; + tests = { + inherit pygame-gui; + }; }; meta = { description = "Pygame Community Edition (CE) - library for multimedia application built on SDL"; homepage = "https://pyga.me/"; - changelog = "https://github.com/pygame-community/pygame-ce/releases/tag/${src.tag}"; + changelog = "https://github.com/pygame-community/pygame-ce/releases/tag/${finalAttrs.src.tag}"; license = lib.licenses.lgpl21Plus; maintainers = [ lib.maintainers.pbsds ]; platforms = lib.platforms.unix; }; -} +}) diff --git a/pkgs/development/python-modules/pygame-ce/fix-dependency-finding.patch b/pkgs/development/python-modules/pygame-ce/fix-dependency-finding.patch index 5e39dff13575..43910758aa42 100644 --- a/pkgs/development/python-modules/pygame-ce/fix-dependency-finding.patch +++ b/pkgs/development/python-modules/pygame-ce/fix-dependency-finding.patch @@ -1,13 +1,19 @@ diff --git a/buildconfig/config_darwin.py b/buildconfig/config_darwin.py -index 9503ea70..d0d3ab6e 100644 +index fdc911318..9acce8e5f 100644 --- a/buildconfig/config_darwin.py +++ b/buildconfig/config_darwin.py -@@ -140,16 +140,8 @@ def main(auto_config=False): - ]) +@@ -138,22 +138,8 @@ def main(auto_config=False): print('Hunting dependencies...') -- incdirs = ['/usr/local/include', '/opt/homebrew/include'] -- incdirs.extend(['/usr/local/include/SDL2', '/opt/homebrew/include/SDL2', '/opt/local/include/SDL2']) + +- homebrew_prefix = '/opt/homebrew' +- try: +- homebrew_prefix = check_output(['brew', '--prefix'], text=True, stderr=DEVNULL).strip() +- except (FileNotFoundError, CalledProcessError): +- pass +- +- incdirs = ['/usr/local/include', f'{homebrew_prefix}/include'] +- incdirs.extend(['/usr/local/include/SDL2', f'{homebrew_prefix}/include/SDL2', '/opt/local/include/SDL2']) - - incdirs.extend([ - #'/usr/X11/include', @@ -15,17 +21,17 @@ index 9503ea70..d0d3ab6e 100644 - '/opt/local/include/freetype2/freetype'] - ) - #libdirs = ['/usr/local/lib', '/usr/X11/lib', '/opt/local/lib'] -- libdirs = ['/usr/local/lib', '/opt/local/lib', '/opt/homebrew/lib'] +- libdirs = ['/usr/local/lib', '/opt/local/lib', f'{homebrew_prefix}/lib'] + incdirs = @buildinputs_include@ + libdirs = @buildinputs_lib@ for d in DEPS: if isinstance(d, (list, tuple)): diff --git a/buildconfig/config_unix.py b/buildconfig/config_unix.py -index 3eba5b5c..53cc6233 100644 +index a9ebc8394..0875da6dd 100644 --- a/buildconfig/config_unix.py +++ b/buildconfig/config_unix.py -@@ -240,11 +240,8 @@ def main(auto_config=False): +@@ -238,11 +238,8 @@ def main(auto_config=False): if not DEPS[0].found: raise RuntimeError('Unable to run "sdl-config". Please make sure a development version of SDL is installed.') diff --git a/pkgs/development/python-modules/pygame-gui/default.nix b/pkgs/development/python-modules/pygame-gui/default.nix index ea2fd3040bfe..be21cc0d92af 100644 --- a/pkgs/development/python-modules/pygame-gui/default.nix +++ b/pkgs/development/python-modules/pygame-gui/default.nix @@ -3,43 +3,57 @@ pkgs, stdenv, buildPythonPackage, - nix-update-script, fetchFromGitHub, + + # build-system setuptools, + + # dependencies pygame-ce, python-i18n, + + # tests pytestCheckHook, + writableTmpDirAsHomeHook, + + # passthru + nix-update-script, }: -buildPythonPackage rec { +buildPythonPackage (finalAttrs: { pname = "pygame-gui"; version = "0614"; pyproject = true; + __structuredAttrs = true; # nixpkgs-update: no auto update src = fetchFromGitHub { owner = "MyreMylar"; repo = "pygame_gui"; - tag = "v_${version}"; + tag = "v_${finalAttrs.version}"; hash = "sha256-wLvWaJuXMXk7zOaSZfIpsXhQt+eCjOtlh8IRuKbR75o="; }; - nativeBuildInputs = [ setuptools ]; - - propagatedBuildInputs = [ - pygame-ce - python-i18n - ]; - postPatch = '' substituteInPlace pygame_gui/core/utility.py \ --replace-fail "xsel" "${lib.getExe pkgs.xsel}" ''; - nativeCheckInputs = [ pytestCheckHook ]; + build-system = [ + setuptools + ]; + + dependencies = [ + pygame-ce + python-i18n + ]; + + nativeCheckInputs = [ + pytestCheckHook + writableTmpDirAsHomeHook + ]; preCheck = '' - export HOME=$TMPDIR export SDL_VIDEODRIVER=dummy ''; @@ -54,6 +68,22 @@ buildPythonPackage rec { "test_process_event_text_ctrl_v_select_range" "test_process_event_text_ctrl_a" "test_process_event_text_ctrl_x" + + # Pixel-level rendering mismatches with pygame-ce 2.5.7 + "test_clear" + "test_creation_grow_to_fit_width" + "test_draw_ui" + "test_on_hovered" + "test_on_unhovered" + "test_process_event_mouse_buttons" + "test_set_active" + "test_set_cursor_from_click_pos" + "test_set_cursor_position" + "test_set_default_text_colour" + "test_set_inactive" + "test_set_text" + "test_split" + "test_split_index" ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ # fails to determine "/" as an existing path @@ -79,4 +109,4 @@ buildPythonPackage rec { pbsds ]; }; -} +}) diff --git a/pkgs/development/python-modules/pysdl2/default.nix b/pkgs/development/python-modules/pysdl2/default.nix index 66fb3a4664aa..d14b516513e2 100644 --- a/pkgs/development/python-modules/pysdl2/default.nix +++ b/pkgs/development/python-modules/pysdl2/default.nix @@ -19,18 +19,17 @@ pytestCheckHook, }: -buildPythonPackage rec { +buildPythonPackage (finalAttrs: { pname = "pysdl2"; - version = "0.9.17-unstable-2025-04-03"; + version = "0.9.17-unstable-2025-11-18"; pyproject = true; - - pythonImportsCheck = [ "sdl2" ]; + __structuredAttrs = true; src = fetchFromGitHub { owner = "py-sdl"; repo = "py-sdl2"; - rev = "6414ee1c5f4a6eb91b71f5f9e35d469eee395b9f"; - hash = "sha256-E6Jpuin4bqDkvFTaZTsTNkNQJd2e5fuTf2oLsQ71uQ0="; + rev = "3d0672135fab3ca58e2f00c0a76b7b25cb818784"; + hash = "sha256-SgorCWZmJk13LNlTmh5Aomik14PTZdWliU3GWtkTASE="; }; patches = [ @@ -72,6 +71,8 @@ buildPythonPackage rec { PYTHONFAULTHANDLER = "1"; }; + pythonImportsCheck = [ "sdl2" ]; + nativeCheckInputs = [ numpy pillow @@ -91,10 +92,10 @@ buildPythonPackage rec { ]; meta = { - changelog = "https://github.com/py-sdl/py-sdl2/compare/0.9.17..${src.rev}"; + changelog = "https://github.com/py-sdl/py-sdl2/compare/0.9.17..${finalAttrs.src.rev}"; description = "Wrapper around the SDL2 library and as such similar to the discontinued PySDL project"; homepage = "https://github.com/py-sdl/py-sdl2"; license = lib.licenses.publicDomain; maintainers = with lib.maintainers; [ pmiddend ]; }; -} +}) diff --git a/pkgs/development/python-modules/pytmx/default.nix b/pkgs/development/python-modules/pytmx/default.nix index 83cd7fd1b3c7..691a0f672db7 100644 --- a/pkgs/development/python-modules/pytmx/default.nix +++ b/pkgs/development/python-modules/pytmx/default.nix @@ -2,18 +2,24 @@ lib, buildPythonPackage, fetchFromGitHub, + + # build-system + setuptools-scm, + + # dependencies pygame, pyglet, pysdl2, + + # tests pytestCheckHook, - setuptools-scm, }: buildPythonPackage { pname = "pytmx"; version = "3.32"; - pyproject = true; + __structuredAttrs = true; src = fetchFromGitHub { owner = "bitcraft";