From ea7eb6f52ace3708455e050ce50ca649d38ae28e Mon Sep 17 00:00:00 2001 From: Martin Joerg Date: Tue, 9 Jul 2024 22:22:55 +0000 Subject: [PATCH 1/5] python311Packages.magic-wormhole-mailbox-server: add setuptools as dependency pkg_resources from setuptools is referenced at runtime. Use meta.broken instead of disabled in order to make magic-wormhole usable with Python 3.12. --- .../magic-wormhole-mailbox-server/default.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/development/python-modules/magic-wormhole-mailbox-server/default.nix b/pkgs/development/python-modules/magic-wormhole-mailbox-server/default.nix index af4cb08de9e0..f43cf4c4afee 100644 --- a/pkgs/development/python-modules/magic-wormhole-mailbox-server/default.nix +++ b/pkgs/development/python-modules/magic-wormhole-mailbox-server/default.nix @@ -21,9 +21,6 @@ buildPythonPackage rec { version = "0.4.1"; pyproject = true; - # python 3.12 support: https://github.com/magic-wormhole/magic-wormhole-mailbox-server/issues/41 - disabled = pythonOlder "3.7" || pythonAtLeast "3.12"; - src = fetchPypi { inherit pname version; hash = "sha256-GvEFkpCcqvUZwA5wbqyELF53+NQ1YhX+nGHHsiWKiPs="; @@ -38,13 +35,14 @@ buildPythonPackage rec { }) ]; - nativeBuildInputs = [ setuptools ]; + build-system = [ setuptools ]; - propagatedBuildInputs = [ + dependencies = [ attrs + autobahn + setuptools # pkg_resources is referenced at runtime six twisted - autobahn ] ++ autobahn.optional-dependencies.twisted ++ twisted.optional-dependencies.tls; pythonImportsCheck = [ "wormhole_mailbox_server" ]; @@ -66,5 +64,7 @@ buildPythonPackage rec { changelog = "https://github.com/magic-wormhole/magic-wormhole-mailbox-server/blob/${version}/NEWS.md"; license = lib.licenses.mit; maintainers = [ lib.maintainers.mjoerg ]; + # Python 3.12 support: https://github.com/magic-wormhole/magic-wormhole-mailbox-server/issues/41 + broken = pythonOlder "3.7" || pythonAtLeast "3.12"; }; } From a147c86f2e07bc272497356d126c820f9aed7406 Mon Sep 17 00:00:00 2001 From: Martin Joerg Date: Tue, 9 Jul 2024 22:22:55 +0000 Subject: [PATCH 2/5] python311Packages.magic-wormhole-transit-relay: add setuptools as dependency pkg_resources from setuptools is referenced at runtime. Use meta.broken instead of disabled in order to make magic-wormhole usable with Python 3.12. --- .../magic-wormhole-transit-relay/default.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/magic-wormhole-transit-relay/default.nix b/pkgs/development/python-modules/magic-wormhole-transit-relay/default.nix index 39b7d93ce0f2..bf8b990fe0d9 100644 --- a/pkgs/development/python-modules/magic-wormhole-transit-relay/default.nix +++ b/pkgs/development/python-modules/magic-wormhole-transit-relay/default.nix @@ -16,17 +16,16 @@ buildPythonPackage rec { version = "0.2.1"; pyproject = true; - disabled = pythonOlder "3.7" || pythonAtLeast "3.12"; - src = fetchPypi { inherit pname version; hash = "sha256-y0gBtGiQ6v+XKG4OP+xi0dUv/jF9FACDtjNqH7To+l4="; }; - nativeBuildInputs = [ setuptools ]; + build-system = [ setuptools ]; - propagatedBuildInputs = [ + dependencies = [ autobahn + setuptools # pkg_resources is referenced at runtime twisted ]; @@ -38,11 +37,15 @@ buildPythonPackage rec { twisted ]; + __darwinAllowLocalNetworking = true; + meta = { description = "Transit Relay server for Magic-Wormhole"; homepage = "https://github.com/magic-wormhole/magic-wormhole-transit-relay"; changelog = "https://github.com/magic-wormhole/magic-wormhole-transit-relay/blob/${version}/NEWS.md"; license = lib.licenses.mit; maintainers = [ lib.maintainers.mjoerg ]; + # Python 3.12 support: https://github.com/magic-wormhole/magic-wormhole-transit-relay/issues/35 + broken = pythonOlder "3.7" || pythonAtLeast "3.12"; }; } From 9a039035ce0af64e601e83bf2f81fcbc0f4772a0 Mon Sep 17 00:00:00 2001 From: Martin Joerg Date: Tue, 9 Jul 2024 22:22:56 +0000 Subject: [PATCH 3/5] python312Packages.magic-wormhole: make usable with Python 3.12 Test dependencies magic-wormhole-mailbox-server and magic-wormhole-transit-relay are not yet supported with Python 3.12. When using Python 3.12, these dependencies and the related tests are removed. fixes #325854 --- .../python-modules/magic-wormhole/default.nix | 86 ++++++++++--------- 1 file changed, 44 insertions(+), 42 deletions(-) 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 From 12de9a746997db5ad5a9cc1b823bbb400e4e6012 Mon Sep 17 00:00:00 2001 From: Martin Joerg Date: Tue, 9 Jul 2024 22:22:56 +0000 Subject: [PATCH 4/5] nixos/magic-wormhole-mailbox-server: nixfmt --- .../networking/magic-wormhole-mailbox-server.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/networking/magic-wormhole-mailbox-server.nix b/nixos/modules/services/networking/magic-wormhole-mailbox-server.nix index 03210bca371c..2edd81045dde 100644 --- a/nixos/modules/services/networking/magic-wormhole-mailbox-server.nix +++ b/nixos/modules/services/networking/magic-wormhole-mailbox-server.nix @@ -1,11 +1,19 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: with lib; let cfg = config.services.magic-wormhole-mailbox-server; dataDir = "/var/lib/magic-wormhole-mailbox-server;"; - python = pkgs.python3.withPackages (py: [ py.magic-wormhole-mailbox-server py.twisted ]); + python = pkgs.python3.withPackages (py: [ + py.magic-wormhole-mailbox-server + py.twisted + ]); in { options.services.magic-wormhole-mailbox-server = { @@ -23,6 +31,5 @@ in StateDirectory = baseNameOf dataDir; }; }; - }; } From a85c31488245e22f42cb499c6d647e9f579a55ac Mon Sep 17 00:00:00 2001 From: Martin Joerg Date: Tue, 9 Jul 2024 22:22:56 +0000 Subject: [PATCH 5/5] nixos/magic-wormhole-mailbox-server: use Python 3.11, adopt magic-wormhole-mailbox-server is not yet supported with Python 3.12. https://github.com/magic-wormhole/magic-wormhole-mailbox-server/issues/41 --- .../magic-wormhole-mailbox-server.nix | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/networking/magic-wormhole-mailbox-server.nix b/nixos/modules/services/networking/magic-wormhole-mailbox-server.nix index 2edd81045dde..5b700269037c 100644 --- a/nixos/modules/services/networking/magic-wormhole-mailbox-server.nix +++ b/nixos/modules/services/networking/magic-wormhole-mailbox-server.nix @@ -5,22 +5,23 @@ ... }: -with lib; - let cfg = config.services.magic-wormhole-mailbox-server; + # keep semicolon in dataDir for backward compatibility dataDir = "/var/lib/magic-wormhole-mailbox-server;"; - python = pkgs.python3.withPackages (py: [ - py.magic-wormhole-mailbox-server - py.twisted - ]); + python = pkgs.python311.withPackages ( + py: with py; [ + magic-wormhole-mailbox-server + twisted + ] + ); in { options.services.magic-wormhole-mailbox-server = { - enable = mkEnableOption "Magic Wormhole Mailbox Server"; + enable = lib.mkEnableOption "Magic Wormhole Mailbox Server"; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.magic-wormhole-mailbox-server = { after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; @@ -32,4 +33,6 @@ in }; }; }; + + meta.maintainers = [ lib.maintainers.mjoerg ]; }