From 651f5da36a3b06dda6742dee9e7778dd0ff93b46 Mon Sep 17 00:00:00 2001 From: John Sandall Date: Sat, 20 Mar 2021 20:11:45 +0000 Subject: [PATCH 1/3] Stream verbose output from pip-compile --- pipcompilemulti/environment.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pipcompilemulti/environment.py b/pipcompilemulti/environment.py index acbe010..c649841 100644 --- a/pipcompilemulti/environment.py +++ b/pipcompilemulti/environment.py @@ -63,11 +63,22 @@ def create_lockfile(self): if sink_out_path and sink_out_path != self.outfile: original_in_file = self._read_infile() self._inject_sink() + + verbose = True process = subprocess.Popen( self.pin_command, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + stderr=None if verbose else subprocess.PIPE, ) + if verbose: + while True: + output = process.stdout.readline() + if output == b'' and process.poll() is not None: + break + if output: + print(output.strip()) + rc = process.poll() + stdout, stderr = process.communicate() finally: if original_in_file: From 481faff922a3f63d5b3d26131451ba5f2687f46b Mon Sep 17 00:00:00 2001 From: John Sandall Date: Sat, 20 Mar 2021 20:29:50 +0000 Subject: [PATCH 2/3] Consider assigning process.poll() to stdout --- pipcompilemulti/environment.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pipcompilemulti/environment.py b/pipcompilemulti/environment.py index c649841..2d8c4eb 100644 --- a/pipcompilemulti/environment.py +++ b/pipcompilemulti/environment.py @@ -77,7 +77,8 @@ def create_lockfile(self): break if output: print(output.strip()) - rc = process.poll() + # TODO: Decide what to do about this + # stdout, stderr = process.poll(), None stdout, stderr = process.communicate() finally: From d524ee84e0e253904c156c453002945a260caf17 Mon Sep 17 00:00:00 2001 From: John Sandall <2884159+john-sandall@users.noreply.github.com> Date: Sat, 20 Mar 2021 22:43:15 +0000 Subject: [PATCH 3/3] Just set stdout=None if verbose is True --- pipcompilemulti/environment.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/pipcompilemulti/environment.py b/pipcompilemulti/environment.py index 2d8c4eb..1496b5d 100644 --- a/pipcompilemulti/environment.py +++ b/pipcompilemulti/environment.py @@ -67,19 +67,9 @@ def create_lockfile(self): verbose = True process = subprocess.Popen( self.pin_command, - stdout=subprocess.PIPE, + stdout=None if verbose else subprocess.PIPE, stderr=None if verbose else subprocess.PIPE, ) - if verbose: - while True: - output = process.stdout.readline() - if output == b'' and process.poll() is not None: - break - if output: - print(output.strip()) - # TODO: Decide what to do about this - # stdout, stderr = process.poll(), None - stdout, stderr = process.communicate() finally: if original_in_file: