at master 2.6 kB view raw
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.24.5"; 27 pyproject = true; 28 29 src = fetchFromGitHub { 30 owner = "OpenCyphal"; 31 repo = "pycyphal"; 32 tag = version; 33 hash = "sha256-yrGKmJW4W8bPazKHWkwgNWDPiQYg1KTEuI7hC3yOWek="; 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 ] 59 ++ builtins.foldl' (x: y: x ++ y) [ ] (builtins.attrValues optional-dependencies); 60 61 preCheck = '' 62 export HOME=$TMPDIR 63 export PYTHONASYNCIODEBUG=1 64 python -c ${lib.escapeShellArg '' 65 import pycyphal 66 pycyphal.dsdl.compile_all( 67 [ 68 "demo/public_regulated_data_types/uavcan", 69 "demo/custom_data_types/sirius_cyber_corp", 70 ], 71 output_directory=".dsdl_compiled", 72 ) 73 ''} 74 export PYTHONPATH="$(pwd)/.dsdl_compiled:$PYTHONPATH" 75 ''; 76 77 # These require extra permissions and/or actual hardware connected 78 disabledTestPaths = [ 79 "pycyphal/application/__init__.py" 80 "pycyphal/application/_transport_factory.py" 81 "pycyphal/application/register/backend/dynamic.py" 82 "pycyphal/application/register/backend/static.py" 83 "pycyphal/transport/udp" 84 "tests/application" 85 "tests/demo" 86 "tests/dsdl" 87 "tests/presentation" 88 "tests/transport" 89 # These are flaky -- test against string representations of values 90 "pycyphal/application/register/_registry.py" 91 "pycyphal/application/register/_value.py" 92 ]; 93 94 pythonImportsCheck = [ "pycyphal" ]; 95 96 meta = with lib; { 97 description = "Full-featured implementation of the Cyphal protocol stack in Python"; 98 longDescription = '' 99 Cyphal is an open technology for real-time intravehicular distributed computing and communication based on modern networking standards (Ethernet, CAN FD, etc.). 100 ''; 101 homepage = "https://opencyphal.org/"; 102 changelog = "https://github.com/OpenCyphal/pycyphal/blob/${version}/CHANGELOG.rst"; 103 license = licenses.mit; 104 teams = [ teams.ororatech ]; 105 }; 106}