Skip to content

Commit

Permalink
Ensure Pip logs to stderr. (#1268)
Browse files Browse the repository at this point in the history
Fixes #1267
  • Loading branch information
jsirois authored Mar 12, 2021
1 parent 40bff7f commit 1111cae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion pex/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,18 @@ def _spawn_pip_isolated(
from pex.pex import PEX

pip = PEX(pex=self._pip_pex_path, interpreter=python_interpreter)

# Pip has no discernable stdout / stderr discipline with its logging. Pex guarantees
# stdout will only contain useable (parseable) data and all logging will go to stderr.
# To uphold the Pex standard, force Pip to comply by re-directing stdout to stderr.
#
# See:
# + https:/pantsbuild/pex/issues/1267
# + https:/pypa/pip/issues/9420
stdout = popen_kwargs.pop("stdout", sys.stderr.fileno())

return pip.cmdline(command), pip.run(
args=command, env=env, blocking=False, **popen_kwargs
args=command, env=env, blocking=False, stdout=stdout, **popen_kwargs
)

def _spawn_pip_isolated_job(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2876,7 +2876,7 @@ def test_seed(
):
# type: (...) -> None
pex_file, args = isort_pex_args
results = run_pex_command(args=args + mode_args + ["--seed"], quiet=True)
results = run_pex_command(args=args + mode_args + ["--seed"])
results.assert_success()

# Setting posix=False works around this issue under pypy: https://bugs.python.org/issue1170.
Expand Down

0 comments on commit 1111cae

Please sign in to comment.