nixpkgs/pkgs/development/python-modules/pygame/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

122 lines
2.6 KiB
Nix
Raw Normal View History

2023-12-02 23:02:08 +00:00
{ stdenv
, lib
, substituteAll
, fetchFromGitHub
, buildPythonPackage
, pythonOlder
2023-12-02 23:02:08 +00:00
# build-system
, cython
2023-12-02 23:02:08 +00:00
, setuptools
, pkg-config
# native dependencies
, AppKit
, fontconfig
, freetype
, libjpeg
, libpng
, libX11
, portmidi
, SDL2
, SDL2_image
, SDL2_mixer
, SDL2_ttf
# tests
, python
}:
2016-05-23 01:35:07 +00:00
buildPythonPackage rec {
pname = "pygame";
2023-12-02 23:02:08 +00:00
version = "2.5.2";
pyproject = true;
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}";
# 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";
};
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"
"${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 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
'';
nativeBuildInputs = [
cython
2023-12-02 23:02:08 +00:00
pkg-config
SDL2
setuptools
];
buildInputs = [
2023-12-02 23:02:08 +00:00
freetype
libjpeg
libpng
libX11
portmidi
SDL2
SDL2_image
SDL2_mixer
SDL2_ttf
] ++ lib.optionals stdenv.isDarwin [
2021-08-25 12:06:46 +00:00
AppKit
];
2016-05-23 01:35:07 +00:00
preConfigure = ''
${python.pythonOnBuildForHost.interpreter} buildconfig/config.py
'';
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-function-pointer-types";
};
checkPhase = ''
runHook preCheck
# No audio or video device in test environment
export SDL_VIDEODRIVER=dummy
export SDL_AUDIODRIVER=disk
${python.interpreter} -m pygame.tests -v --exclude opengl,timing --time_out 300
runHook postCheck
'';
pythonImportsCheck = [ "pygame" ];
meta = with lib; {
description = "Python library for games";
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 ];
platforms = platforms.unix;
};
}