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:
|
|
|
|
|
|
|
|
# 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/>.
|
|
|
|
|
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-08-14 06:59:36 +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-06-11 16:41:36 +02:00
|
|
|
urllib.urlretrieve(
|
2015-08-16 11:13:05 +02:00
|
|
|
'http://www.qutebrowser.org/pyqt/PyQt5-5.5-gpl-Py3.4-Qt5.5.0-x32.exe',
|
2015-08-16 15:40:26 +02:00
|
|
|
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...")
|
|
|
|
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 %*')
|
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-08 06:24:31 +02:00
|
|
|
print("sudo pip install tox/npm")
|
|
|
|
subprocess.check_call(['sudo', 'pip', 'install', 'tox'])
|
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-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
|
|
|
|
2015-10-19 17:29:01 +02:00
|
|
|
# https://github.com/Homebrew/homebrew/issues/45114
|
|
|
|
print("Patching PyQt formula...")
|
|
|
|
brew_path = subprocess.check_output(['brew', '--prefix']).strip()
|
|
|
|
pyqt_file = os.path.join(brew_path, 'Library', 'Formula', 'pyqt5.rb')
|
|
|
|
os.remove(pyqt_file)
|
|
|
|
urllib.urlretrieve(
|
|
|
|
'https://raw.githubusercontent.com/UniqMartin/homebrew/023a20a7959680952d166beca66d2995439d4540/Library/Formula/pyqt5.rb',
|
|
|
|
pyqt_file)
|
|
|
|
|
2015-06-11 16:36:58 +02:00
|
|
|
print("Installing packages...")
|
2015-10-19 17:29:01 +02:00
|
|
|
brew(['install', 'python3'])
|
2015-10-05 22:43:01 +02:00
|
|
|
if INSTALL_PYQT:
|
2015-10-19 17:29:01 +02:00
|
|
|
brew(['install', 'qt5', 'sip'])
|
|
|
|
brew(['install', 'pyqt5', '--build-from-source'])
|
2015-06-10 18:35:19 +02:00
|
|
|
|
2015-06-11 16:36:58 +02:00
|
|
|
print("Installing tox...")
|
2015-09-24 08:53:20 +02:00
|
|
|
subprocess.check_call(['sudo', 'pip3', 'install', 'tox'])
|
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)
|