qutebrowser/scripts/dev/ci_install.py
Florian Bruhin 866017f9c1 Pass --verbose to Homebrew.
The homebrew progress bars cause Travis to bail out because the 4MB maximum log
size was reached. Ironically, that does not happen with --verbose.
2015-09-29 06:54:14 +02:00

120 lines
3.8 KiB
Python

#!/usr/bin/env python2
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# Copyright 2015 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
# This file is part of qutebrowser.
#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
# pylint: skip-file
"""Install needed prerequisites on the AppVeyor/Travis CI.
Note this file is written in python2 as this is more readily available on the
CI machines.
"""
from __future__ import print_function
import os
import sys
import subprocess
import urllib
try:
import _winreg as winreg
except ImportError:
winreg = None
def apt_get(args):
subprocess.check_call(['sudo', 'apt-get', '-y', '-q'] + args)
def brew(args, silent=False):
if silent:
with open(os.devnull, 'w') as f:
subprocess.check_call(['brew'] + args, stdout=f)
else:
subprocess.check_call(['brew'] + args + ['--verbose'])
def check_setup(executable):
print("Checking setup...")
subprocess.check_call([executable, '-c', 'import PyQt5'])
subprocess.check_call([executable, '-c', 'import sip'])
if 'APPVEYOR' in os.environ:
print("Getting PyQt5...")
urllib.urlretrieve(
'http://www.qutebrowser.org/pyqt/PyQt5-5.5-gpl-Py3.4-Qt5.5.0-x32.exe',
r'C:\install-PyQt5.exe')
print("Fixing registry...")
with winreg.OpenKey(winreg.HKEY_CURRENT_USER,
r'Software\Python\PythonCore\3.4', 0,
winreg.KEY_WRITE) as key:
winreg.SetValue(key, 'InstallPath', winreg.REG_SZ, r'C:\Python34')
print("Installing PyQt5...")
subprocess.check_call([r'C:\install-PyQt5.exe', '/S'])
print("Installing tox...")
subprocess.check_call([r'C:\Python34\Scripts\pip', 'install', 'tox'])
print("Linking Python...")
with open(r'C:\Windows\system32\python3.bat', 'w') as f:
f.write(r'@C:\Python34\python %*')
check_setup(r'C:\Python34\python')
elif os.environ.get('TRAVIS_OS_NAME', None) == 'linux':
print("apt-get update...")
apt_get(['update'])
print("Installing packages...")
pkgs = ['python3-pyqt5', 'python3-pyqt5.qtwebkit', 'python-tox',
'python3-dev', 'libpython3.4-dev', 'xvfb']
apt_get(['install'] + pkgs)
check_setup('python3')
elif os.environ.get('TRAVIS_OS_NAME', None) == 'osx':
print("brew update...")
brew(['update'], silent=True)
print("Installing packages...")
brew(['install', 'python3', 'pyqt5'])
print("Installing tox...")
subprocess.check_call(['sudo', 'pip3', 'install', 'tox'])
check_setup('python3')
print("Creating xvfb-run stub...")
with open('/usr/local/bin/xvfb-run', 'w') as f:
# This will break when xvfb-run is called differently in .travis.yml,
# but I can't be bothered to do it in a nicer way.
f.write('#!/bin/bash\n')
f.write('shift 2\n')
f.write('exec "$@"\n')
subprocess.check_call(['sudo', 'chmod', '755', '/usr/local/bin/xvfb-run'])
else:
def env(key):
return os.environ.get(key, None)
print("Unknown environment! (CI {}, APPVEYOR {}, TRAVIS {}, "
"TRAVIS_OS_NAME {})".format(env('CI'), env('APPVEYOR'),
env('TRAVIS'), env('TRAVIS_OS_NAME')),
file=sys.stderr)
sys.exit(1)