From 3e4bef3e25d830d7b7968514bfa96ee802f478cb Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Thu, 2 Jul 2026 10:45:07 +0200 Subject: [PATCH] python3Packages.swi-tools: init at 1.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 泥鰍 <165534185+Holiu618@users.noreply.github.com> --- .../python-modules/swi-tools/default.nix | 71 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 73 insertions(+) create mode 100644 pkgs/development/python-modules/swi-tools/default.nix diff --git a/pkgs/development/python-modules/swi-tools/default.nix b/pkgs/development/python-modules/swi-tools/default.nix new file mode 100644 index 000000000000..79ce794c8a56 --- /dev/null +++ b/pkgs/development/python-modules/swi-tools/default.nix @@ -0,0 +1,71 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + pytestCheckHook, + versionCheckHook, + hatchling, + cryptography, + jsonschema, + pyparsing, + pyyaml, + typer, + zip, +}: + +buildPythonPackage (finalAttrs: { + pname = "swi-tools"; + version = "1.6"; + pyproject = true; + + src = fetchFromGitHub { + owner = "aristanetworks"; + repo = "swi-tools"; + # master branch is at 1.6, they don't have a v1.6 branch/tag + rev = "6db86f5983426d272e541a61e0add79b3fec5b1e"; + hash = "sha256-enWxDrTFWxJCwHF8NjH2UvZ/cxJnldF5nxm+Xzmu4xY="; + }; + + build-system = [ + hatchling + ]; + + dependencies = [ + cryptography + jsonschema + pyparsing + pyyaml + typer + zip + ]; + + # verify.py uses importlib.resources.files(__name__) but __name__ is + # "switools.verify" (a module, not a package). The cert lives in the + # "switools" package directory, so we need to reference that instead. + postPatch = '' + substituteInPlace src/switools/verify.py \ + --replace-fail 'import importlib' 'import importlib, importlib.resources' \ + --replace-fail 'importlib.resources.files(__name__)' 'importlib.resources.files("switools")' + ''; + + # Importing verify triggers the importlib.resources cert load, + # so this catches the exact bug we patched above. + pythonImportsCheck = [ + "switools" + "switools.verify" + ]; + + nativeCheckInputs = [ + pytestCheckHook + zip + versionCheckHook + ]; + + meta = { + description = "Scripts for operating on an Arista SWI or SWIX"; + homepage = "https://github.com/aristanetworks/swi-tools"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ jherland ]; + mainProgram = "swi-tools"; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 9033e7b92583..993914e67dce 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -19455,6 +19455,8 @@ self: super: with self; { swh-web-client = callPackage ../development/python-modules/swh-web-client { }; + swi-tools = callPackage ../development/python-modules/swi-tools { }; + swift = callPackage ../development/python-modules/swift { }; swifter = callPackage ../development/python-modules/swifter { };