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, 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 nativeBuildInputs = [
24 pkg-config
25 cython
26 docutils
27 ];
28
29 buildInputs = [
30 SDL2
31 SDL2_image
32 SDL2_ttf
33 SDL2_mixer
34 ] ++ lib.optionals stdenv.isLinux [
35 mesa
36 mtdev
37 ] ++ lib.optionals stdenv.isDarwin [
38 ApplicationServices
39 AVFoundation
40 libcxx
41 ] ++ lib.optionals withGstreamer (with gst_all_1; [
42 # NOTE: The degree to which gstreamer actually works is unclear
43 gstreamer
44 gst-plugins-base
45 gst-plugins-good
46 gst-plugins-bad
47 ]);
48
49 propagatedBuildInputs = [
50 kivy-garden
51 pillow
52 pygments
53 requests
54 ];
55
56 KIVY_NO_CONFIG = 1;
57 KIVY_NO_ARGS = 1;
58 KIVY_NO_FILELOG = 1;
59 # prefer pkg-config over hardcoded framework paths
60 USE_OSX_FRAMEWORKS = 0;
61 # work around python distutils compiling C++ with $CC (see issue #26709)
62 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1";
63
64 postPatch = lib.optionalString stdenv.isLinux ''
65 substituteInPlace kivy/lib/mtdev.py \
66 --replace "LoadLibrary('libmtdev.so.1')" "LoadLibrary('${mtdev}/lib/libmtdev.so.1')"
67 '';
68
69 /*
70 We cannot run tests as Kivy tries to import itself before being fully
71 installed.
72 */
73 doCheck = false;
74 pythonImportsCheck = [ "kivy" ];
75
76 meta = with lib; {
77 description = "Library for rapid development of hardware-accelerated multitouch applications.";
78 homepage = "https://pypi.python.org/pypi/kivy";
79 license = licenses.mit;
80 maintainers = with maintainers; [ risson ];
81 };
82}