1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, future
5, hypothesis
6, packaging
7, parameterized
8, msgpack
9, pyserial
10, pytest-timeout
11, pytestCheckHook
12, pythonOlder
13, setuptools
14, stdenv
15, typing-extensions
16, wrapt
17, uptime
18}:
19
20buildPythonPackage rec {
21 pname = "can";
22 version = "4.2.2";
23 format = "setuptools";
24
25 disabled = pythonOlder "3.7";
26
27 src = fetchFromGitHub {
28 owner = "hardbyte";
29 repo = "python-can";
30 rev = "refs/tags/v${version}";
31 hash = "sha256-MyVGjAy13Ne0PkVufB0JDNEZHhVBzeUYWWlH72ib/pI=";
32 };
33
34 postPatch = ''
35 substituteInPlace tox.ini \
36 --replace " --cov=can --cov-config=tox.ini --cov-report=lcov --cov-report=term" ""
37 '';
38
39 propagatedBuildInputs = [
40 msgpack
41 packaging
42 setuptools
43 typing-extensions
44 wrapt
45 ];
46
47 passthru.optional-dependencies = {
48 serial = [
49 pyserial
50 ];
51 seeedstudio = [
52 pyserial
53 ];
54 pcan = [
55 uptime
56 ];
57 };
58
59 nativeCheckInputs = [
60 future
61 hypothesis
62 parameterized
63 pytest-timeout
64 pytestCheckHook
65 ] ++ passthru.optional-dependencies.serial;
66
67 disabledTestPaths = [
68 # We don't support all interfaces
69 "test/test_interface_canalystii.py"
70 ];
71
72 disabledTests = [
73 # Tests require access socket
74 "BasicTestUdpMulticastBusIPv4"
75 "BasicTestUdpMulticastBusIPv6"
76 # pytest.approx is not supported in a boolean context (since pytest7)
77 "test_pack_unpack"
78 "test_receive"
79 ] ++ lib.optionals stdenv.isDarwin [
80 # timing sensitive
81 "test_general"
82 "test_gap"
83 ];
84
85 preCheck = ''
86 export PATH="$PATH:$out/bin";
87 # skips timing senstive tests
88 export CI=1
89 '';
90
91 pythonImportsCheck = [
92 "can"
93 ];
94
95 meta = with lib; {
96 description = "CAN support for Python";
97 homepage = "https://python-can.readthedocs.io";
98 changelog = "https://github.com/hardbyte/python-can/releases/tag/v${version}";
99 license = licenses.lgpl3Only;
100 maintainers = with maintainers; [ fab sorki ];
101 };
102}