Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --no-emit-find-links option (fixes #848) #873

Merged
merged 2 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 7 additions & 0 deletions tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ 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