1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
{
stdenv,
lib,
substituteAll,
fetchFromGitHub,
buildPythonPackage,
pythonOlder,
python,
pkg-config,
setuptools,
cython,
ninja,
meson-python,
AppKit,
fontconfig,
freetype,
libjpeg,
libpng,
libX11,
portmidi,
SDL2,
SDL2_image,
SDL2_mixer,
SDL2_ttf,
numpy,
}:
buildPythonPackage rec {
pname = "pygame-ce";
version = "2.5.0";
pyproject = true;
disabled = pythonOlder "3.8";
src = fetchFromGitHub {
owner = "pygame-community";
repo = "pygame-ce";
rev = "refs/tags/${version}";
hash = "sha256-LVwOAp7ss8TPxJhfqGwOfH9EXNoNBGFpU+4tv4ozpvo=";
# Unicode file cause different checksums on HFS+ vs. other filesystems
postFetch = "rm -rf $out/docs/reST";
};
patches = [
(substituteAll {
src = ./fix-dependency-finding.patch;
buildinputs_include = builtins.toJSON (
builtins.concatMap (dep: [
"${lib.getDev dep}/"
"${lib.getDev dep}/include"
"${lib.getDev dep}/include/SDL2"
]) buildInputs
);
buildinputs_lib = builtins.toJSON (
builtins.concatMap (dep: [
"${lib.getLib dep}/"
"${lib.getLib dep}/lib"
]) buildInputs
);
})
# Skip tests that should be disabled without video driver
./skip-surface-tests.patch
];
postPatch =
''
substituteInPlace pyproject.toml \
--replace-fail ', "sphinx<=7.2.6"' ""
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.isDarwin ''
# flaky
rm test/system_test.py
'';
nativeBuildInputs = [
pkg-config
cython
setuptools
ninja
meson-python
];
buildInputs = [
freetype
libX11
libjpeg
libpng
portmidi
SDL2
SDL2_image
SDL2_mixer
SDL2_ttf
] ++ lib.optionals stdenv.isDarwin [ AppKit ];
nativeCheckInputs = [
numpy
];
preConfigure = ''
${python.pythonOnBuildForHost.interpreter} buildconfig/config.py
'';
env =
{
SDL_CONFIG = "${SDL2.dev}/bin/sdl2-config";
}
// lib.optionalAttrs stdenv.cc.isClang {
NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-function-pointer-types";
};
preCheck = ''
export HOME=$(mktemp -d)
# No audio or video device in test environment
export SDL_VIDEODRIVER=dummy
export SDL_AUDIODRIVER=disk
'';
checkPhase = ''
runHook preCheck
${python.interpreter} -m pygame.tests -v --exclude opengl,timing --time_out 300
runHook postCheck
'';
pythonImportsCheck = [
"pygame"
"pygame.camera"
"pygame.colordict"
"pygame.cursors"
"pygame.freetype"
"pygame.ftfont"
"pygame.locals"
"pygame.midi"
"pygame.pkgdata"
"pygame.sndarray" # requires numpy
"pygame.sprite"
"pygame.surfarray"
"pygame.sysfont"
"pygame.version"
];
meta = with lib; {
description = "Pygame Community Edition (CE) - library for multimedia application built on SDL";
homepage = "https://pyga.me/";
license = licenses.lgpl21Plus;
maintainers = with maintainers; [ pbsds ];
platforms = platforms.unix;
};
}
|