1{ lib
2, buildPythonPackage
3, fetchPypi
4, cffi
5, pytestCheckHook
6, pyserial
7, fetchpatch
8}:
9
10buildPythonPackage rec {
11 pname = "smbus-cffi";
12 version = "0.5.1";
13
14 src = fetchPypi {
15 inherit pname version;
16 sha256 = "fb4195aaabfc01586863f60d3190b5cb1bf8f12622fd597e23e48768dad6bde8";
17 };
18
19 patches = [
20 # https://github.com/bivab/smbus-cffi/pull/24
21 (fetchpatch {
22 url = "https://github.com/bivab/smbus-cffi/commit/ba79ae174a9d84e767d95f165c43ee212b1bbb92.patch";
23 sha256 = "sha256-WtRuK5y6fWDEhm0Xy5XqS5yCkn7vXXYtjlOjS90gla4=";
24 })
25 ];
26
27 propagatedBuildInputs = [ cffi ];
28
29 installCheckPhase = ''
30 # we want to import the installed module that also contains the compiled library
31 rm -rf smbus
32 runHook pytestCheckPhase
33 '';
34
35 # requires hardware access
36 pytestFlagsArray = [ "--ignore=test/test_smbus_integration.py" ];
37
38 checkInputs = [ pytestCheckHook pyserial ];
39
40 meta = with lib; {
41 description = "Python module for SMBus access through Linux I2C /dev interface";
42 homepage = "https://github.com/bivab/smbus-cffi";
43 license = licenses.gpl2;
44 maintainers = with maintainers; [ mic92 ];
45 platforms = platforms.linux;
46 };
47}