qutebrowser/scripts/ci_install.py

95 lines
3.0 KiB
Python
Raw Normal View History

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
PYQT_VERSION = '5.4.1'
2015-06-11 16:36:58 +02:00
def apt_get(args):
subprocess.check_call(['sudo', 'apt-get', '-y', '-q'] + args)
def brew(args):
subprocess.check_call(['brew'] + args)
if 'APPVEYOR' in os.environ:
print("Getting PyQt5...")
2015-06-11 16:41:36 +02:00
urllib.urlretrieve(
2015-06-11 16:36:58 +02:00
('http://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-{v}/'
'PyQt5-{v}-gpl-Py3.4-Qt{v}-x32.exe'.format(v=PYQT_VERSION)),
r'C:\install-PyQt5.exe')
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 %*')
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 xvfb'
apt_get(['install'] + pkgs.split())
elif os.environ.get('TRAVIS_OS_NAME', None) == 'osx':
print("brew update...")
brew(['update'])
print("Installing packages...")
brew(['install', 'python3', 'pyqt5'])
2015-06-10 18:35:19 +02:00
2015-06-11 16:36:58 +02:00
print("Installing tox...")
subprocess.check_call(['pip3.4', 'install', 'tox'])
2015-06-10 18:35:19 +02:00
2015-06-11 16:36:58 +02:00
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')
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)