2021-08-10 11:23:47 +01:00
|
|
|
{ stdenv, lib, substituteAll, fetchPypi, buildPythonPackage, python, pkg-config, libX11
|
|
|
|
, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, libpng, libjpeg, portmidi, freetype, fontconfig
|
|
|
|
, AppKit, CoreMIDI
|
2013-06-09 05:12:15 +01:00
|
|
|
}:
|
2008-10-06 23:07:53 +01:00
|
|
|
|
2016-05-23 02:35:07 +01:00
|
|
|
buildPythonPackage rec {
|
2017-05-27 10:25:35 +01:00
|
|
|
pname = "pygame";
|
2020-12-25 16:55:26 +00:00
|
|
|
version = "2.0.1";
|
2007-08-09 18:33:18 +01:00
|
|
|
|
2019-02-20 19:27:31 +00:00
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2020-12-25 16:55:26 +00:00
|
|
|
sha256 = "8b1e7b63f47aafcdd8849933b206778747ef1802bd3d526aca45ed77141e4001";
|
2007-08-09 18:33:18 +01:00
|
|
|
};
|
|
|
|
|
2021-08-10 11:23:47 +01: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"
|
|
|
|
]) 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
|
|
|
|
'';
|
|
|
|
|
2019-02-20 19:27:31 +00:00
|
|
|
nativeBuildInputs = [
|
2020-12-07 23:59:22 +00:00
|
|
|
pkg-config SDL2
|
2019-02-20 19:27:31 +00:00
|
|
|
];
|
|
|
|
|
2013-06-09 05:12:15 +01:00
|
|
|
buildInputs = [
|
2020-12-07 23:59:22 +00:00
|
|
|
SDL2 SDL2_image SDL2_mixer SDL2_ttf libpng libjpeg
|
2017-03-17 07:34:25 +00:00
|
|
|
portmidi libX11 freetype
|
2021-08-10 11:23:47 +01:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
AppKit CoreMIDI
|
2013-06-09 05:12:15 +01:00
|
|
|
];
|
|
|
|
|
2016-05-23 02:35:07 +01:00
|
|
|
preConfigure = ''
|
2019-05-03 21:30:04 +01:00
|
|
|
LOCALBASE=/ ${python.interpreter} buildconfig/config.py
|
2008-10-06 23:07:53 +01:00
|
|
|
'';
|
2007-08-09 18:33:18 +01:00
|
|
|
|
2021-08-10 11:23:47 +01:00
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
2021-07-22 12:13:26 +01:00
|
|
|
|
|
|
|
# No audio or video device in test environment
|
|
|
|
export SDL_VIDEODRIVER=dummy
|
|
|
|
export SDL_AUDIODRIVER=disk
|
|
|
|
export SDL_DISKAUDIOFILE=/dev/null
|
2021-08-10 11:23:47 +01:00
|
|
|
|
|
|
|
${python.interpreter} -m pygame.tests -v --exclude opengl,timing --time_out 300
|
|
|
|
|
|
|
|
runHook postCheck
|
2021-07-22 12:13:26 +01:00
|
|
|
'';
|
2021-08-10 11:23:47 +01:00
|
|
|
pythonImportsCheck = [ "pygame" ];
|
2021-07-22 12:13:26 +01:00
|
|
|
|
2019-02-20 19:27:31 +00:00
|
|
|
meta = with lib; {
|
2009-03-03 13:27:40 +00:00
|
|
|
description = "Python library for games";
|
2021-07-22 12:13:26 +01:00
|
|
|
homepage = "https://www.pygame.org/";
|
2016-05-23 02:35:07 +01:00
|
|
|
license = licenses.lgpl21Plus;
|
2021-08-10 11:23:47 +01:00
|
|
|
maintainers = with maintainers; [ angustrau ];
|
|
|
|
platforms = platforms.unix;
|
2007-08-09 18:33:18 +01:00
|
|
|
};
|
|
|
|
}
|