From e2283652588f41d66540cd963e8445ef8ff79be2 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sat, 19 Sep 2020 16:26:21 +0200 Subject: [PATCH] pythonPackages.yq: repackage as library, convert to application, fix tests --- .../{tools => python-modules}/yq/default.nix | 27 +++++++++++++------ pkgs/top-level/all-packages.nix | 5 +--- pkgs/top-level/python-packages.nix | 2 ++ 3 files changed, 22 insertions(+), 12 deletions(-) rename pkgs/development/{tools => python-modules}/yq/default.nix (66%) diff --git a/pkgs/development/tools/yq/default.nix b/pkgs/development/python-modules/yq/default.nix similarity index 66% rename from pkgs/development/tools/yq/default.nix rename to pkgs/development/python-modules/yq/default.nix index cfca8a32f93..3640023b10f 100644 --- a/pkgs/development/tools/yq/default.nix +++ b/pkgs/development/python-modules/yq/default.nix @@ -1,6 +1,7 @@ { lib -, buildPythonApplication +, buildPythonPackage , fetchPypi +, pkgs , argcomplete , pyyaml , xmltodict @@ -12,11 +13,24 @@ , toml }: -buildPythonApplication rec { +buildPythonPackage rec { pname = "yq"; version = "2.10.1"; - propagatedBuildInputs = [ pyyaml xmltodict jq argcomplete ]; + src = fetchPypi { + inherit pname version; + sha256 = "1h6nnkp53mm4spwy8nyxwvh9j6p4lxvf20j4bgjskhnhaw3jl9gn"; + }; + + postPatch = '' + substituteInPlace test/test.py --replace "expect_exit_codes={0} if sys.stdin.isatty() else {2}" "expect_exit_codes={0}" + ''; + + propagatedBuildInputs = [ + pyyaml + xmltodict + argcomplete + ]; doCheck = true; @@ -24,16 +38,13 @@ buildPythonApplication rec { pytest coverage flake8 - jq + pkgs.jq toml ]; checkPhase = "pytest ./test/test.py"; - src = fetchPypi { - inherit pname version; - sha256 = "1h6nnkp53mm4spwy8nyxwvh9j6p4lxvf20j4bgjskhnhaw3jl9gn"; - }; + pythonImportsCheck = [ "yq" ]; meta = with lib; { description = "Command-line YAML processor - jq wrapper for YAML documents."; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f636f0fd894..5f7b750c9a1 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11798,10 +11798,7 @@ in yodl = callPackage ../development/tools/misc/yodl { }; - yq = callPackage ../development/tools/yq { - inherit (python3Packages) - buildPythonApplication fetchPypi argcomplete pyyaml xmltodict pytest coverage flake8 toml; - }; + yq = python3.pkgs.toPythonApplication python3.pkgs.yq; yq-go = callPackage ../development/tools/yq-go { }; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index c2c471d9772..86e2faa238e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7614,6 +7614,8 @@ in { yowsup = callPackage ../development/python-modules/yowsup { }; + yq = callPackage ../development/python-modules/yq { }; + yt = callPackage ../development/python-modules/yt { }; yubico-client = callPackage ../development/python-modules/yubico-client { };