1{ lib, stdenv
2, buildPythonPackage, fetchFromGitHub, fetchpatch
3, pkg-config, cython, docutils
4, kivy-garden
5, mesa, mtdev, SDL2, SDL2_image, SDL2_ttf, SDL2_mixer
6, Accelerate, ApplicationServices, AVFoundation, libcxx
7, withGstreamer ? true
8, gst_all_1
9, pillow, requests, pygments
10}:
11
12buildPythonPackage rec {
13 pname = "Kivy";
14 version = "2.1.0";
15
16 src = fetchFromGitHub {
17 owner = "kivy";
18 repo = "kivy";
19 rev = version;
20 hash = "sha256-k9LIiLtlHY6H1xfVylI/Xbm7R6pCpC5UHe8GWnCwEGA=";
21 };
22
23 patches = [
24 # Fixes incompatible function pointer conversion errors with clang 16.
25 # https://github.com/kivy/kivy/pull/8415
26 (fetchpatch {
27 url = "https://github.com/kivy/kivy/commit/a0ec8ff79fcbc1b82391132a89c8fc21ef1c5c55.patch";
28 hash = "sha256-2Kpkx75uWPiEiEqkOxBKl3HENKUGVHbQV4haeI5Gl3A=";
29 })
30 ];
31
32 nativeBuildInputs = [
33 pkg-config
34 cython
35 docutils
36 ];
37
38 buildInputs = [
39 SDL2
40 SDL2_image
41 SDL2_ttf
42 SDL2_mixer
43 ] ++ lib.optionals stdenv.isLinux [
44 mesa
45 mtdev
46 ] ++ lib.optionals stdenv.isDarwin [
47 Accelerate
48 ApplicationServices
49 AVFoundation
50 libcxx
51 ] ++ lib.optionals withGstreamer (with gst_all_1; [
52 # NOTE: The degree to which gstreamer actually works is unclear
53 gstreamer
54 gst-plugins-base
55 gst-plugins-good
56 gst-plugins-bad
57 ]);
58
59 propagatedBuildInputs = [
60 kivy-garden
61 pillow
62 pygments
63 requests
64 ];
65
66 KIVY_NO_CONFIG = 1;
67 KIVY_NO_ARGS = 1;
68 KIVY_NO_FILELOG = 1;
69 # prefer pkg-config over hardcoded framework paths
70 USE_OSX_FRAMEWORKS = 0;
71 # work around python distutils compiling C++ with $CC (see issue #26709)
72 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1";
73
74 postPatch = lib.optionalString stdenv.isLinux ''
75 substituteInPlace kivy/lib/mtdev.py \
76 --replace "LoadLibrary('libmtdev.so.1')" "LoadLibrary('${mtdev}/lib/libmtdev.so.1')"
77 '';
78
79 /*
80 We cannot run tests as Kivy tries to import itself before being fully
81 installed.
82 */
83 doCheck = false;
84 pythonImportsCheck = [ "kivy" ];
85
86 meta = with lib; {
87 description = "Library for rapid development of hardware-accelerated multitouch applications.";
88 homepage = "https://pypi.python.org/pypi/kivy";
89 license = licenses.mit;
90 maintainers = with maintainers; [ risson ];
91 };
92}