From bef24445eac7919955d4a7976957d23699107076 Mon Sep 17 00:00:00 2001 From: Alex Cameron Date: Thu, 23 Mar 2023 16:27:38 +1100 Subject: [PATCH 1/3] _subprocess: Fix `pip install` log window not showing --- pip_audit/_subprocess.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pip_audit/_subprocess.py b/pip_audit/_subprocess.py index 070db782..4f3291f0 100644 --- a/pip_audit/_subprocess.py +++ b/pip_audit/_subprocess.py @@ -45,7 +45,6 @@ def run(args: Sequence[str], *, log_stdout: bool = False, state: AuditState = Au terminated = False stdout = b"" - stderr = b"" # NOTE: We use `poll()` to control this loop instead of the `read()` call # to prevent deadlocks. Similarly, `read(size)` will return an empty bytes @@ -54,11 +53,11 @@ def run(args: Sequence[str], *, log_stdout: bool = False, state: AuditState = Au terminated = process.poll() is not None # NOTE(ww): Buffer size chosen arbitrarily here and below. stdout += process.stdout.read(4096) # type: ignore - stderr += process.stderr.read(4096) # type: ignore state.update_state( f"Running {pretty_args}", stdout.decode(errors="replace") if log_stdout else None ) + stderr = process.stderr.read() # type: ignore if process.returncode != 0: raise CalledProcessError( f"{pretty_args} exited with {process.returncode}", From 999537d0208befb32bec1145e9e0180e064aa526 Mon Sep 17 00:00:00 2001 From: Alex Cameron Date: Thu, 23 Mar 2023 16:36:21 +1100 Subject: [PATCH 2/3] _subprocess: Add comment explaining --- pip_audit/_subprocess.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pip_audit/_subprocess.py b/pip_audit/_subprocess.py index 4f3291f0..f08f6456 100644 --- a/pip_audit/_subprocess.py +++ b/pip_audit/_subprocess.py @@ -57,6 +57,9 @@ def run(args: Sequence[str], *, log_stdout: bool = False, state: AuditState = Au f"Running {pretty_args}", stdout.decode(errors="replace") if log_stdout else None ) + # NOTE(alex): For reasons I'm unsure about, reading the stderr stream in + # real time seems to interfere with stdout and cause us to read nothing. + # Let's wait until the process is terminated before reading stderr. stderr = process.stderr.read() # type: ignore if process.returncode != 0: raise CalledProcessError( From e7863f052066142443c1a0f693d10aedd40c7885 Mon Sep 17 00:00:00 2001 From: Alex Cameron Date: Thu, 23 Mar 2023 16:39:09 +1100 Subject: [PATCH 3/3] CHANGELOG: Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbdb5698..a73a44a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,10 @@ All versions prior to 0.0.9 are untracked. * Fixed a crash on Windows caused by multiple open file handles to input requirements ([#551](https://github.com/pypa/pip-audit/pull/551)) +* Fixed an issue where the log window that we use to display `pip-audit`'s + dependency resolution progress was not showing anything + ([#567](https://github.com/pypa/pip-audit/pull/567)) + ## [2.5.0] ### Changed