Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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, typing-extensions
14, wrapt
15, uptime
16}:
17
18buildPythonPackage rec {
19 pname = "can";
20 version = "4.1.0";
21 format = "setuptools";
22
23 disabled = pythonOlder "3.7";
24
25 src = fetchFromGitHub {
26 owner = "hardbyte";
27 repo = "python-can";
28 rev = "refs/tags/v${version}";
29 hash = "sha256-jNy47SapujTF3ReJtIbwUY53IftIH4cXZjkzHrnZMFQ=";
30 };
31
32 postPatch = ''
33 substituteInPlace tox.ini \
34 --replace " --cov=can --cov-config=tox.ini --cov-report=lcov --cov-report=term" ""
35 '';
36
37 propagatedBuildInputs = [
38 msgpack
39 packaging
40 typing-extensions
41 wrapt
42 ];
43
44 passthru.optional-dependencies = {
45 serial = [
46 pyserial
47 ];
48 seeedstudio = [
49 pyserial
50 ];
51 pcan = [
52 uptime
53 ];
54 };
55
56 checkInputs = [
57 future
58 hypothesis
59 parameterized
60 pytest-timeout
61 pytestCheckHook
62 ] ++ passthru.optional-dependencies.serial;
63
64 disabledTestPaths = [
65 # We don't support all interfaces
66 "test/test_interface_canalystii.py"
67 ];
68
69 disabledTests = [
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
78 preCheck = ''
79 export PATH="$PATH:$out/bin";
80 '';
81
82 pythonImportsCheck = [
83 "can"
84 ];
85
86 meta = with lib; {
87 description = "CAN support for Python";
88 homepage = "https://python-can.readthedocs.io";
89 changelog = "https://github.com/hardbyte/python-can/releases/tag/v${version}";
90 license = licenses.lgpl3Only;
91 maintainers = with maintainers; [ fab sorki ];
92 };
93}