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