summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/w1thermsensor/default.nix
blob: f4868058e57027e401fe2d8c6ce26003a978c339 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
  lib,
  buildPythonPackage,
  fetchPypi,
  setuptools,
  aiofiles,
  click,
  tomli,
  pytest-mock,
  pytest-asyncio,
  pytestCheckHook,
  pythonOlder,
}:

buildPythonPackage rec {
  pname = "w1thermsensor";
  version = "2.3.0";
  pyproject = true;

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-n7wK4N1mzZtUxtYu17qyuI4UjJh/59UGD0dvkOgcInA=";
  };

  postPatch = ''
    sed -i 's/3\.5\.\*/3.5/' setup.py
  '';

  nativeBuildInputs = [ setuptools ];

  propagatedBuildInputs = [ click ];

  optional-dependencies = {
    async = [ aiofiles ];
  };

  # Don't try to load the kernel module in tests.
  env.W1THERMSENSOR_NO_KERNEL_MODULE = 1;

  nativeCheckInputs = [
    pytest-mock
    pytest-asyncio
    pytestCheckHook
  ]
  ++ lib.optionals (pythonOlder "3.11") [ tomli ]
  ++ lib.concatAttrValues optional-dependencies;

  pythonImportsCheck = [ "w1thermsensor" ];

  meta = {
    description = "Python interface to 1-Wire temperature sensors";
    mainProgram = "w1thermsensor";
    longDescription = ''
      A Python package and CLI tool to work with w1 temperature sensors like
      DS1822, DS18S20 & DS18B20 on the Raspberry Pi, Beagle Bone and other
      devices.
    '';
    homepage = "https://github.com/timofurrer/w1thermsensor";
    changelog = "https://github.com/timofurrer/w1thermsensor/blob/v${version}/CHANGELOG.rst";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ quentin ];
    platforms = lib.platforms.all;
  };
}