2021-12-06 16:07:01 +00:00
|
|
|
{ stdenv, lib, substituteAll, fetchFromGitHub, buildPythonPackage, python, pkg-config, libX11
|
2021-08-22 07:53:02 +00:00
|
|
|
, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, libpng, libjpeg, portmidi, freetype, fontconfig
|
2021-12-06 16:07:01 +00:00
|
|
|
, AppKit
|
2023-03-04 12:14:45 +00:00
|
|
|
, pythonAtLeast
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pygame";
|
2022-02-10 20:34:41 +00:00
|
|
|
version = "2.1.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
|
|
|
# Unicode file names lead to different checksums on HFS+ vs. other
|
|
|
|
# filesystems because of unicode normalisation. The documentation
|
|
|
|
# has such files and will be removed.
|
2022-02-10 20:34:41 +00:00
|
|
|
sha256 = "sha256-v1z6caEMJNXqbcbTmFXoy3KQewHiz6qK4vhNU6Qbukk=";
|
2022-06-16 17:23:12 +00:00
|
|
|
postFetch = "rm -rf $out/docs/reST";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
patches = [
|
|
|
|
# Patch pygame's dependency resolution to let it find build inputs
|
|
|
|
(substituteAll {
|
|
|
|
src = ./fix-dependency-finding.patch;
|
|
|
|
buildinputs_include = builtins.toJSON (builtins.concatMap (dep: [
|
|
|
|
"${lib.getDev dep}/"
|
|
|
|
"${lib.getDev dep}/include"
|
2022-03-30 09:31:56 +00:00
|
|
|
"${lib.getDev dep}/include/SDL2"
|
2021-08-22 07:53:02 +00:00
|
|
|
]) buildInputs);
|
|
|
|
buildinputs_lib = builtins.toJSON (builtins.concatMap (dep: [
|
|
|
|
"${lib.getLib dep}/"
|
|
|
|
"${lib.getLib dep}/lib"
|
|
|
|
]) buildInputs);
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace src_py/sysfont.py \
|
|
|
|
--replace 'path="fc-list"' 'path="${fontconfig}/bin/fc-list"' \
|
|
|
|
--replace /usr/X11/bin/fc-list ${fontconfig}/bin/fc-list
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [
|
2020-12-09 12:39:15 +00:00
|
|
|
pkg-config SDL2
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
2020-12-09 12:39:15 +00:00
|
|
|
SDL2 SDL2_image SDL2_mixer SDL2_ttf libpng libjpeg
|
2020-04-24 23:36:52 +00:00
|
|
|
portmidi libX11 freetype
|
2021-08-22 07:53:02 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
2021-12-06 16:07:01 +00:00
|
|
|
AppKit
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure = ''
|
2023-03-04 12:14:45 +00:00
|
|
|
${python.pythonForBuild.interpreter} buildconfig/config.py
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
2021-07-24 12:14:16 +00:00
|
|
|
|
|
|
|
# No audio or video device in test environment
|
|
|
|
export SDL_VIDEODRIVER=dummy
|
|
|
|
export SDL_AUDIODRIVER=disk
|
|
|
|
export SDL_DISKAUDIOFILE=/dev/null
|
2021-08-22 07:53:02 +00:00
|
|
|
|
|
|
|
${python.interpreter} -m pygame.tests -v --exclude opengl,timing --time_out 300
|
|
|
|
|
|
|
|
runHook postCheck
|
2021-07-24 12:14:16 +00:00
|
|
|
'';
|
2021-08-22 07:53:02 +00:00
|
|
|
pythonImportsCheck = [ "pygame" ];
|
2021-07-24 12:14:16 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Python library for games";
|
2021-07-24 12:14:16 +00:00
|
|
|
homepage = "https://www.pygame.org/";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.lgpl21Plus;
|
2022-02-20 05:27:41 +00:00
|
|
|
maintainers = with maintainers; [ emilytrau ];
|
2021-08-22 07:53:02 +00:00
|
|
|
platforms = platforms.unix;
|
2023-03-04 12:14:45 +00:00
|
|
|
# fatal error: longintrepr.h: No such file or directory.
|
|
|
|
broken = pythonAtLeast "3.11"; # At 2022-02-27
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|