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