1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 pkgs,
6 setuptools,
7 aiofiles,
8 click,
9 coverage,
10 tomli,
11 pytest,
12 pytest-mock,
13 pytest-asyncio,
14 pytestCheckHook,
15 pythonOlder,
16}:
17
18buildPythonPackage rec {
19 pname = "w1thermsensor";
20 version = "2.3.0";
21 pyproject = true;
22
23 disabled = pythonOlder "3.7";
24
25 src = fetchPypi {
26 inherit pname version;
27 hash = "sha256-n7wK4N1mzZtUxtYu17qyuI4UjJh/59UGD0dvkOgcInA=";
28 };
29
30 postPatch = ''
31 sed -i 's/3\.5\.\*/3.5/' setup.py
32 '';
33
34 nativeBuildInputs = [ setuptools ];
35
36 propagatedBuildInputs = [ click ];
37
38 passthru.optional-dependencies = {
39 async = [ aiofiles ];
40 };
41
42 # Don't try to load the kernel module in tests.
43 env.W1THERMSENSOR_NO_KERNEL_MODULE = 1;
44
45 nativeCheckInputs =
46 [
47 pytest-mock
48 pytest-asyncio
49 pytestCheckHook
50 ]
51 ++ lib.optionals (pythonOlder "3.11") [ tomli ]
52 ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
53
54 pythonImportsCheck = [ "w1thermsensor" ];
55
56 meta = with lib; {
57 description = "Python interface to 1-Wire temperature sensors";
58 mainProgram = "w1thermsensor";
59 longDescription = ''
60 A Python package and CLI tool to work with w1 temperature sensors like
61 DS1822, DS18S20 & DS18B20 on the Raspberry Pi, Beagle Bone and other
62 devices.
63 '';
64 homepage = "https://github.com/timofurrer/w1thermsensor";
65 changelog = "https://github.com/timofurrer/w1thermsensor/blob/v${version}/CHANGELOG.rst";
66 license = licenses.mit;
67 maintainers = with maintainers; [ quentin ];
68 platforms = platforms.all;
69 };
70}