From 0c8745d813522a9e4d0826026952c0e7eaa93659 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 12 May 2016 10:03:42 +0200 Subject: [PATCH 1/5] Remove logging of lines to stdout Fixes https://github.com/nvie/pip-tools/issues/360. --- piptools/writer.py | 1 - 1 file changed, 1 deletion(-) diff --git a/piptools/writer.py b/piptools/writer.py index f78e6b1af..d475d763a 100644 --- a/piptools/writer.py +++ b/piptools/writer.py @@ -93,7 +93,6 @@ def write(self, results, reverse_dependencies, primary_packages): f = stack.enter_context(AtomicSaver(self.dst_file)) for line in self._iter_lines(results, reverse_dependencies, primary_packages): - log.info(line) if f: f.write(unstyle(line).encode('utf-8')) f.write(os.linesep.encode('utf-8')) From 51cb3e906f32c38387d62f4e84b0eb252a571913 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 12 May 2016 10:01:37 +0200 Subject: [PATCH 2/5] Support for --output-file - Fixes https://github.com/nvie/pip-tools/issues/275. --- piptools/writer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/piptools/writer.py b/piptools/writer.py index d475d763a..6058d4a1c 100644 --- a/piptools/writer.py +++ b/piptools/writer.py @@ -89,13 +89,15 @@ def _iter_lines(self, results, reverse_dependencies, primary_packages): def write(self, results, reverse_dependencies, primary_packages): with ExitStack() as stack: f = None - if not self.dry_run: + if not self.dry_run and self.dst_file != '-': f = stack.enter_context(AtomicSaver(self.dst_file)) for line in self._iter_lines(results, reverse_dependencies, primary_packages): if f: f.write(unstyle(line).encode('utf-8')) f.write(os.linesep.encode('utf-8')) + else: + print(line) def _format_requirement(self, ireq, reverse_dependencies, primary_packages, include_specifier=True): line = format_requirement(ireq, include_specifier=include_specifier) From 31cbab8407149895f04692927daf028ef39b7f33 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 12 May 2016 10:15:34 +0200 Subject: [PATCH 3/5] Use stdout for output file for stdin as input by default --- piptools/scripts/compile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/piptools/scripts/compile.py b/piptools/scripts/compile.py index 9b9480951..30f7cfcfc 100755 --- a/piptools/scripts/compile.py +++ b/piptools/scripts/compile.py @@ -67,7 +67,7 @@ def cli(verbose, dry_run, pre, rebuild, find_links, index_url, extra_index_url, if len(src_files) == 1 and src_files[0] == '-': if not output_file: - raise click.BadParameter('--output-file is required if input is from stdin') + output_file = '-' if len(src_files) > 1 and not output_file: raise click.BadParameter('--output-file is required if two or more input files are given.') From 1aa91b53946e244d8998f582af003970ed8ace9e Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 12 May 2016 10:16:11 +0200 Subject: [PATCH 4/5] Do not write a header with output to stdout I could imagine still being able to force this, but the default should be changed in that case. --- piptools/scripts/compile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/piptools/scripts/compile.py b/piptools/scripts/compile.py index 30f7cfcfc..2833cc947 100755 --- a/piptools/scripts/compile.py +++ b/piptools/scripts/compile.py @@ -68,6 +68,8 @@ def cli(verbose, dry_run, pre, rebuild, find_links, index_url, extra_index_url, if len(src_files) == 1 and src_files[0] == '-': if not output_file: output_file = '-' + if output_file == '-': + header = False if len(src_files) > 1 and not output_file: raise click.BadParameter('--output-file is required if two or more input files are given.') From 51134d837a5bdb349d5c10f28358966244ef6897 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 12 May 2016 10:17:23 +0200 Subject: [PATCH 5/5] write_format_controls: do not emit only an empty line --- piptools/writer.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/piptools/writer.py b/piptools/writer.py index 6058d4a1c..78bab6fd8 100644 --- a/piptools/writer.py +++ b/piptools/writer.py @@ -52,11 +52,12 @@ def write_index_options(self): yield '' # extra line of whitespace def write_format_controls(self): - for nb in self.format_control.no_binary: - yield '--no-binary {}'.format(nb) - for ob in self.format_control.only_binary: - yield '--only-binary {}'.format(ob) - yield '' + if self.format_control.no_binary or self.format_control.only_binary: + for nb in self.format_control.no_binary: + yield '--no-binary {}'.format(nb) + for ob in self.format_control.only_binary: + yield '--only-binary {}'.format(ob) + yield '' def _iter_lines(self, results, reverse_dependencies, primary_packages): for line in self.write_header():