Skip to content

Commit 88bcb26

Browse files
authored
Merge pull request pypa#6154 from cjerdonek/show-stdout-default
Change call_subprocess()'s show_stdout default from True to False
2 parents 133b30a + 1b6ea51 commit 88bcb26

File tree

6 files changed

+24
-17
lines changed

6 files changed

+24
-17
lines changed

src/pip/_internal/build_env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def install_requirements(
192192
args.append('--')
193193
args.extend(requirements)
194194
with open_spinner(message) as spinner:
195-
call_subprocess(args, show_stdout=False, spinner=spinner)
195+
call_subprocess(args, spinner=spinner)
196196

197197

198198
class NoOpBuildEnvironment(BuildEnvironment):

src/pip/_internal/download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ def _copy_dist_from_dir(link_path, location):
795795
logger.info('Running setup.py sdist for %s', link_path)
796796

797797
with indent_log():
798-
call_subprocess(sdist_args, cwd=link_path, show_stdout=False)
798+
call_subprocess(sdist_args, cwd=link_path)
799799

800800
# unpack sdist into `location`
801801
sdist = os.path.join(location, os.listdir(location)[0])

src/pip/_internal/req/req_install.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@ def runner(cmd, cwd=None, extra_environ=None):
507507
cmd,
508508
cwd=cwd,
509509
extra_environ=extra_environ,
510-
show_stdout=False,
511510
spinner=spinner
512511
)
513512
self.spin_message = ""
@@ -605,7 +604,6 @@ def run_egg_info(self):
605604
call_subprocess(
606605
egg_info_cmd + egg_base_option,
607606
cwd=self.setup_py_dir,
608-
show_stdout=False,
609607
command_desc='python setup.py egg_info')
610608

611609
@property
@@ -757,7 +755,6 @@ def install_editable(
757755
list(install_options),
758756

759757
cwd=self.setup_py_dir,
760-
show_stdout=False,
761758
)
762759

763760
self.install_succeeded = True
@@ -941,7 +938,6 @@ def install(
941938
call_subprocess(
942939
install_args + install_options,
943940
cwd=self.setup_py_dir,
944-
show_stdout=False,
945941
spinner=spinner,
946942
)
947943

src/pip/_internal/utils/misc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ def unpack_file(
650650

651651
def call_subprocess(
652652
cmd, # type: List[str]
653-
show_stdout=True, # type: bool
653+
show_stdout=False, # type: bool
654654
cwd=None, # type: Optional[str]
655655
on_returncode='raise', # type: str
656656
extra_ok_returncodes=None, # type: Optional[Iterable[int]]
@@ -677,13 +677,13 @@ def call_subprocess(
677677
#
678678
# The obvious thing that affects output is the show_stdout=
679679
# kwarg. show_stdout=True means, let the subprocess write directly to our
680-
# stdout. Even though it is nominally the default, it is almost never used
680+
# stdout. It is almost never used
681681
# inside pip (and should not be used in new code without a very good
682682
# reason); as of 2016-02-22 it is only used in a few places inside the VCS
683683
# wrapper code. Ideally we should get rid of it entirely, because it
684684
# creates a lot of complexity here for a rarely used feature.
685685
#
686-
# Most places in pip set show_stdout=False. What this means is:
686+
# Most places in pip use show_stdout=False. What this means is:
687687
# - We connect the child stdout to a pipe, which we read.
688688
# - By default, we hide the output but show a spinner -- unless the
689689
# subprocess exits with an error, in which case we show the output.

src/pip/_internal/wheel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ def _build_one_legacy(self, req, tempd, python_tag=None):
953953

954954
try:
955955
output = call_subprocess(wheel_args, cwd=req.setup_py_dir,
956-
show_stdout=False, spinner=spinner)
956+
spinner=spinner)
957957
except Exception:
958958
spinner.finish("error")
959959
logger.error('Failed building wheel for %s', req.name)
@@ -974,7 +974,7 @@ def _clean_one(self, req):
974974
logger.info('Running setup.py clean for %s', req.name)
975975
clean_args = base_args + ['clean', '--all']
976976
try:
977-
call_subprocess(clean_args, cwd=req.source_dir, show_stdout=False)
977+
call_subprocess(clean_args, cwd=req.source_dir)
978978
return True
979979
except Exception:
980980
logger.error('Failed cleaning build dir for %s', req.name)

tests/unit/test_utils.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,16 +724,27 @@ def test_get_prog(self, monkeypatch, argv, executable, expected):
724724
assert get_prog() == expected
725725

726726

727-
def test_call_subprocess_works_okay_when_just_given_nothing():
728-
try:
729-
call_subprocess([sys.executable, '-c', 'print("Hello")'])
730-
except Exception:
731-
assert False, "Expected subprocess call to succeed"
727+
def test_call_subprocess_works__no_keyword_arguments():
728+
result = call_subprocess(
729+
[sys.executable, '-c', 'print("Hello")'],
730+
)
731+
assert result.rstrip() == 'Hello'
732+
733+
734+
def test_call_subprocess_works__show_stdout_true():
735+
result = call_subprocess(
736+
[sys.executable, '-c', 'print("Hello")'],
737+
show_stdout=True,
738+
)
739+
assert result is None
732740

733741

734742
def test_call_subprocess_closes_stdin():
735743
with pytest.raises(InstallationError):
736-
call_subprocess([sys.executable, '-c', 'input()'])
744+
call_subprocess(
745+
[sys.executable, '-c', 'input()'],
746+
show_stdout=True,
747+
)
737748

738749

739750
@pytest.mark.parametrize('args, expected', [

0 commit comments

Comments
 (0)