certbot/tools/install_and_test.py
Brad Warren 353d092585
Remove -q/--quiet from pip invocations. (#6568)
While reducing noise in test output is valuable, this flag has made a couple aspects of Certbot's development difficult:

1. We test with different sets of dependencies and running pip in quiet mode removes all output about the packages being installed which has made reviewing changes to these tests more difficult.
2. When pip fails, it provides significantly less output about the failure in quiet mode than it does normally. The output is reduced so much that in the two times I've hit this issue in the last month, I was only able to see that installing package X failed rather than what the cause of that failure was which could be seen with `--quiet` removed.

Also, since running pip without `--quiet` is the tox default, I expect Python developers to be familiar with what they see here.
2018-12-06 16:02:16 -08:00

58 lines
1.9 KiB
Python
Executable file

#!/usr/bin/env python
# pip installs the requested packages in editable mode and runs unit tests on
# them. Each package is installed and tested in the order they are provided
# before the script moves on to the next package. If CERTBOT_NO_PIN is set not
# set to 1, packages are installed using pinned versions of all of our
# dependencies. See pip_install.py for more information on the versions pinned
# to.
from __future__ import print_function
import os
import sys
import tempfile
import shutil
import subprocess
import re
SKIP_PROJECTS_ON_WINDOWS = [
'certbot-apache', 'certbot-nginx', 'certbot-postfix', 'letshelp-certbot']
def call_with_print(command, cwd=None):
print(command)
subprocess.check_call(command, shell=True, cwd=cwd or os.getcwd())
def main(args):
if os.environ.get('CERTBOT_NO_PIN') == '1':
command = [sys.executable, '-m', 'pip', '-e']
else:
script_dir = os.path.dirname(os.path.abspath(__file__))
command = [sys.executable, os.path.join(script_dir, 'pip_install_editable.py')]
new_args = []
for arg in args:
if os.name == 'nt' and arg in SKIP_PROJECTS_ON_WINDOWS:
print((
'Info: currently {0} is not supported on Windows and will not be tested.'
.format(arg)))
else:
new_args.append(arg)
for requirement in new_args:
current_command = command[:]
current_command.append(requirement)
call_with_print(' '.join(current_command))
pkg = re.sub(r'\[\w+\]', '', requirement)
if pkg == '.':
pkg = 'certbot'
temp_cwd = tempfile.mkdtemp()
shutil.copy2("pytest.ini", temp_cwd)
try:
call_with_print(' '.join([
sys.executable, '-m', 'pytest', pkg.replace('-', '_')]), cwd=temp_cwd)
finally:
shutil.rmtree(temp_cwd)
if __name__ == '__main__':
main(sys.argv[1:])