Skip to content

Commit c1d21e3

Browse files
committed
install: Less output on success; once on failure
This fixes 2 aspects of `pip install output`: 1. When `pip install` succeeds, it's still printing a lot of output from the package's setup.py. The average consumer of Python packages, when they do `pip install lxml`, probably doesn't care to see a bunch of output about: - copying files to a `build` directory - installing and running Cython - compiling C code This is noise to most when the `pip install` succeeds. It's useful to see all the output when the install fails, which is the subject of pypa#2 below. On success, the output is now very clean with 5 short lines: $ pip install lxml Collecting lxml Using cached lxml-3.4.2.tar.gz Installing collected packages: lxml Running setup.py install for lxml Successfully installed lxml-3.4.2 2. When there's an error from `pip install`, it's annoying to have to scroll through 2 different copies of the failure output (especially when one is filtered and one is unfiltered so one might have stuff that the other doesn't). This makes it not print the filtered version so that there is just the unfiltered version and nothing is repeated. $ pip install ~/dev/git-repos/lxml Processing /Users/marca/dev/git-repos/lxml Installing collected packages: lxml Running setup.py install for lxml Complete output from command ... cc -c /var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/xmlCheckVersion4tBaVV.c -o var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/xmlCheckVersion4tBaVV.o /var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/xmlCheckVersion4tBaVV.c:1:10: fatal error: 'libxml/xmlversion.h' file not found #include "libxml/xmlversion.h" ^ 1 error generated. ---------------------------------------- Command "/Users/marca/python/virtualenvs/pip/bin/python -c ... None of the lines above are repeated.
1 parent c357632 commit c1d21e3

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

pip/utils/__init__.py

+19-17
Original file line numberDiff line numberDiff line change
@@ -727,23 +727,25 @@ def call_subprocess(cmd, show_stdout=True,
727727
if stdout is not None:
728728
stdout = remove_tracebacks(console_to_str(proc.stdout.read()))
729729
stdout = cStringIO(stdout)
730-
while 1:
731-
line = stdout.readline()
732-
if not line:
733-
break
734-
line = line.rstrip()
735-
all_output.append(line + '\n')
736-
if filter_stdout:
737-
level = filter_stdout(line)
738-
if isinstance(level, tuple):
739-
level, line = level
740-
logger.log(level, line)
741-
# if not logger.stdout_level_matches(level) and False:
742-
# # TODO(dstufft): Handle progress bar.
743-
# logger.show_progress()
744-
else:
745-
logger.debug(line)
746-
else:
730+
all_output = stdout.readlines()
731+
if show_stdout:
732+
while 1:
733+
line = stdout.readline()
734+
if not line:
735+
break
736+
line = line.rstrip()
737+
all_output.append(line + '\n')
738+
if filter_stdout:
739+
level = filter_stdout(line)
740+
if isinstance(level, tuple):
741+
level, line = level
742+
logger.log(level, line)
743+
# if not logger.stdout_level_matches(level) and False:
744+
# # TODO(dstufft): Handle progress bar.
745+
# logger.show_progress()
746+
else:
747+
logger.debug(line)
748+
if not all_output:
747749
returned_stdout, returned_stderr = proc.communicate()
748750
all_output = [returned_stdout or '']
749751
proc.wait()

tests/functional/test_install.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ def test_install_global_option_using_editable(script, tmpdir):
454454
'install', '--global-option=--version', '-e',
455455
'%[email protected]#egg=anyjson' % local_checkout(url, tmpdir.join("cache"))
456456
)
457-
assert '0.2.5\n' in result.stdout
457+
assert 'Successfully installed anyjson' in result.stdout
458458

459459

460460
@pytest.mark.network

0 commit comments

Comments
 (0)