2015-06-11 16:41:36 +02:00
|
|
|
#!/usr/bin/env python2
|
2015-06-10 18:35:19 +02:00
|
|
|
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
|
|
|
|
2016-01-04 07:12:39 +01:00
|
|
|
# Copyright 2015-2016 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
2015-06-10 18:35:19 +02:00
|
|
|
|
|
|
|
# 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/>.
|
|
|
|
|
2015-06-11 16:41:36 +02:00
|
|
|
# pylint: skip-file
|
2015-06-11 16:36:58 +02:00
|
|
|
|
2015-06-11 16:41:36 +02:00
|
|
|
"""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
|
2015-06-10 18:35:19 +02:00
|
|
|
|
2015-06-11 16:36:58 +02:00
|
|
|
import os
|
|
|
|
import sys
|
2015-06-10 18:35:19 +02:00
|
|
|
import subprocess
|
2015-06-11 16:41:36 +02:00
|
|
|
import urllib
|
2015-06-10 18:35:19 +02:00
|
|
|
|
2015-08-16 11:13:24 +02:00
|
|
|
try:
|
|
|
|
import _winreg as winreg
|
|
|
|
except ImportError:
|
|
|
|
winreg = None
|
2015-06-10 18:35:19 +02:00
|
|
|
|
2015-10-05 22:43:01 +02:00
|
|
|
TESTENV = os.environ['TESTENV']
|
|
|
|
TRAVIS_OS = os.environ.get('TRAVIS_OS_NAME', None)
|
2015-10-05 23:27:19 +02:00
|
|
|
INSTALL_PYQT = TESTENV in ('py34', 'py35', 'unittests-nodisp', 'vulture',
|
2015-10-05 22:43:01 +02:00
|
|
|
'pylint')
|
|
|
|
XVFB = TRAVIS_OS == 'linux' and TESTENV == 'py34'
|
2015-10-26 07:37:20 +01:00
|
|
|
pip_packages = ['tox']
|
2015-11-18 17:47:26 +01:00
|
|
|
if TESTENV in ['py34', 'py35'] and TRAVIS_OS == 'linux':
|
2015-10-26 07:37:20 +01:00
|
|
|
pip_packages.append('codecov')
|
|
|
|
|
2015-10-05 22:43:01 +02:00
|
|
|
|
2015-06-11 16:36:58 +02:00
|
|
|
def apt_get(args):
|
|
|
|
subprocess.check_call(['sudo', 'apt-get', '-y', '-q'] + args)
|
|
|
|
|
|
|
|
|
2015-06-12 13:49:50 +02:00
|
|
|
def brew(args, silent=False):
|
|
|
|
if silent:
|
|
|
|
with open(os.devnull, 'w') as f:
|
|
|
|
subprocess.check_call(['brew'] + args, stdout=f)
|
|
|
|
else:
|
2015-09-29 06:26:26 +02:00
|
|
|
subprocess.check_call(['brew'] + args + ['--verbose'])
|
2015-06-11 16:36:58 +02:00
|
|
|
|
|
|
|
|
2015-08-14 07:14:13 +02:00
|
|
|
def check_setup(executable):
|
2015-10-05 22:43:01 +02:00
|
|
|
if INSTALL_PYQT:
|
|
|
|
print("Checking setup...")
|
|
|
|
subprocess.check_call([executable, '-c', 'import PyQt5'])
|
|
|
|
subprocess.check_call([executable, '-c', 'import sip'])
|
2015-08-14 07:14:13 +02:00
|
|
|
|
|
|
|
|
2015-06-11 16:36:58 +02:00
|
|
|
if 'APPVEYOR' in os.environ:
|
|
|
|
print("Getting PyQt5...")
|
2015-11-18 08:28:35 +01:00
|
|
|
qt_version = '5.5.1'
|
|
|
|
pyqt_version = '5.5.1'
|
|
|
|
pyqt_url = ('http://www.qutebrowser.org/pyqt/'
|
|
|
|
'PyQt5-{}-gpl-Py3.4-Qt{}-x32.exe'.format(
|
|
|
|
pyqt_version, qt_version))
|
|
|
|
urllib.urlretrieve(pyqt_url, r'C:\install-PyQt5.exe')
|
2015-06-11 16:36:58 +02:00
|
|
|
|
2015-08-16 11:13:24 +02:00
|
|
|
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')
|
|
|
|
|
2015-06-11 16:36:58 +02:00
|
|
|
print("Installing PyQt5...")
|
|
|
|
subprocess.check_call([r'C:\install-PyQt5.exe', '/S'])
|
|
|
|
|
|
|
|
print("Installing tox...")
|
2015-10-27 17:54:23 +01:00
|
|
|
subprocess.check_call([r'C:\Python34\Scripts\pip', 'install', '-U'] +
|
2015-10-26 07:37:20 +01:00
|
|
|
pip_packages)
|
2015-06-11 16:36:58 +02:00
|
|
|
|
|
|
|
print("Linking Python...")
|
|
|
|
with open(r'C:\Windows\system32\python3.bat', 'w') as f:
|
|
|
|
f.write(r'@C:\Python34\python %*')
|
2015-08-14 07:14:13 +02:00
|
|
|
|
2015-08-15 19:19:03 +02:00
|
|
|
check_setup(r'C:\Python34\python')
|
2015-10-05 22:43:01 +02:00
|
|
|
elif TRAVIS_OS == 'linux':
|
2015-10-15 22:22:28 +02:00
|
|
|
print("travis_fold:start:ci_install")
|
2015-10-21 19:16:49 +02:00
|
|
|
print("Installing via pip...")
|
2015-10-26 07:37:20 +01:00
|
|
|
subprocess.check_call(['sudo', 'pip', 'install'] + pip_packages)
|
2015-06-11 16:36:58 +02:00
|
|
|
|
|
|
|
print("Installing packages...")
|
2015-10-06 06:20:31 +02:00
|
|
|
pkgs = []
|
|
|
|
|
2015-10-05 22:43:01 +02:00
|
|
|
if XVFB:
|
|
|
|
pkgs.append('xvfb')
|
|
|
|
if INSTALL_PYQT:
|
|
|
|
pkgs += ['python3-pyqt5', 'python3-pyqt5.qtwebkit']
|
2015-10-06 06:44:03 +02:00
|
|
|
if TESTENV == 'eslint':
|
2015-10-06 07:32:22 +02:00
|
|
|
pkgs += ['npm', 'nodejs', 'nodejs-legacy']
|
2015-10-06 06:20:31 +02:00
|
|
|
|
|
|
|
if pkgs:
|
|
|
|
print("apt-get update...")
|
|
|
|
apt_get(['update'])
|
|
|
|
print("apt-get install...")
|
|
|
|
apt_get(['install'] + pkgs)
|
2015-10-06 06:44:03 +02:00
|
|
|
|
|
|
|
if TESTENV == 'eslint':
|
|
|
|
subprocess.check_call(['sudo', 'npm', 'install', '-g', 'eslint'])
|
|
|
|
else:
|
|
|
|
check_setup('python3')
|
2015-10-15 22:22:28 +02:00
|
|
|
print("travis_fold:end:ci_install")
|
2015-10-05 22:43:01 +02:00
|
|
|
elif TRAVIS_OS == 'osx':
|
2015-11-27 17:49:27 +01:00
|
|
|
print("Disabling App Nap...")
|
|
|
|
subprocess.check_call(['defaults', 'write', 'NSGlobalDomain',
|
|
|
|
'NSAppSleepDisabled', '-bool', 'YES'])
|
2015-06-11 16:36:58 +02:00
|
|
|
print("brew update...")
|
2015-06-12 13:49:50 +02:00
|
|
|
brew(['update'], silent=True)
|
2015-06-11 16:36:58 +02:00
|
|
|
|
|
|
|
print("Installing packages...")
|
2015-10-20 18:14:25 +02:00
|
|
|
pkgs = ['python3']
|
2015-10-05 22:43:01 +02:00
|
|
|
if INSTALL_PYQT:
|
2015-10-20 18:14:25 +02:00
|
|
|
pkgs.append('pyqt5')
|
|
|
|
brew(['install'] + pkgs)
|
2015-06-10 18:35:19 +02:00
|
|
|
|
2015-10-26 07:34:56 +01:00
|
|
|
print("Installing tox/codecov...")
|
2015-10-26 07:37:20 +01:00
|
|
|
subprocess.check_call(['sudo', 'pip3', 'install'] + pip_packages)
|
2015-06-10 18:35:19 +02:00
|
|
|
|
2015-08-14 07:14:13 +02:00
|
|
|
check_setup('python3')
|
2015-06-11 16:36:58 +02:00
|
|
|
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)
|