1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 async-timeout,
12 bellows,
13 click,
14 coloredlogs,
15 crc,
16 libgpiod,
17 pyserial-asyncio-fast,
18 typing-extensions,
19 zigpy,
20
21 # tests
22 pytestCheckHook,
23 pytest-asyncio,
24 pytest-mock,
25 pytest-timeout,
26}:
27
28buildPythonPackage rec {
29 pname = "universal-silabs-flasher";
30 version = "0.0.25";
31 pyproject = true;
32
33 src = fetchFromGitHub {
34 owner = "NabuCasa";
35 repo = "universal-silabs-flasher";
36 rev = "refs/tags/v${version}";
37 hash = "sha256-fmm5QrRpZIYmPO4GK/JrP7w0Utlw52pfh524pgESliM=";
38 };
39
40 postPatch = ''
41 substituteInPlace pyproject.toml \
42 --replace-fail '"setuptools-git-versioning<2"' "" \
43 --replace-fail 'dynamic = ["version"]' 'version = "${version}"'
44 '';
45
46 build-system = [ setuptools ];
47
48 pythonRelaxDeps = [
49 # https://github.com/NabuCasa/universal-silabs-flasher/pull/50
50 "gpiod"
51 ];
52
53 propagatedBuildInputs = [
54 async-timeout
55 bellows
56 click
57 coloredlogs
58 crc
59 pyserial-asyncio-fast
60 typing-extensions
61 zigpy
62 ] ++ lib.optionals (stdenv.hostPlatform.isLinux) [ libgpiod ];
63
64 nativeCheckInputs = [
65 pytestCheckHook
66 pytest-asyncio
67 pytest-mock
68 pytest-timeout
69 ];
70
71 pythonImportsCheck = [ "universal_silabs_flasher" ];
72
73 meta = with lib; {
74 changelog = "https://github.com/NabuCasa/universal-silabs-flasher/releases/tag/v${version}";
75 description = "Flashes Silicon Labs radios running EmberZNet or CPC multi-pan firmware";
76 mainProgram = "universal-silabs-flasher";
77 homepage = "https://github.com/NabuCasa/universal-silabs-flasher";
78 license = licenses.gpl3Only;
79 maintainers = with maintainers; [ hexa ];
80 };
81}