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