Skip to content

Commit

Permalink
Pass cache_dir to pip_args for backtracking resolver (#1827)
Browse files Browse the repository at this point in the history
  • Loading branch information
q0w committed Apr 4, 2023
1 parent 33128f5 commit d931833
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

0 comments on commit d931833

Please sign in to comment.