2023-12-02 23:02:08 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, substituteAll
|
|
|
|
, fetchFromGitHub
|
|
|
|
, buildPythonPackage
|
2023-03-09 20:23:45 +00:00
|
|
|
, pythonOlder
|
2023-12-02 23:02:08 +00:00
|
|
|
|
|
|
|
# build-system
|
|
|
|
, cython_3
|
|
|
|
, setuptools
|
|
|
|
, pkg-config
|
|
|
|
|
|
|
|
# native dependencies
|
|
|
|
, AppKit
|
|
|
|
, fontconfig
|
|
|
|
, freetype
|
|
|
|
, libjpeg
|
|
|
|
, libpng
|
|
|
|
, libX11
|
|
|
|
, portmidi
|
|
|
|
, SDL2
|
|
|
|
, SDL2_image
|
|
|
|
, SDL2_mixer
|
|
|
|
, SDL2_ttf
|
|
|
|
|
|
|
|
# tests
|
|
|
|
, python
|
2013-06-09 04:12:15 +00:00
|
|
|
}:
|
2008-10-06 22:07:53 +00:00
|
|
|
|
2016-05-23 01:35:07 +00:00
|
|
|
buildPythonPackage rec {
|
2017-05-27 09:25:35 +00:00
|
|
|
pname = "pygame";
|
2023-12-02 23:02:08 +00:00
|
|
|
version = "2.5.2";
|
|
|
|
pyproject = true;
|
2023-03-09 20:23:45 +00:00
|
|
|
|
|
|
|
disabled = pythonOlder "3.6";
|
|
|
|
|
2021-08-25 12:06:46 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
2023-09-15 12:06:47 +00:00
|
|
|
rev = "refs/tags/${version}";
|
2021-11-14 21:28:28 +00:00
|
|
|
# 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.
|
2023-12-02 23:02:08 +00:00
|
|
|
hash = "sha256-+gRv3Rim+2aL2uhPPGfVD0QDgB013lTf6wPx8rOwgXg=";
|
2022-05-17 19:10:33 +00:00
|
|
|
postFetch = "rm -rf $out/docs/reST";
|
2007-08-09 17:33:18 +00:00
|
|
|
};
|
|
|
|
|
2021-08-10 10:23:47 +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-24 12:56:54 +00:00
|
|
|
"${lib.getDev dep}/include/SDL2"
|
2021-08-10 10:23:47 +00:00
|
|
|
]) buildInputs);
|
|
|
|
buildinputs_lib = builtins.toJSON (builtins.concatMap (dep: [
|
|
|
|
"${lib.getLib dep}/"
|
|
|
|
"${lib.getLib dep}/lib"
|
|
|
|
]) buildInputs);
|
|
|
|
})
|
2024-03-05 00:27:17 +00:00
|
|
|
# Skip tests that should be disabled without video driver
|
|
|
|
./skip-surface-tests.patch
|
2021-08-10 10:23:47 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace src_py/sysfont.py \
|
2024-03-05 00:27:17 +00:00
|
|
|
--replace-fail 'path="fc-list"' 'path="${fontconfig}/bin/fc-list"' \
|
|
|
|
--replace-fail /usr/X11/bin/fc-list ${fontconfig}/bin/fc-list
|
2021-08-10 10:23:47 +00:00
|
|
|
'';
|
|
|
|
|
2019-02-20 19:27:31 +00:00
|
|
|
nativeBuildInputs = [
|
2023-12-02 23:02:08 +00:00
|
|
|
cython_3
|
|
|
|
pkg-config
|
|
|
|
SDL2
|
|
|
|
setuptools
|
2019-02-20 19:27:31 +00:00
|
|
|
];
|
|
|
|
|
2013-06-09 04:12:15 +00:00
|
|
|
buildInputs = [
|
2023-12-02 23:02:08 +00:00
|
|
|
freetype
|
|
|
|
libjpeg
|
|
|
|
libpng
|
|
|
|
libX11
|
|
|
|
portmidi
|
|
|
|
SDL2
|
|
|
|
SDL2_image
|
|
|
|
SDL2_mixer
|
|
|
|
SDL2_ttf
|
2021-08-10 10:23:47 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
2021-08-25 12:06:46 +00:00
|
|
|
AppKit
|
2013-06-09 04:12:15 +00:00
|
|
|
];
|
|
|
|
|
2016-05-23 01:35:07 +00:00
|
|
|
preConfigure = ''
|
2023-11-06 01:38:24 +00:00
|
|
|
${python.pythonOnBuildForHost.interpreter} buildconfig/config.py
|
2008-10-06 22:07:53 +00:00
|
|
|
'';
|
2007-08-09 17:33:18 +00:00
|
|
|
|
2023-11-10 02:03:57 +00:00
|
|
|
env = lib.optionalAttrs stdenv.cc.isClang {
|
|
|
|
NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-function-pointer-types";
|
|
|
|
};
|
|
|
|
|
2021-08-10 10:23:47 +00:00
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
2021-07-22 11:13:26 +00:00
|
|
|
|
|
|
|
# No audio or video device in test environment
|
|
|
|
export SDL_VIDEODRIVER=dummy
|
|
|
|
export SDL_AUDIODRIVER=disk
|
2021-08-10 10:23:47 +00:00
|
|
|
|
|
|
|
${python.interpreter} -m pygame.tests -v --exclude opengl,timing --time_out 300
|
|
|
|
|
|
|
|
runHook postCheck
|
2021-07-22 11:13:26 +00:00
|
|
|
'';
|
2021-08-10 10:23:47 +00:00
|
|
|
pythonImportsCheck = [ "pygame" ];
|
2021-07-22 11:13:26 +00: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 11:13:26 +00:00
|
|
|
homepage = "https://www.pygame.org/";
|
2016-05-23 01:35:07 +00:00
|
|
|
license = licenses.lgpl21Plus;
|
2022-02-11 04:45:03 +00:00
|
|
|
maintainers = with maintainers; [ emilytrau ];
|
2021-08-10 10:23:47 +00:00
|
|
|
platforms = platforms.unix;
|
2007-08-09 17:33:18 +00:00
|
|
|
};
|
|
|
|
}
|