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 support for --find-links in pip-compile input #704

Closed
wants to merge 1 commit into from
Closed
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
27 changes: 15 additions & 12 deletions piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,6 @@ def cli(verbose, dry_run, pre, rebuild, find_links, index_url, extra_index_url,
if is_pinned_requirement(ireq) and key_from_req(ireq.req) not in upgrade_install_reqs}
repository = LocalRequirementsRepository(existing_pins, repository)

log.debug('Using indexes:')
# remove duplicate index urls before processing
repository.finder.index_urls = list(dedup(repository.finder.index_urls))
for index_url in repository.finder.index_urls:
log.debug(' {}'.format(index_url))

if repository.finder.find_links:
log.debug('')
log.debug('Configuration:')
for find_link in repository.finder.find_links:
log.debug(' -f {}'.format(find_link))

###
# Parsing/collecting initial requirements
###
Expand Down Expand Up @@ -187,6 +175,20 @@ def cli(verbose, dry_run, pre, rebuild, find_links, index_url, extra_index_url,
constraints = [req for req in constraints
if req.markers is None or req.markers.evaluate()]

log.debug('Using indexes:')
# remove duplicate index urls before processing
repository.finder.index_urls = list(dedup(repository.finder.index_urls))
for index_url in repository.finder.index_urls:
log.debug(' {}'.format(index_url))

# remove duplicate find links before processing
repository.finder.find_links = list(dedup(repository.finder.find_links))
if repository.finder.find_links:
log.debug('')
log.debug('Configuration:')
for find_link in repository.finder.find_links:
log.debug(' -f {}'.format(find_link))

# Check the given base set of constraints first
Resolver.check_constraints(constraints)

Expand Down Expand Up @@ -240,6 +242,7 @@ def cli(verbose, dry_run, pre, rebuild, find_links, index_url, extra_index_url,
generate_hashes=generate_hashes,
default_index_url=repository.DEFAULT_INDEX_URL,
index_urls=repository.finder.index_urls,
find_links=repository.finder.find_links,
trusted_hosts=pip_options.trusted_hosts,
format_control=repository.finder.format_control)
writer.write(results=results,
Expand Down
9 changes: 8 additions & 1 deletion piptools/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
class OutputWriter(object):
def __init__(self, src_files, dst_file, dry_run, emit_header, emit_index,
emit_trusted_host, annotate, generate_hashes,
default_index_url, index_urls, trusted_hosts, format_control):
default_index_url, index_urls, find_links, trusted_hosts,
format_control):
self.src_files = src_files
self.dst_file = dst_file
self.dry_run = dry_run
Expand All @@ -22,6 +23,7 @@ def __init__(self, src_files, dst_file, dry_run, emit_header, emit_index,
self.generate_hashes = generate_hashes
self.default_index_url = default_index_url
self.index_urls = index_urls
self.find_links = find_links
self.trusted_hosts = trusted_hosts
self.format_control = format_control

Expand Down Expand Up @@ -60,6 +62,10 @@ def write_index_options(self):
flag = '--index-url' if index == 0 else '--extra-index-url'
yield '{} {}'.format(flag, index_url)

def write_find_links(self):
for find_link in self.find_links:
yield '--find-links {}'.format(find_link)

def write_trusted_hosts(self):
if self.emit_trusted_host:
for trusted_host in dedup(self.trusted_hosts):
Expand All @@ -74,6 +80,7 @@ def write_format_controls(self):
def write_flags(self):
emitted = False
for line in chain(self.write_index_options(),
self.write_find_links(),
self.write_trusted_hosts(),
self.write_format_controls()):
emitted = True
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ def test_find_links_option(pip_conf):

runner = CliRunner()
with runner.isolated_filesystem():
with open('requirements.in', 'w'):
pass
with open('requirements.in', 'w') as in_req:
in_req.write('-f ./libs3')
out = runner.invoke(cli, ['-v', '-f', './libs1', '-f', './libs2'])

# Check that find-links has been passed to pip
assert 'Configuration:\n -f ./libs1\n -f ./libs2' in out.output
assert 'Configuration:\n -f ./libs1\n -f ./libs2\n -f ./libs3' in out.output


def test_extra_index_option(pip_conf):
Expand Down
1 change: 1 addition & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def writer():
annotate=True,
generate_hashes=False,
default_index_url=None, index_urls=[],
find_links=[],
trusted_hosts=[],
format_control=FormatControl(set(), set()))

Expand Down