1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 6 # build system 7 setuptools, 8 9 # dependencies 10 numpy, 11 nunavut, 12 13 # optional dependencies 14 cobs, 15 libpcap, 16 pyserial, 17 python-can, 18 19 # tests 20 pytest-asyncio, 21 pytestCheckHook, 22}: 23 24buildPythonPackage rec { 25 pname = "pycyphal"; 26 version = "1.18.0"; 27 pyproject = true; 28 29 src = fetchFromGitHub { 30 owner = "OpenCyphal"; 31 repo = pname; 32 tag = version; 33 hash = "sha256-XkH0wss8ueh/Wwz0lhvQShOp3a4X9lNdosT/sMe7p4Q="; 34 fetchSubmodules = true; 35 }; 36 37 build-system = [ setuptools ]; 38 39 pythonRelaxDeps = [ "numpy" ]; 40 41 dependencies = [ 42 numpy 43 nunavut 44 ]; 45 46 optional-dependencies = { 47 transport-can-pythoncan = [ python-can ] ++ python-can.optional-dependencies.serial; 48 transport-serial = [ 49 cobs 50 pyserial 51 ]; 52 transport-udp = [ libpcap ]; 53 }; 54 55 nativeCheckInputs = [ 56 pytestCheckHook 57 pytest-asyncio 58 ] ++ builtins.foldl' (x: y: x ++ y) [ ] (builtins.attrValues optional-dependencies); 59 60 preCheck = '' 61 export HOME=$TMPDIR 62 export PYTHONASYNCIODEBUG=1 63 python -c ${lib.escapeShellArg '' 64 import pycyphal 65 pycyphal.dsdl.compile_all( 66 [ 67 "demo/public_regulated_data_types/uavcan", 68 "demo/custom_data_types/sirius_cyber_corp", 69 ], 70 output_directory=".dsdl_compiled", 71 ) 72 ''} 73 export PYTHONPATH="$(pwd)/.dsdl_compiled:$PYTHONPATH" 74 ''; 75 76 # These require extra permissions and/or actual hardware connected 77 disabledTestPaths = [ 78 "pycyphal/application/__init__.py" 79 "pycyphal/application/_transport_factory.py" 80 "pycyphal/application/register/backend/dynamic.py" 81 "pycyphal/application/register/backend/static.py" 82 "pycyphal/transport/udp" 83 "tests/application" 84 "tests/demo" 85 "tests/dsdl" 86 "tests/presentation" 87 "tests/transport" 88 # These are flaky -- test against string representations of values 89 "pycyphal/application/register/_registry.py" 90 "pycyphal/application/register/_value.py" 91 ]; 92 93 pythonImportsCheck = [ "pycyphal" ]; 94 95 meta = with lib; { 96 description = "Full-featured implementation of the Cyphal protocol stack in Python"; 97 longDescription = '' 98 Cyphal is an open technology for real-time intravehicular distributed computing and communication based on modern networking standards (Ethernet, CAN FD, etc.). 99 ''; 100 homepage = "https://opencyphal.org/"; 101 changelog = "https://github.com/OpenCyphal/pycyphal/blob/${version}/CHANGELOG.rst"; 102 license = licenses.mit; 103 teams = [ teams.ororatech ]; 104 }; 105}