diff --git a/pkgs/development/python-modules/pycyphal/default.nix b/pkgs/development/python-modules/pycyphal/default.nix index 787f04c413c9..8fed197d2e4d 100644 --- a/pkgs/development/python-modules/pycyphal/default.nix +++ b/pkgs/development/python-modules/pycyphal/default.nix @@ -2,6 +2,7 @@ lib, buildPythonPackage, fetchFromGitHub, + pythonAtLeast, # build system setuptools, @@ -34,6 +35,9 @@ buildPythonPackage rec { fetchSubmodules = true; }; + # Set an event loop in the doctest helper; policy.get_event_loop no longer auto-creates one on 3.14. + patches = lib.optional (pythonAtLeast "3.14") ./python-3.14-asyncio-loop.patch; + build-system = [ setuptools ]; pythonRelaxDeps = [ "numpy" ]; diff --git a/pkgs/development/python-modules/pycyphal/python-3.14-asyncio-loop.patch b/pkgs/development/python-modules/pycyphal/python-3.14-asyncio-loop.patch new file mode 100644 index 000000000000..9bd4cb5b47e0 --- /dev/null +++ b/pkgs/development/python-modules/pycyphal/python-3.14-asyncio-loop.patch @@ -0,0 +1,10 @@ +--- a/tests/__init__.py ++++ b/tests/__init__.py +@@ -37,6 +37,7 @@ + This function shall be invoked per test, because the test suite undoes its effect before starting the next test. + """ + _logger.info("asyncio_allow_event_loop_access_from_top_level()") ++ asyncio.set_event_loop(asyncio.new_event_loop()) + + def swap(mod: Any, name: str, new: Any) -> None: + restore = _PATCH_RESTORE_PREFIX + name