From d931833cc4cf22189b0c82219cc410842836339d Mon Sep 17 00:00:00 2001 From: q0w <43147888+q0w@users.noreply.github.com> Date: Tue, 4 Apr 2023 18:45:56 +0300 Subject: [PATCH] Pass cache_dir to pip_args for backtracking resolver (#1827) --- piptools/scripts/compile.py | 2 ++ tests/test_cli_compile.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/piptools/scripts/compile.py b/piptools/scripts/compile.py index f578140d1..4afcc20e0 100755 --- a/piptools/scripts/compile.py +++ b/piptools/scripts/compile.py @@ -424,6 +424,8 @@ def cli( pip_args.append("--no-build-isolation") if resolver_name == "legacy": pip_args.extend(["--use-deprecated", "legacy-resolver"]) + if resolver_name == "backtracking" and cache_dir: + pip_args.extend(["--cache-dir", cache_dir]) pip_args.extend(right_args) repository: BaseRepository diff --git a/tests/test_cli_compile.py b/tests/test_cli_compile.py index 693cff130..4c162adbf 100644 --- a/tests/test_cli_compile.py +++ b/tests/test_cli_compile.py @@ -2853,3 +2853,18 @@ def test_raise_error_when_input_and_output_filenames_are_matched( f"Error: input and output filenames must not be matched: {req_out_path}" ) assert expected_error in out.stderr.splitlines() + + +@pytest.mark.network +@backtracking_resolver_only +def test_pass_pip_cache_to_pip_args(tmpdir, runner, current_resolver): + cache_dir = tmpdir.mkdir("cache_dir") + + with open("requirements.in", "w") as fp: + fp.write("six==1.15.0") + + out = runner.invoke( + cli, ["--cache-dir", str(cache_dir), "--resolver", current_resolver] + ) + assert out.exit_code == 0 + assert os.listdir(os.path.join(str(cache_dir), "http"))