From c1b7deab9f208626f5f2c48e8064033df66a7cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Wed, 20 Feb 2019 15:05:16 +0100 Subject: [PATCH] python.pkgs.git-annex-adapter: use patch to hardcode git-annex path --- .../git-annex-adapter/default.nix | 22 +++--- .../git-annex-adapter/git-annex-path.patch | 75 +++++++++++++++++++ 2 files changed, 86 insertions(+), 11 deletions(-) create mode 100644 pkgs/development/python-modules/git-annex-adapter/git-annex-path.patch diff --git a/pkgs/development/python-modules/git-annex-adapter/default.nix b/pkgs/development/python-modules/git-annex-adapter/default.nix index d8fc12b1c422..ec58825878ae 100644 --- a/pkgs/development/python-modules/git-annex-adapter/default.nix +++ b/pkgs/development/python-modules/git-annex-adapter/default.nix @@ -1,5 +1,5 @@ -{ stdenv, buildPythonPackage, isPy3k, fetchFromGitHub, fetchpatch -, utillinux, pygit2, gitMinimal, git-annex +{ stdenv, buildPythonPackage, isPy3k, fetchFromGitHub, substituteAll +, python, utillinux, pygit2, gitMinimal, git-annex }: buildPythonPackage rec { @@ -16,22 +16,22 @@ buildPythonPackage rec { sha256 = "146q1jhcfc7f96ajkhjffskkljk2xzivs5ih5clb8qx0sh7mj097"; }; - prePatch = '' - substituteInPlace git_annex_adapter/process.py \ - --replace "'git', 'annex'" "'${git-annex}/bin/git-annex'" \ - --replace "'git-annex'" "'${git-annex}/bin/git-annex'" - ''; + patches = [ + (substituteAll { + src = ./git-annex-path.patch; + gitAnnex = "${git-annex}/bin/git-annex"; + }) + ]; checkInputs = [ + gitMinimal utillinux # `rev` is needed in tests/test_process.py ]; - propagatedBuildInputs = [ pygit2 gitMinimal ]; - - buildInputs = [ git-annex ]; + propagatedBuildInputs = [ pygit2 ]; checkPhase = '' - python -m unittest + ${python.interpreter} -m unittest ''; meta = with stdenv.lib; { diff --git a/pkgs/development/python-modules/git-annex-adapter/git-annex-path.patch b/pkgs/development/python-modules/git-annex-adapter/git-annex-path.patch new file mode 100644 index 000000000000..8b1b854058b9 --- /dev/null +++ b/pkgs/development/python-modules/git-annex-adapter/git-annex-path.patch @@ -0,0 +1,75 @@ +diff --git a/git_annex_adapter/process.py b/git_annex_adapter/process.py +index 6ddb985..bbd0ab8 100644 +--- a/git_annex_adapter/process.py ++++ b/git_annex_adapter/process.py +@@ -389,7 +389,7 @@ class GitAnnexBatchProcess: + _procclass = Process + + def __init__(self, args, workdir): +- self.args = ('git', 'annex', *args) ++ self.args = ('@gitAnnex@', *args) + self.workdir = workdir + self._process = None + self._dead_process = None +@@ -586,7 +586,7 @@ class ProcessRunner: + class GitAnnexRunner(ProcessRunner): + """Helper class to run git-annex commands.""" + def __init__(self, args_prefix, workdir): +- args_prefix = ('git-annex', *args_prefix) ++ args_prefix = ('@gitAnnex@', *args_prefix) + super().__init__(args_prefix, workdir) + + def __call__(self, *args_suffix): +diff --git a/tests/test_process.py b/tests/test_process.py +index ed619bb..9335078 100644 +--- a/tests/test_process.py ++++ b/tests/test_process.py +@@ -181,7 +181,7 @@ class TestProcessOnEmptyAnnex(TempAnnexTestCase): + def test_process_annex_metadata_batch(self): + """Process should be able to read one line""" + with Process( +- ['git', 'annex', 'metadata', '--batch', '--json'], ++ ['@gitAnnex@', 'metadata', '--batch', '--json'], + str(self.tempdir), + ) as proc: + proc.writeline( +@@ -202,7 +202,7 @@ class TestProcessOnEmptyAnnex(TempAnnexTestCase): + def test_jsonprocess_annex_metadata_batch(self): + """JsonProcess should encode and decode properly""" + with JsonProcess( +- ['git', 'annex', 'metadata', '--batch', '--json'], ++ ['@gitAnnex@', 'metadata', '--batch', '--json'], + str(self.tempdir), + ) as proc: + obj = proc({'key':'SHA256E-s0--0'}) +@@ -218,7 +218,7 @@ class TestProcessOnEmptyAnnex(TempAnnexTestCase): + def test_process_annex_info_batch(self): + """Process should be able to read multiple lines""" + with Process( +- ['git', 'annex', 'info', '--batch'], ++ ['@gitAnnex@', 'info', '--batch'], + str(self.tempdir), + ) as proc: + proc.writeline('here') +diff --git a/tests/utils.py b/tests/utils.py +index 281ee3f..969aedc 100644 +--- a/tests/utils.py ++++ b/tests/utils.py +@@ -107,7 +107,7 @@ class TempAnnexTestCase(TempRepoTestCase): + # Have to uninit before cleaning directory, since git-annex + # marks its objects read-only so that they don't get deleted. + subprocess.run( +- ['git', 'annex', 'uninit'], ++ ['@gitAnnex@', 'uninit'], + cwd=self.repo.workdir, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, +@@ -122,7 +122,7 @@ class TempAnnexTestCase(TempRepoTestCase): + path.write_text(text) + + subprocess.run( +- ['git', 'annex', 'add', '--quiet', relpath], ++ ['@gitAnnex@', 'add', '--quiet', relpath], + cwd=self.repo.workdir, + check=True, + )