summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pygame-sdl2/default.nix
blob: 7885db98e93fd32fad04b6d1770feaf0c4282bab (plain)
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
{
  buildPythonPackage,
  cython,
  fetchFromGitHub,
  lib,
  libjpeg,
  libpng,
  nix-update-script,
  SDL2,
  SDL2_image,
  SDL2_mixer,
  SDL2_ttf,
  setuptools,
}:

buildPythonPackage rec {
  pname = "pygame-sdl2";
  version = "8.5.2.26010301";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "renpy";
    repo = "pygame_sdl2";
    tag = "renpy-${version}";
    hash = "sha256-I4zk19aNfVZstkVDLkwI/TBXliGAqVmOjeQLbRFri8Y=";
  };

  build-system = [
    cython
    SDL2
    setuptools
  ];

  dependencies = [
    libjpeg
    libpng
    SDL2
    SDL2_image
    SDL2_mixer
    SDL2_ttf
  ];

  doCheck = true;

  postUnpack = ''
    substituteInPlace source/setup.py --replace-fail "2.1.0" "${version}"
    substituteInPlace source/src/pygame_sdl2/version.py --replace-fail "2, 1, 0" "${
      builtins.replaceStrings [ "." ] [ ", " ] version
    }"

    headers=$(mktemp -d)
    substituteInPlace source/setup.py --replace-fail \
      "pathlib.Path(sysconfig.get_paths()['include']) / \"pygame_sdl2\"" \
      "pathlib.Path(\"$headers\")"
  '';

  postInstall = ''
    install -Dm644 $headers/* -t $out/include/pygame_sdl2
  '';

  passthru.updateScript = nix-update-script { extraArgs = [ "--version-regex=renpy-(.*)" ]; };

  meta = {
    description = "Reimplementation of the Pygame API using SDL2 and related libraries";
    homepage = "https://github.com/renpy/pygame_sdl2";
    license = with lib.licenses; [
      lgpl2
      zlib
    ];
    platforms = lib.platforms.unix;
    maintainers = with lib.maintainers; [ raskin ];
  };
}