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 postPatch = ''
38 substituteInPlace pyproject.toml \
39 --replace-fail "setuptools~=69.2.0" "setuptools" \
40 --replace-fail "wheel~=0.44.0" "wheel" \
41 --replace-fail "cython>=0.29.1,<=3.0.11" "cython" \
42 --replace-fail "packaging~=24.0" packaging
43 ''
44 + lib.optionalString stdenv.hostPlatform.isLinux ''
45 substituteInPlace kivy/lib/mtdev.py \
46 --replace-fail "LoadLibrary('libmtdev.so.1')" "LoadLibrary('${mtdev}/lib/libmtdev.so.1')"
47 '';
48
49 build-system = [
50 setuptools
51 cython
52 ];
53
54 nativeBuildInputs = [
55 pkg-config
56 ];
57
58 buildInputs = [
59 SDL2
60 SDL2_image
61 SDL2_ttf
62 SDL2_mixer
63 ]
64 ++ lib.optionals stdenv.hostPlatform.isLinux [
65 libGL
66 libX11
67 mtdev
68 ]
69 ++ lib.optionals withGstreamer (
70 with gst_all_1;
71 [
72 # NOTE: The degree to which gstreamer actually works is unclear
73 gstreamer
74 gst-plugins-base
75 gst-plugins-good
76 gst-plugins-bad
77 ]
78 );
79
80 dependencies = [
81 kivy-garden
82 docutils
83 pygments
84 requests
85 filetype
86 ];
87
88 KIVY_NO_CONFIG = 1;
89 KIVY_NO_ARGS = 1;
90 KIVY_NO_FILELOG = 1;
91 # prefer pkg-config over hardcoded framework paths
92 USE_OSX_FRAMEWORKS = 0;
93 # work around python distutils compiling C++ with $CC (see issue #26709)
94 env.NIX_CFLAGS_COMPILE = toString (
95 lib.optionals stdenv.cc.isGNU [
96 "-Wno-error=incompatible-pointer-types"
97 ]
98 ++ lib.optionals stdenv.hostPlatform.isDarwin [
99 "-I${lib.getInclude stdenv.cc.libcxx}/include/c++/v1"
100 ]
101 );
102
103 /*
104 We cannot run tests as Kivy tries to import itself before being fully
105 installed.
106 */
107 doCheck = false;
108 pythonImportsCheck = [ "kivy" ];
109
110 meta = with lib; {
111 changelog = "https://github.com/kivy/kivy/releases/tag/${src.tag}";
112 description = "Library for rapid development of hardware-accelerated multitouch applications";
113 homepage = "https://github.com/kivy/kivy";
114 license = licenses.mit;
115 maintainers = with maintainers; [ risson ];
116 };
117}