1{ stdenv, lib, buildPythonPackage, fetchFromGitHub, fetchpatch, keyring, mock, pytestCheckHook }:
2
3buildPythonPackage rec {
4 pname = "plyer";
5 version = "2.1.0";
6
7 src = fetchFromGitHub {
8 owner = "kivy";
9 repo = pname;
10 rev = "refs/tags/${version}";
11 sha256 = "sha256-7Icb2MVj5Uit86lRHxal6b7y9gIJ3UT2HNqpA9DYWVE=";
12 };
13
14 postPatch = ''
15 rm -r examples
16 # remove all the wifi stuff. Depends on a python wifi module that has not been updated since 2016
17 find -iname "wifi*" -exec rm {} \;
18 substituteInPlace plyer/__init__.py \
19 --replace "wifi = Proxy('wifi', facades.Wifi)" "" \
20 --replace "'wifi', " ""
21 substituteInPlace plyer/facades/__init__.py \
22 --replace "from plyer.facades.wifi import Wifi" ""
23 '';
24
25 propagatedBuildInputs = [ keyring ];
26
27 nativeCheckInputs = [ mock pytestCheckHook ];
28
29 pytestFlagsArray = [ "plyer/tests" ];
30 disabledTests = [
31 # assumes dbus is not installed, it fails and is not very robust.
32 "test_notification_notifysend"
33 # fails during nix-build, but I am not able to explain why.
34 # The test and the API under test do work outside the nix build.
35 "test_uniqueid"
36 ];
37 preCheck = ''
38 HOME=$(mktemp -d)
39 mkdir -p $HOME/.config/ $HOME/Pictures
40 '';
41
42 pythonImportsCheck = [ "plyer" ];
43
44 meta = with lib; {
45 broken = stdenv.isDarwin;
46 description = "Plyer is a platform-independent api to use features commonly found on various platforms";
47 homepage = "https://github.com/kivy/plyer";
48 license = licenses.mit;
49 maintainers = with maintainers; [ rski ];
50 };
51}