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