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