diff --git a/pkgs/development/python-modules/magic-wormhole/default.nix b/pkgs/development/python-modules/magic-wormhole/default.nix index 528b71063274..90fc7a9a2cbd 100644 --- a/pkgs/development/python-modules/magic-wormhole/default.nix +++ b/pkgs/development/python-modules/magic-wormhole/default.nix @@ -44,20 +44,32 @@ buildPythonPackage rec { hash = "sha256-AG0jn4i/98N7wu/2CgBOJj+vklj3J5GS0Gugyc7WsIA="; }; - nativeBuildInputs = [ setuptools ]; + postPatch = + # enable tests by fixing the location of the wormhole binary + '' + substituteInPlace src/wormhole/test/test_cli.py --replace-fail \ + 'locations = procutils.which("wormhole")' \ + 'return "${placeholder "out"}/bin/wormhole"' + '' + # fix the location of the ifconfig binary + + lib.optionalString stdenv.isLinux '' + sed -i -e "s|'ifconfig'|'${nettools}/bin/ifconfig'|" src/wormhole/ipaddrs.py + ''; - propagatedBuildInputs = [ - spake2 - pynacl - six + build-system = [ setuptools ]; + + dependencies = [ attrs - twisted autobahn automat - tqdm click humanize iterable-io + pynacl + six + spake2 + tqdm + twisted txtorcon zipstream-ng ] ++ autobahn.optional-dependencies.twisted ++ twisted.optional-dependencies.tls; @@ -66,43 +78,33 @@ buildPythonPackage rec { dilation = [ noiseprotocol ]; }; - nativeCheckInputs = [ - mock - magic-wormhole-transit-relay - magic-wormhole-mailbox-server - pytestCheckHook - ] ++ passthru.optional-dependencies.dilation ++ lib.optionals stdenv.isDarwin [ unixtools.locale ]; + nativeCheckInputs = + # For Python 3.12, remove magic-wormhole-mailbox-server and magic-wormhole-transit-relay from test dependencies, + # which are not yet supported with this version. + lib.optionals (!magic-wormhole-mailbox-server.meta.broken) [ magic-wormhole-mailbox-server ] + ++ lib.optionals (!magic-wormhole-transit-relay.meta.broken) [ magic-wormhole-transit-relay ] + ++ [ + mock + pytestCheckHook + ] + ++ passthru.optional-dependencies.dilation + ++ lib.optionals stdenv.isDarwin [ unixtools.locale ]; - disabledTests = lib.optionals stdenv.isDarwin [ - # These tests doesn't work within Darwin's sandbox - "test_version" - "test_text" - "test_receiver" - "test_sender" - "test_sender_allocation" - "test_text_wrong_password" - "test_override" - "test_allocate_port" - "test_allocate_port_no_reuseaddr" - "test_ignore_localhost_hint" - "test_ignore_localhost_hint_orig" - "test_keep_only_localhost_hint" - "test_get_direct_hints" - "test_listener" - "test_success_direct" - "test_direct" - "test_relay" - ]; + __darwinAllowLocalNetworking = true; - disabledTestPaths = lib.optionals stdenv.isDarwin [ - # These tests doesn't work within Darwin's sandbox - "src/wormhole/test/test_xfer_util.py" - "src/wormhole/test/test_wormhole.py" - ]; - - postPatch = lib.optionalString stdenv.isLinux '' - sed -i -e "s|'ifconfig'|'${nettools}/bin/ifconfig'|" src/wormhole/ipaddrs.py - ''; + disabledTestPaths = + # For Python 3.12, remove the tests depending on magic-wormhole-mailbox-server and magic-wormhole-transit-relay, + # which are not yet supported with this version. + lib.optionals + (magic-wormhole-mailbox-server.meta.broken || magic-wormhole-transit-relay.meta.broken) + [ + "src/wormhole/test/dilate/test_full.py" + "src/wormhole/test/test_args.py" + "src/wormhole/test/test_cli.py" + "src/wormhole/test/test_wormhole.py" + "src/wormhole/test/test_xfer_util.py" + ] + ++ lib.optionals magic-wormhole-transit-relay.meta.broken [ "src/wormhole/test/test_transit.py" ]; postInstall = '' install -Dm644 docs/wormhole.1 $out/share/man/man1/wormhole.1