1{
2 stdenv,
3 lib,
4 buildPythonPackage,
5 fetchFromGitHub,
6 fetchpatch,
7 keyring,
8 pytestCheckHook,
9 setuptools,
10 writableTmpDirAsHomeHook,
11}:
12
13buildPythonPackage rec {
14 pname = "plyer";
15 version = "2.1.0";
16 pyproject = true;
17
18 src = fetchFromGitHub {
19 owner = "kivy";
20 repo = "plyer";
21 tag = version;
22 sha256 = "sha256-7Icb2MVj5Uit86lRHxal6b7y9gIJ3UT2HNqpA9DYWVE=";
23 };
24
25 patches = [
26 # Fix compatibility with Python 3.13
27 (fetchpatch {
28 name = "0001-plyer-Use-unittest-mock.patch";
29 url = "https://github.com/kivy/plyer/commit/c9e73f395e2b51d46ada68119abfae2973591c00.patch";
30 hash = "sha256-rWak2GOGnsw+GhEtdob9h1c39aa6Z1yU7vH9kdGjHO0=";
31 })
32 (fetchpatch {
33 name = "0002-plyer-Remove-whitespace-error-during-self.assertEqual-function-call.patch";
34 url = "https://github.com/kivy/plyer/commit/8393c61dfd3a7aa0362d3bf530ba9ca052878c1a.patch";
35 hash = "sha256-omjpQJQ+vZ6T12vL6LvKOuRSihiHfLdEZ1pDat8VuiM=";
36 })
37 (fetchpatch {
38 name = "0003-plyer-Replace obj.__doc__-with-getdoc-obj-to-automatically-remove-new-lines.patch";
39 url = "https://github.com/kivy/plyer/commit/675750f31e9f98cd5de2df732afe34648f343d3e.patch";
40 hash = "sha256-Lb7MbbcIjwbfnR8U6t9j0c+bqU7kK3/xEt13pSF8G6M=";
41 })
42 (fetchpatch {
43 name = "0004-plyer-Remove-newline-and-indentation-comparisons-during-self.assertEqual-function-call.patch";
44 url = "https://github.com/kivy/plyer/commit/31e96f689771cd43f0a925463a59fcbc49f58e46.patch";
45 hash = "sha256-ZYYftI4w+21Q6oKm1wku7NJg3xfkIpkjN+PvZY0YjyY=";
46 })
47 ];
48
49 postPatch = ''
50 # remove all the wifi stuff. Depends on a python wifi module that has not been updated since 2016
51 find -iname "wifi*" -exec rm {} \;
52 substituteInPlace plyer/__init__.py \
53 --replace-fail "wifi = Proxy('wifi', facades.Wifi)" "" \
54 --replace-fail "'wifi', " ""
55 substituteInPlace plyer/facades/__init__.py \
56 --replace-fail "from plyer.facades.wifi import Wifi" ""
57 '';
58
59 build-system = [
60 setuptools
61 ];
62
63 propagatedBuildInputs = [ keyring ];
64
65 nativeCheckInputs = [
66 pytestCheckHook
67 writableTmpDirAsHomeHook
68 ];
69
70 enabledTestPaths = [ "plyer/tests" ];
71 disabledTests = [
72 # assumes dbus is not installed, it fails and is not very robust.
73 "test_notification_notifysend"
74 # fails during nix-build, but I am not able to explain why.
75 # The test and the API under test do work outside the nix build.
76 "test_uniqueid"
77 ];
78
79 preCheck = ''
80 mkdir -p $HOME/.config/ $HOME/Pictures
81 '';
82
83 pythonImportsCheck = [ "plyer" ];
84
85 meta = {
86 broken = stdenv.hostPlatform.isDarwin;
87 description = "Plyer is a platform-independent api to use features commonly found on various platforms";
88 homepage = "https://github.com/kivy/plyer";
89 license = lib.licenses.mit;
90 teams = [
91 lib.teams.ngi
92 ];
93 };
94}