From 420827d7deb30a802d18bbaa95314320ff9cd159 Mon Sep 17 00:00:00 2001 From: Leandro Reina Date: Sat, 10 Feb 2024 14:26:17 +0100 Subject: [PATCH] python312Packages.pycyphal: 1.15.4 -> 1.18.0 Also fixed the extra dependencies and the check phase --- .../python-modules/pycyphal/default.nix | 74 ++++++++++++++++--- pkgs/top-level/python-packages.nix | 12 +-- 2 files changed, 63 insertions(+), 23 deletions(-) diff --git a/pkgs/development/python-modules/pycyphal/default.nix b/pkgs/development/python-modules/pycyphal/default.nix index fa95336d3b3f..9067a3f06ad5 100644 --- a/pkgs/development/python-modules/pycyphal/default.nix +++ b/pkgs/development/python-modules/pycyphal/default.nix @@ -1,6 +1,6 @@ { lib , buildPythonPackage -, fetchPypi +, fetchFromGitHub , pythonOlder , can , cobs @@ -8,31 +8,80 @@ , nunavut , numpy , pyserial +, pytestCheckHook +, pytest-asyncio +, setuptools }: buildPythonPackage rec { pname = "pycyphal"; - version = "1.15.4"; - format = "pyproject"; + version = "1.18.0"; + format = "setuptools"; disabled = pythonOlder "3.8"; - src = fetchPypi { - inherit pname version; - hash = "sha256-0Mp8d/rNOOPLg0gUPWdOgp/d5n148dxcLceW1VtjrkQ="; + src = fetchFromGitHub { + owner = "OpenCyphal"; + repo = pname; + rev = "refs/tags/${version}"; + hash = "sha256-XkH0wss8ueh/Wwz0lhvQShOp3a4X9lNdosT/sMe7p4Q="; + fetchSubmodules = true; }; propagatedBuildInputs = [ - can - cobs - libpcap numpy nunavut - pyserial ]; - # Can't seem to run the tests on nix - doCheck = false; + passthru.optional-dependencies = { + transport-can-pythoncan = [ + can + ] ++ can.optional-dependencies.serial; + transport-serial = [ + cobs + pyserial + ]; + transport-udp = [ + libpcap + ]; + }; + + nativeCheckInputs = [ + pytestCheckHook + pytest-asyncio + ] ++ builtins.foldl' (x: y: x ++ y) [ ] + (builtins.attrValues passthru.optional-dependencies) + ; + + preCheck = '' + export HOME=$TMPDIR + export PYTHONASYNCIODEBUG=1 + python -c ${lib.escapeShellArg '' + import pycyphal + pycyphal.dsdl.compile_all( + [ + "demo/public_regulated_data_types/uavcan", + "demo/custom_data_types/sirius_cyber_corp", + ], + output_directory=".dsdl_compiled", + ) + ''} + export PYTHONPATH="$(pwd)/.dsdl_compiled:$PYTHONPATH" + ''; + + # These require extra permissions and/or actual hardware connected + disabledTestPaths = [ + "pycyphal/application/__init__.py" + "pycyphal/application/_transport_factory.py" + "pycyphal/transport/udp/_ip/_link_layer.py" + "pycyphal/transport/udp/_ip/_v4.py" + "tests/application" + "tests/demo" + "tests/dsdl" + "tests/presentation" + "tests/transport" + ]; + pythonImportsCheck = [ "pycyphal" ]; @@ -43,6 +92,7 @@ buildPythonPackage rec { Cyphal is an open technology for real-time intravehicular distributed computing and communication based on modern networking standards (Ethernet, CAN FD, etc.). ''; homepage = "https://opencyphal.org/"; + changelog = "https://github.com/OpenCyphal/pycyphal/blob/${version}/CHANGELOG.rst"; license = licenses.mit; maintainers = teams.ororatech.members; }; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 0d830f5dc02a..88edb0a7fffe 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -10309,17 +10309,7 @@ self: super: with self; { pycxx = callPackage ../development/python-modules/pycxx { }; - pycyphal = callPackage ../development/python-modules/pycyphal { - # Does not yet support nunavut 2+, use latest 1.X version instead - # https://github.com/OpenCyphal/pycyphal/issues/277 - nunavut = self.nunavut.overridePythonAttrs (prev: rec { - version = "1.9.0"; - src = prev.src.override { - inherit version; - hash = "sha256-KhgijXJ908uxM7VZdXo1WU/RGU0cfqctBCbpF2wOcy8="; - }; - }); - }; + pycyphal = callPackage ../development/python-modules/pycyphal { }; pydaikin = callPackage ../development/python-modules/pydaikin { };