From 44c0690eb767726a73a26ed04f00f678bfb7b192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Mon, 14 Jul 2025 13:58:10 -0700 Subject: [PATCH 1/2] python3Packages.rclone-python: hardcode path to rclone executable --- .../python-modules/rclone-python/default.nix | 8 +- .../rclone-python/hardcode-rclone-path.patch | 99 +++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/python-modules/rclone-python/hardcode-rclone-path.patch diff --git a/pkgs/development/python-modules/rclone-python/default.nix b/pkgs/development/python-modules/rclone-python/default.nix index 1b6be818b936..01ac0b3c4b7a 100644 --- a/pkgs/development/python-modules/rclone-python/default.nix +++ b/pkgs/development/python-modules/rclone-python/default.nix @@ -2,6 +2,7 @@ lib, buildPythonPackage, fetchFromGitHub, + replaceVars, setuptools, rich, rclone, @@ -19,10 +20,15 @@ buildPythonPackage rec { hash = "sha256-vvsiXS3uI0TcL+X8+75BQmycrF+EGIgQE1dmGef35rI="; }; + patches = [ + (replaceVars ./hardcode-rclone-path.patch { + rclone = lib.getExe rclone; + }) + ]; + build-system = [ setuptools ]; dependencies = [ - rclone rich ]; diff --git a/pkgs/development/python-modules/rclone-python/hardcode-rclone-path.patch b/pkgs/development/python-modules/rclone-python/hardcode-rclone-path.patch new file mode 100644 index 000000000000..5edd6e24b9e6 --- /dev/null +++ b/pkgs/development/python-modules/rclone-python/hardcode-rclone-path.patch @@ -0,0 +1,99 @@ +diff --git a/rclone_python/rclone.py b/rclone_python/rclone.py +index da399b4..e05365a 100644 +--- a/rclone_python/rclone.py ++++ b/rclone_python/rclone.py +@@ -43,7 +43,7 @@ def is_installed() -> bool: + """ + :return: True if rclone is correctly installed on the system. + """ +- return which("rclone") is not None ++ return True + + + @__check_installed +@@ -199,7 +199,7 @@ def copy( + in_path, + out_path, + ignore_existing=ignore_existing, +- command="rclone copy", ++ command="@rclone@ copy", + command_descr="Copying", + show_progress=show_progress, + listener=listener, +@@ -234,7 +234,7 @@ def copyto( + in_path, + out_path, + ignore_existing=ignore_existing, +- command="rclone copyto", ++ command="@rclone@ copyto", + command_descr="Copying", + show_progress=show_progress, + listener=listener, +@@ -269,7 +269,7 @@ def move( + in_path, + out_path, + ignore_existing=ignore_existing, +- command="rclone move", ++ command="@rclone@ move", + command_descr="Moving", + show_progress=show_progress, + listener=listener, +@@ -304,7 +304,7 @@ def moveto( + in_path, + out_path, + ignore_existing=ignore_existing, +- command="rclone moveto", ++ command="@rclone@ moveto", + command_descr="Moving", + show_progress=show_progress, + listener=listener, +@@ -336,7 +336,7 @@ def sync( + _rclone_transfer_operation( + src_path, + dest_path, +- command="rclone sync", ++ command="@rclone@ sync", + command_descr="Syncing", + show_progress=show_progress, + listener=listener, +diff --git a/rclone_python/scripts/get_version.py b/rclone_python/scripts/get_version.py +index b1d30fd..bc00cad 100644 +--- a/rclone_python/scripts/get_version.py ++++ b/rclone_python/scripts/get_version.py +@@ -2,6 +2,6 @@ from subprocess import check_output + + + def get_version(): +- stdout = check_output("rclone version", shell=True, encoding="utf8") ++ stdout = check_output("@rclone@ version", shell=True, encoding="utf8") + + return stdout.split("\n")[0].replace("rclone ", "") +diff --git a/rclone_python/scripts/update_hash_types.py b/rclone_python/scripts/update_hash_types.py +index 92fbd0a..ef963cf 100644 +--- a/rclone_python/scripts/update_hash_types.py ++++ b/rclone_python/scripts/update_hash_types.py +@@ -14,7 +14,7 @@ def update_hashes(output_path: str): + """ + + # get all supported backends +- rclone_output = sp.check_output("rclone hashsum", shell=True, encoding="utf8") ++ rclone_output = sp.check_output("@rclone@ hashsum", shell=True, encoding="utf8") + lines = rclone_output.splitlines() + + hashes = [] +diff --git a/rclone_python/utils.py b/rclone_python/utils.py +index d4a8413..1b29bd8 100644 +--- a/rclone_python/utils.py ++++ b/rclone_python/utils.py +@@ -66,9 +66,9 @@ def run_rclone_cmd( + # otherwise the default rclone config path is used: + config = Config() + if config.config_path is not None: +- base_command = f"rclone --config={config.config_path}" ++ base_command = f"@rclone@ --config={config.config_path}" + else: +- base_command = "rclone" ++ base_command = "@rclone@" + + # add optional arguments and flags to the command + args_str = args2string(args) From e6dce4ad3e4966ad89b57539cbc26a4b89f619b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Mon, 14 Jul 2025 14:29:54 -0700 Subject: [PATCH 2/2] python3Packages.rclone-python: run tests --- .../python-modules/rclone-python/default.nix | 26 ++++++++++++++-- .../rclone-python/hardcode-rclone-path.patch | 30 +++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/rclone-python/default.nix b/pkgs/development/python-modules/rclone-python/default.nix index 01ac0b3c4b7a..b4469d714dbc 100644 --- a/pkgs/development/python-modules/rclone-python/default.nix +++ b/pkgs/development/python-modules/rclone-python/default.nix @@ -2,10 +2,12 @@ lib, buildPythonPackage, fetchFromGitHub, + pytestCheckHook, replaceVars, setuptools, rich, rclone, + writableTmpDirAsHomeHook, }: buildPythonPackage rec { @@ -32,8 +34,28 @@ buildPythonPackage rec { rich ]; - # tests require working internet connection - doCheck = false; + nativeCheckInputs = [ + pytestCheckHook + writableTmpDirAsHomeHook + ]; + + preCheck = '' + # Unlike upstream we don't actually run an S3 server for testing. + # See https://github.com/Johannes11833/rclone_python/blob/master/launch_test_server.sh + mkdir -p "$HOME/.config/rclone" + cat > "$HOME/.config/rclone/rclone.conf" <