From 98c349019697cc3d2d065b12ce0b199f0d6219e4 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 14 Jan 2021 10:26:34 +0000 Subject: [PATCH] ydiff,gitAndTools.ydiff: unify We were packaging ydiff twice! In this patch, I've merged the two expressions into one, trying to take the best of each. ydiff (top-level) didn't support being used as a Python library, which is required by one other package (patroni), so I chose gitAndTools.ydiff as the starting point, then moved in the longDescription from the top-level one, as well as the code used to run the tests. While I was there, I fixed the tests, which were intended to be run by the top-level ydiff but actually were not, because unlike mkDerivation buildPythonApplication will not run `make test' by default. Also, top-level ydiff previously propagated less and patchutils, meaning they'd have been installed globally instead of just referenced by ydiff. gitAndTools.ydiff just did nothing. Both also expected to find git, hg, and svn in the environment, which was impure. So now all these programs are referenced by store path from ydiff, for purity. --- .../python-modules/ydiff/default.nix | 35 +++++++++++---- pkgs/development/tools/ydiff/default.nix | 45 ------------------- pkgs/top-level/all-packages.nix | 2 +- 3 files changed, 28 insertions(+), 54 deletions(-) delete mode 100644 pkgs/development/tools/ydiff/default.nix diff --git a/pkgs/development/python-modules/ydiff/default.nix b/pkgs/development/python-modules/ydiff/default.nix index 89b063f84be7..be935b1995c6 100644 --- a/pkgs/development/python-modules/ydiff/default.nix +++ b/pkgs/development/python-modules/ydiff/default.nix @@ -1,4 +1,6 @@ -{ lib, stdenv, buildPythonPackage, fetchPypi }: +{ stdenv, lib, buildPythonPackage, fetchPypi, docutils, pygments +, gitMinimal, mercurial, subversion, patchutils, less +}: buildPythonPackage rec { pname = "ydiff"; @@ -9,21 +11,38 @@ buildPythonPackage rec { sha256 = "f5430577ecd30974d766ee9b8333e06dc76a947b4aae36d39612a0787865a121"; }; - # test suite requires a multitude of other version control tooling - # currently only a single file, an import/usage should suffice + patchPhase = '' + substituteInPlace ydiff.py \ + --replace "['git'" "['${gitMinimal}/bin/git'" \ + --replace "['hg'" "['${mercurial}/bin/hg'" \ + --replace "['svn'" "['${subversion}/bin/svn'" \ + --replace "['filterdiff'" "['${patchutils}/bin/filterdiff'" \ + --replace "['less'" "['${less}/bin/less'" # doesn't support PAGER from env + substituteInPlace tests/test_ydiff.py \ + --replace /bin/rm rm \ + --replace /bin/sh sh + patchShebangs setup.py + patchShebangs tests/*.sh + ''; + + checkInputs = [ docutils pygments ]; + checkPhase = '' - $out/bin/ydiff --help + runHook preCheck + make doc-check reg # We don't want the linter or coverage check. + runHook postCheck ''; meta = with lib; { description = "View colored, incremental diff in workspace or from stdin with side by side and auto pager support (Was \"cdiff\")"; longDescription = '' - Term based tool to view colored, incremental diff in a Git/Mercurial/Svn - workspace or from stdin, with side by side (similar to diff -y) and auto - pager support + Term based tool to view colored, incremental diff in a version + controlled workspace (supports Git, Mercurial, Perforce and Svn + so far) or from stdin, with side by side (similar to diff -y) + and auto pager support. ''; homepage = "https://github.com/ymattw/ydiff"; license = licenses.bsd3; - maintainers = teams.deshaw.members; + maintainers = (with maintainers; [ leenaars ]) ++ teams.deshaw.members; }; } diff --git a/pkgs/development/tools/ydiff/default.nix b/pkgs/development/tools/ydiff/default.nix deleted file mode 100644 index 510808fc4127..000000000000 --- a/pkgs/development/tools/ydiff/default.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ stdenv, lib, pythonPackages, python3Packages, less, patchutils, git -, subversion, coreutils, which }: - -with pythonPackages; - -buildPythonApplication rec { - pname = "ydiff"; - version = "1.2"; - - src = fetchPypi { - inherit pname version; - sha256 = "f5430577ecd30974d766ee9b8333e06dc76a947b4aae36d39612a0787865a121"; - }; - - patchPhase = '' - substituteInPlace tests/test_ydiff.py \ - --replace /bin/rm ${coreutils}/bin/rm \ - --replace /bin/sh ${stdenv.shell} - substituteInPlace Makefile \ - --replace "pep8 --ignore" "# pep8 --ignore" \ - --replace "python3 \`which coverage\`" "${python3Packages.coverage}/bin/coverage3" \ - --replace /bin/sh ${stdenv.shell} \ - --replace tests/regression.sh "${stdenv.shell} tests/regression.sh" - patchShebangs tests/*.sh - ''; - - buildInputs = [ docutils pygments ]; - propagatedBuildInputs = [ less patchutils ]; - checkInputs = [ coverage coreutils git subversion which ]; - - checkTarget = if isPy3k then "test3" else "test"; - - meta = { - homepage = "https://github.com/ymattw/ydiff"; - description = "View colored, incremental diff in workspace or from stdin"; - longDescription = '' - Term based tool to view colored, incremental diff in a version - controlled workspace (supports Git, Mercurial, Perforce and Svn - so far) or from stdin, with side by side (similar to diff -y) - and auto pager support. - ''; - license = lib.licenses.bsd3; - maintainers = with lib.maintainers; [ leenaars ]; - }; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0d19db7332c4..9edaea14f432 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -25743,7 +25743,7 @@ in yate = callPackage ../applications/misc/yate { }; - ydiff = callPackage ../development/tools/ydiff { }; + inherit (gitAndTools) ydiff; yed = callPackage ../applications/graphics/yed {};