summary refs log tree commit diff
path: root/pkgs/development/python-modules/kivy/default.nix
blob: dd04b97010dda893ec2e5722ead373c6e36b3146 (plain) (blame)
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
{ lib, stdenv
, buildPythonPackage, fetchFromGitHub, fetchpatch
, pkg-config, cython, docutils
, kivy-garden
, mesa, mtdev, SDL2, SDL2_image, SDL2_ttf, SDL2_mixer
, Accelerate, ApplicationServices, AVFoundation, libcxx
, withGstreamer ? true
, gst_all_1
, pillow, requests, pygments
}:

buildPythonPackage rec {
  pname = "Kivy";
  version = "2.1.0";

  src = fetchFromGitHub {
    owner = "kivy";
    repo = "kivy";
    rev = version;
    hash = "sha256-k9LIiLtlHY6H1xfVylI/Xbm7R6pCpC5UHe8GWnCwEGA=";
  };

  patches = [
    # Fixes incompatible function pointer conversion errors with clang 16.
    # https://github.com/kivy/kivy/pull/8415
    (fetchpatch {
      url = "https://github.com/kivy/kivy/commit/a0ec8ff79fcbc1b82391132a89c8fc21ef1c5c55.patch";
      hash = "sha256-2Kpkx75uWPiEiEqkOxBKl3HENKUGVHbQV4haeI5Gl3A=";
    })
  ];

  nativeBuildInputs = [
    pkg-config
    cython
    docutils
  ];

  buildInputs = [
    SDL2
    SDL2_image
    SDL2_ttf
    SDL2_mixer
  ] ++ lib.optionals stdenv.isLinux [
    mesa
    mtdev
  ] ++ lib.optionals stdenv.isDarwin [
    Accelerate
    ApplicationServices
    AVFoundation
    libcxx
  ] ++ lib.optionals withGstreamer (with gst_all_1; [
    # NOTE: The degree to which gstreamer actually works is unclear
    gstreamer
    gst-plugins-base
    gst-plugins-good
    gst-plugins-bad
  ]);

  propagatedBuildInputs = [
    kivy-garden
    pillow
    pygments
    requests
  ];

  KIVY_NO_CONFIG = 1;
  KIVY_NO_ARGS = 1;
  KIVY_NO_FILELOG = 1;
  # prefer pkg-config over hardcoded framework paths
  USE_OSX_FRAMEWORKS = 0;
  # work around python distutils compiling C++ with $CC (see issue #26709)
  env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1";

  postPatch = lib.optionalString stdenv.isLinux ''
    substituteInPlace kivy/lib/mtdev.py \
      --replace "LoadLibrary('libmtdev.so.1')" "LoadLibrary('${mtdev}/lib/libmtdev.so.1')"
  '';

  /*
    We cannot run tests as Kivy tries to import itself before being fully
    installed.
  */
  doCheck = false;
  pythonImportsCheck = [ "kivy" ];

  meta = with lib; {
    description = "Library for rapid development of hardware-accelerated multitouch applications.";
    homepage = "https://pypi.python.org/pypi/kivy";
    license = licenses.mit;
    maintainers = with maintainers; [ risson ];
  };
}