git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #103737 from ttuegel/yq-needs-jq

yq: fix path to jq

commitb5bf9da14d28952b2b88a4c51d556014e2d69397 authorThomas Tuegel <ttuegel@mailbox.org> dateSun 27 Dec 2020, 06:46 (6 years ago) parent1d6bc184074d4a
2 files changed+34−1
pkgs/development/python-modules/yq/default.nix+8−1 pkgs/development/python-modules/yq/jq-path.patch+26
pkgs/development/python-modules/yq/default.nix+8−1
@@ -2,6 +2,7 @@
22, nixosTests
33, buildPythonPackage
44, fetchPypi
5+, substituteAll
56, pkgs
67, argcomplete
78, pyyaml
@@ -23,6 +24,13 @@ buildPythonPackage rec {
2324 sha256 = "1q4rky0a6n4izmq7slb91a54g8swry1xrbfqxwc8lkd3hhvlxxkl";
2425 };
2526
27+ patches = [
28+ (substituteAll {
29+ src = ./jq-path.patch;
30+ jq = "${lib.getBin pkgs.jq}/bin/jq";
31+ })
32+ ];
33+
2634 postPatch = ''
2735 substituteInPlace test/test.py --replace "expect_exit_codes={0} if sys.stdin.isatty() else {2}" "expect_exit_codes={0}"
2836 '';
@@ -39,7 +47,6 @@ buildPythonPackage rec {
3947 pytest
4048 coverage
4149 flake8
42− pkgs.jq
4350 toml
4451 ];
4552
pkgs/development/python-modules/yq/jq-path.patchnew file+26
@@ -0,0 +1,26 @@
1+diff --git a/test/test.py b/test/test.py
2+index a81f41b..9e80f04 100755
3+--- a/test/test.py
4++++ b/test/test.py
5+@@ -112,7 +112,7 @@ class TestYq(unittest.TestCase):
6+ tf2.seek(0)
7+ self.assertEqual(self.run_yq("", ["-y", arg, tf.name, self.fd_path(tf2)]), '1\n...\n')
8+
9+- @unittest.skipIf(subprocess.check_output(["jq", "--version"]) < b"jq-1.6", "Test options introduced in jq 1.6")
10++ @unittest.skipIf(subprocess.check_output(["@jq@", "--version"]) < b"jq-1.6", "Test options introduced in jq 1.6")
11+ def test_jq16_arg_passthrough(self):
12+ self.assertEqual(self.run_yq("{}", ["--indentless", "-y", ".a=$ARGS.positional", "--args", "a", "b"]),
13+ "a:\n- a\n- b\n")
14+diff --git a/yq/__init__.py b/yq/__init__.py
15+index afeb42c..a0d7970 100755
16+--- a/yq/__init__.py
17++++ b/yq/__init__.py
18+@@ -146,7 +146,7 @@ def yq(input_streams=None, output_stream=None, input_format="yaml", output_forma
19+
20+ try:
21+ # Note: universal_newlines is just a way to induce subprocess to make stdin a text buffer and encode it for us
22+- jq = subprocess.Popen(["jq"] + list(jq_args),
23++ jq = subprocess.Popen(["@jq@"] + list(jq_args),
24+ stdin=subprocess.PIPE,
25+ stdout=subprocess.PIPE if converting_output else None,
26+ universal_newlines=True)