mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Hide setup.py output unless using -v
This commit is contained in:
parent
547ba94900
commit
56d5076ee2
9 changed files with 17 additions and 88 deletions
|
@ -40,35 +40,9 @@ from pip.wheel import move_wheel_files, Wheel
|
|||
from pip._vendor.packaging.version import Version
|
||||
|
||||
|
||||
_FILTER_INSTALL_OUTPUT_REGEX = re.compile(r"""
|
||||
(?:^running\s.*) |
|
||||
(?:^writing\s.*) |
|
||||
(?:creating\s.*) |
|
||||
(?:[Cc]opying\s.*) |
|
||||
(?:^reading\s.*') |
|
||||
(?:^removing\s.*\.egg-info'\s\(and\severything\sunder\sit\)$) |
|
||||
(?:^byte-compiling) |
|
||||
(?:^SyntaxError:) |
|
||||
(?:^SyntaxWarning:) |
|
||||
(?:^\s*Skipping\simplicit\sfixer:) |
|
||||
(?:^\s*(warning:\s)?no\spreviously-included\s(files|directories)) |
|
||||
(?:^\s*warning:\sno\sfiles\sfound matching\s\'.*\') |
|
||||
(?:^\s*changing\smode\sof) |
|
||||
# Not sure what this warning is, but it seems harmless:
|
||||
(?:^warning:\smanifest_maker:\sstandard\sfile\s'-c'\snot found$)
|
||||
""", re.VERBOSE)
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _filter_install(line):
|
||||
level = logging.INFO
|
||||
if _FILTER_INSTALL_OUTPUT_REGEX.search(line.strip()):
|
||||
level = logging.DEBUG
|
||||
return (level, line)
|
||||
|
||||
|
||||
def _strip_extras(path):
|
||||
m = re.match(r'^(.+)(\[[^\]]+\])$', path)
|
||||
extras = None
|
||||
|
@ -423,7 +397,6 @@ class InstallRequirement(object):
|
|||
call_subprocess(
|
||||
egg_info_cmd + egg_base_option,
|
||||
cwd=cwd,
|
||||
filter_stdout=_filter_install,
|
||||
show_stdout=False,
|
||||
command_level=logging.DEBUG,
|
||||
command_desc='python setup.py egg_info')
|
||||
|
@ -881,7 +854,6 @@ exec(compile(
|
|||
call_subprocess(
|
||||
install_args + install_options,
|
||||
cwd=self.source_dir,
|
||||
filter_stdout=_filter_install,
|
||||
show_stdout=False,
|
||||
)
|
||||
|
||||
|
@ -983,14 +955,11 @@ exec(compile(
|
|||
['develop', '--no-deps'] +
|
||||
list(install_options),
|
||||
|
||||
cwd=cwd, filter_stdout=self._filter_install,
|
||||
cwd=cwd,
|
||||
show_stdout=False)
|
||||
|
||||
self.install_succeeded = True
|
||||
|
||||
def _filter_install(self, line):
|
||||
return _filter_install(line)
|
||||
|
||||
def check_if_exists(self):
|
||||
"""Find an installed distribution that satisfies or conflicts
|
||||
with this requirement, and set self.satisfied_by or
|
||||
|
|
|
@ -22,7 +22,6 @@ from pip.locations import (
|
|||
)
|
||||
from pip._vendor import pkg_resources
|
||||
from pip._vendor.six.moves import input
|
||||
from pip._vendor.six.moves import cStringIO
|
||||
from pip._vendor.six import PY2
|
||||
from pip._vendor.retrying import retry
|
||||
|
||||
|
@ -677,8 +676,7 @@ def remove_tracebacks(output):
|
|||
return re.sub(r"\*\*\* Error compiling (?:.*)", '', output)
|
||||
|
||||
|
||||
def call_subprocess(cmd, show_stdout=True,
|
||||
filter_stdout=None, cwd=None,
|
||||
def call_subprocess(cmd, show_stdout=True, cwd=None,
|
||||
raise_on_returncode=True,
|
||||
command_level=logging.DEBUG, command_desc=None,
|
||||
extra_environ=None):
|
||||
|
@ -708,26 +706,13 @@ def call_subprocess(cmd, show_stdout=True,
|
|||
raise
|
||||
all_output = []
|
||||
if stdout is not None:
|
||||
stdout = remove_tracebacks(console_to_str(proc.stdout.read()))
|
||||
stdout = cStringIO(stdout)
|
||||
all_output = stdout.readlines()
|
||||
if show_stdout:
|
||||
while 1:
|
||||
line = stdout.readline()
|
||||
if not line:
|
||||
break
|
||||
line = line.rstrip()
|
||||
all_output.append(line + '\n')
|
||||
if filter_stdout:
|
||||
level = filter_stdout(line)
|
||||
if isinstance(level, tuple):
|
||||
level, line = level
|
||||
logger.log(level, line)
|
||||
# if not logger.stdout_level_matches(level) and False:
|
||||
# # TODO(dstufft): Handle progress bar.
|
||||
# logger.show_progress()
|
||||
else:
|
||||
logger.debug(line)
|
||||
while True:
|
||||
line = console_to_str(proc.stdout.readline())
|
||||
if not line:
|
||||
break
|
||||
line = line.rstrip()
|
||||
all_output.append(line + '\n')
|
||||
logger.debug(line)
|
||||
if not all_output:
|
||||
returned_stdout, returned_stderr = proc.communicate()
|
||||
all_output = [returned_stdout or '']
|
||||
|
|
|
@ -106,9 +106,6 @@ class VersionControl(object):
|
|||
self.url = url
|
||||
super(VersionControl, self).__init__(*args, **kwargs)
|
||||
|
||||
def _filter(self, line):
|
||||
return (logging.DEBUG, line)
|
||||
|
||||
def _is_local_repository(self, repo):
|
||||
"""
|
||||
posix absolute paths start with os.path.sep,
|
||||
|
@ -301,8 +298,7 @@ class VersionControl(object):
|
|||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def run_command(self, cmd, show_stdout=True,
|
||||
filter_stdout=None, cwd=None,
|
||||
def run_command(self, cmd, show_stdout=True, cwd=None,
|
||||
raise_on_returncode=True,
|
||||
command_level=logging.DEBUG, command_desc=None,
|
||||
extra_environ=None):
|
||||
|
@ -313,7 +309,7 @@ class VersionControl(object):
|
|||
"""
|
||||
cmd = [self.name] + cmd
|
||||
try:
|
||||
return call_subprocess(cmd, show_stdout, filter_stdout, cwd,
|
||||
return call_subprocess(cmd, show_stdout, cwd,
|
||||
raise_on_returncode, command_level,
|
||||
command_desc, extra_environ)
|
||||
except OSError as e:
|
||||
|
|
|
@ -47,7 +47,7 @@ class Bazaar(VersionControl):
|
|||
rmtree(location)
|
||||
try:
|
||||
self.run_command(['export', location], cwd=temp_dir,
|
||||
filter_stdout=self._filter, show_stdout=False)
|
||||
show_stdout=False)
|
||||
finally:
|
||||
rmtree(temp_dir)
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class Git(VersionControl):
|
|||
location = location + '/'
|
||||
self.run_command(
|
||||
['checkout-index', '-a', '-f', '--prefix', location],
|
||||
filter_stdout=self._filter, show_stdout=False, cwd=temp_dir)
|
||||
show_stdout=False, cwd=temp_dir)
|
||||
finally:
|
||||
rmtree(temp_dir)
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@ class Mercurial(VersionControl):
|
|||
self.unpack(temp_dir)
|
||||
try:
|
||||
self.run_command(
|
||||
['archive', location],
|
||||
filter_stdout=self._filter, show_stdout=False, cwd=temp_dir)
|
||||
['archive', location], show_stdout=False, cwd=temp_dir)
|
||||
finally:
|
||||
rmtree(temp_dir)
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ class Subversion(VersionControl):
|
|||
rmtree(location)
|
||||
self.run_command(
|
||||
['export'] + rev_options + [url, location],
|
||||
filter_stdout=self._filter, show_stdout=False)
|
||||
show_stdout=False)
|
||||
|
||||
def switch(self, dest, url, rev_options):
|
||||
self.run_command(['switch'] + rev_options + [url, dest])
|
||||
|
|
|
@ -11,7 +11,7 @@ from pip.exceptions import (PreviousBuildDirError, InvalidWheelFilename,
|
|||
from pip.download import PipSession
|
||||
from pip.index import PackageFinder
|
||||
from pip.req import (InstallRequirement, RequirementSet, Requirements)
|
||||
from pip.req.req_install import parse_editable, _filter_install
|
||||
from pip.req.req_install import parse_editable
|
||||
from pip.utils import read_text_file
|
||||
from pip._vendor import pkg_resources
|
||||
from tests.lib import assert_raises_regexp
|
||||
|
@ -295,27 +295,6 @@ def test_parse_editable_local_extras(
|
|||
)
|
||||
|
||||
|
||||
def test_filter_install():
|
||||
from logging import DEBUG, INFO
|
||||
|
||||
assert _filter_install('running setup.py install') == (
|
||||
DEBUG, 'running setup.py install')
|
||||
assert _filter_install('writing foo.bar') == (
|
||||
DEBUG, 'writing foo.bar')
|
||||
assert _filter_install('creating foo.bar') == (
|
||||
DEBUG, 'creating foo.bar')
|
||||
assert _filter_install('copying foo.bar') == (
|
||||
DEBUG, 'copying foo.bar')
|
||||
assert _filter_install('SyntaxError: blah blah') == (
|
||||
DEBUG, 'SyntaxError: blah blah')
|
||||
assert _filter_install('This should not be filtered') == (
|
||||
INFO, 'This should not be filtered')
|
||||
assert _filter_install('foo bar') == (
|
||||
INFO, 'foo bar')
|
||||
assert _filter_install('I made a SyntaxError') == (
|
||||
INFO, 'I made a SyntaxError')
|
||||
|
||||
|
||||
def test_exclusive_environment_markers():
|
||||
"""Make sure RequirementSet accepts several excluding env markers"""
|
||||
eq26 = InstallRequirement.from_line(
|
||||
|
|
|
@ -457,6 +457,7 @@ class TestParseRequirements(object):
|
|||
|
||||
req.source_dir = os.curdir
|
||||
with patch.object(subprocess, 'Popen') as popen:
|
||||
popen.return_value.stdout.readline.return_value = ""
|
||||
try:
|
||||
req.install([])
|
||||
except:
|
||||
|
|
Loading…
Reference in a new issue