evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / development / python-modules / pygame / default.nix
blob4c035988ae4bb977851590e2faf246bf0ba23f1a
2   stdenv,
3   lib,
4   substituteAll,
5   fetchpatch,
6   fetchFromGitHub,
7   buildPythonPackage,
8   pythonOlder,
10   # build-system
11   cython,
12   setuptools,
13   pkg-config,
15   # native dependencies
16   AppKit,
17   fontconfig,
18   freetype,
19   libjpeg,
20   libpng,
21   libX11,
22   portmidi,
23   SDL2,
24   SDL2_image,
25   SDL2_mixer,
26   SDL2_ttf,
28   # tests
29   python,
32 buildPythonPackage rec {
33   pname = "pygame";
34   version = "2.6.0";
35   pyproject = true;
37   disabled = pythonOlder "3.6";
39   src = fetchFromGitHub {
40     owner = pname;
41     repo = pname;
42     rev = "refs/tags/${version}";
43     # Unicode file names lead to different checksums on HFS+ vs. other
44     # filesystems because of unicode normalisation. The documentation
45     # has such files and will be removed.
46     hash = "sha256-wNXcmH0IIuAOoomIdmhAPxe4TiEzes3Kq+Vth2r4/IA=";
47     postFetch = "rm -rf $out/docs/reST";
48   };
50   patches = [
51     # Patch pygame's dependency resolution to let it find build inputs
52     (substituteAll {
53       src = ./fix-dependency-finding.patch;
54       buildinputs_include = builtins.toJSON (
55         builtins.concatMap (dep: [
56           "${lib.getDev dep}/"
57           "${lib.getDev dep}/include"
58           "${lib.getDev dep}/include/SDL2"
59         ]) buildInputs
60       );
61       buildinputs_lib = builtins.toJSON (
62         builtins.concatMap (dep: [
63           "${lib.getLib dep}/"
64           "${lib.getLib dep}/lib"
65         ]) buildInputs
66       );
67     })
69     # mixer queue test returns busy queue when it shouldn't
70     ./skip-mixer-test.patch
71   ];
73   postPatch = ''
74     substituteInPlace src_py/sysfont.py \
75       --replace-fail 'path="fc-list"' 'path="${fontconfig}/bin/fc-list"' \
76       --replace-fail /usr/X11/bin/fc-list ${fontconfig}/bin/fc-list
77   '';
79   nativeBuildInputs = [
80     cython
81     pkg-config
82     SDL2
83     setuptools
84   ];
86   buildInputs = [
87     freetype
88     libjpeg
89     libpng
90     libX11
91     portmidi
92     SDL2
93     SDL2_image
94     SDL2_mixer
95     SDL2_ttf
96   ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ AppKit ];
98   preConfigure = ''
99     ${python.pythonOnBuildForHost.interpreter} buildconfig/config.py
100   '';
102   env = lib.optionalAttrs stdenv.cc.isClang {
103     NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-function-pointer-types";
104   };
106   checkPhase = ''
107     runHook preCheck
109     # No audio or video device in test environment
110     export SDL_VIDEODRIVER=dummy
111     export SDL_AUDIODRIVER=disk
113     ${python.interpreter} -m pygame.tests -v --exclude opengl,timing --time_out 300
115     runHook postCheck
116   '';
117   pythonImportsCheck = [ "pygame" ];
119   meta = with lib; {
120     description = "Python library for games";
121     homepage = "https://www.pygame.org/";
122     license = licenses.lgpl21Plus;
123     maintainers = with maintainers; [ emilytrau ];
124     platforms = platforms.unix;
125   };