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