1{
2 lib,
3 async-timeout,
4 bluez,
5 buildPythonPackage,
6 dbus-fast,
7 fetchFromGitHub,
8 poetry-core,
9 pytest-asyncio,
10 pytestCheckHook,
11 pythonOlder,
12 typing-extensions,
13}:
14
15buildPythonPackage rec {
16 pname = "bleak";
17 version = "1.1.1";
18 pyproject = true;
19
20 disabled = pythonOlder "3.9";
21
22 src = fetchFromGitHub {
23 owner = "hbldh";
24 repo = "bleak";
25 tag = "v${version}";
26 hash = "sha256-z0Mxr1pUQWNEK01PKMV/CzpW+GeCRcv/+9BADts1FuU=";
27 };
28
29 postPatch = ''
30 # bleak checks BlueZ's version with a call to `bluetoothctl --version`
31 substituteInPlace bleak/backends/bluezdbus/version.py \
32 --replace-fail \"bluetoothctl\" \"${bluez}/bin/bluetoothctl\"
33 '';
34
35 build-system = [ poetry-core ];
36
37 dependencies = [
38 dbus-fast
39 typing-extensions
40 ]
41 ++ lib.optionals (pythonOlder "3.11") [
42 async-timeout
43 ];
44
45 nativeCheckInputs = [
46 pytest-asyncio
47 pytestCheckHook
48 ];
49
50 pythonImportsCheck = [ "bleak" ];
51
52 meta = with lib; {
53 description = "Bluetooth Low Energy platform agnostic client";
54 homepage = "https://github.com/hbldh/bleak";
55 changelog = "https://github.com/hbldh/bleak/blob/${src.tag}/CHANGELOG.rst";
56 license = licenses.mit;
57 platforms = platforms.linux;
58 maintainers = with maintainers; [ oxzi ];
59 };
60}