Skip to content

Commit

Permalink
Add --no-emit-find-links option (fixes jazzband#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtolar committed Aug 13, 2019
1 parent 903931f commit d3eaefb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
8 changes: 8 additions & 0 deletions piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@
"Build dependencies specified by PEP 518 must be already installed "
"if build isolation is disabled.",
)
@click.option(
"--emit-find-links/--no-emit-find-links",
is_flag=True,
default=True,
help="Add the find-links option to generated file",
)
def cli(
ctx,
verbose,
Expand All @@ -188,6 +194,7 @@ def cli(
src_files,
max_rounds,
build_isolation,
emit_find_links,
):
"""Compiles requirements.txt from requirements.in specs."""
log.verbosity = verbose - quiet
Expand Down Expand Up @@ -400,6 +407,7 @@ def cli(
format_control=repository.finder.format_control,
allow_unsafe=allow_unsafe,
find_links=repository.finder.find_links,
emit_find_links=emit_find_links,
)
writer.write(
results=results,
Expand Down
7 changes: 5 additions & 2 deletions piptools/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(
format_control,
allow_unsafe,
find_links,
emit_find_links,
):
self.src_files = src_files
self.dst_file = dst_file
Expand All @@ -70,6 +71,7 @@ def __init__(
self.format_control = format_control
self.allow_unsafe = allow_unsafe
self.find_links = find_links
self.emit_find_links = emit_find_links

def _sort_key(self, ireq):
return (not ireq.editable, str(ireq.req).lower())
Expand Down Expand Up @@ -106,8 +108,9 @@ def write_format_controls(self):
yield "--only-binary {}".format(ob)

def write_find_links(self):
for find_link in dedup(self.find_links):
yield "--find-links {}".format(find_link)
if self.emit_find_links:
for find_link in dedup(self.find_links):
yield "--find-links {}".format(find_link)

def write_flags(self):
emitted = False
Expand Down
9 changes: 9 additions & 0 deletions tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ def test_trusted_host_no_emit(pip_conf, runner):
assert "--trusted-host example.com" not in out.stderr


def test_find_links_no_emit(pip_conf, runner):
with open("requirements.in", "w"):
pass
out = runner.invoke(
cli, ["-v", "--no-emit-find-links"]
)
assert "--find-links" not in out.stderr


def test_realistic_complex_sub_dependencies(runner):
wheels_dir = "wheels"

Expand Down
1 change: 1 addition & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def writer(tmpdir_cwd):
format_control=FormatControl(set(), set()),
allow_unsafe=False,
find_links=[],
emit_find_links=True,
)
yield writer

Expand Down

0 comments on commit d3eaefb

Please sign in to comment.