mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Refactor travis script into a standalong python script
This commit is contained in:
parent
9c5815d9c0
commit
66cec4cabf
@ -18,11 +18,6 @@ matrix:
|
||||
- SWBASE=/Users/kovid SW=$SWBASE/sw PATH=$SW/bin:$SW/qt/bin:$SW/python/Python.framework/Versions/2.7/bin:$PWD/node_modules/.bin:$PATH CFLAGS=-I$SW/include LDFLAGS=-L$SW/lib QMAKE=$SW/qt/bin/qmake QT_PLUGIN_PATH=$SW/qt/plugins
|
||||
|
||||
before_install:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then python setup/ci-download.py https://download.calibre-ebook.com/travis/sw-linux.tar.xz J $HOME; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo mkdir -p $SWBASE && sudo chown $USER $SWBASE; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then python setup/ci-download.py https://download.calibre-ebook.com/travis/sw-osx.tar.bz2 j $SWBASE; fi
|
||||
- npm install --no-optional rapydscript-ng && echo $PATH && which rapydscript && rapydscript --version
|
||||
- python setup.py bootstrap --ephemeral
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export SSL_CERT_FILE=$PWD/resources/mozilla-ca-certs.pem; fi
|
||||
- python setup/unix-ci.py install
|
||||
|
||||
script: python setup.py test
|
||||
script: python setup/unix-ci.py test
|
||||
|
@ -1,29 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import sys, subprocess
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
url, compression, dest = sys.argv[-3:]
|
||||
|
||||
|
||||
def decompress(path):
|
||||
raise SystemExit(
|
||||
subprocess.Popen(['tar', 'x' + compression + 'f', path, '-C', dest]).wait()
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
for i in range(5):
|
||||
if i:
|
||||
print('Failed to download', url, 'retrying...'.format(url))
|
||||
else:
|
||||
print('Downloading', url, '...')
|
||||
with NamedTemporaryFile() as f:
|
||||
ret = subprocess.Popen(['curl', url], stdout=f).wait()
|
||||
if ret == 0:
|
||||
decompress(f.name)
|
||||
break
|
68
setup/unix-ci.py
Normal file
68
setup/unix-ci.py
Normal file
@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
_plat = sys.platform.lower()
|
||||
isosx = 'darwin' in _plat
|
||||
|
||||
|
||||
def run(*args):
|
||||
if len(args) == 1:
|
||||
args = shlex.split(args[0])
|
||||
print(' '.join(args))
|
||||
ret = subprocess.Popen(args).wait()
|
||||
if ret != 0:
|
||||
raise SystemExit(ret)
|
||||
|
||||
|
||||
def decompress(path, dest, compression):
|
||||
run('tar', 'x' + compression + 'f', path, '-C', dest)
|
||||
|
||||
|
||||
def download_and_decompress(url, dest, compression=None):
|
||||
if compression is None:
|
||||
compression = 'j' if url.endswith('.bz2') else 'J'
|
||||
for i in range(5):
|
||||
print('Downloading', url, '...')
|
||||
with NamedTemporaryFile() as f:
|
||||
ret = subprocess.Popen(['curl', '-fSsL', url], stdout=f).wait()
|
||||
if ret == 0:
|
||||
decompress(f.name, dest, compression)
|
||||
return
|
||||
time.sleep(1)
|
||||
raise SystemExit('Failed to download ' + url)
|
||||
|
||||
|
||||
def main():
|
||||
action = sys.argv[1]
|
||||
if action == 'install':
|
||||
if isosx:
|
||||
os.makedirs(os.environ['SWBASE'])
|
||||
run('sudo', 'chown', os.environ['USER'], os.environ['SWBASE'])
|
||||
download_and_decompress('https://download.calibre-ebook.com/travis/sw-osx.tar.bz2', os.environ['SWBASE'])
|
||||
else:
|
||||
download_and_decompress('https://download.calibre-ebook.com/travis/sw-linux.tar.xz', os.path.expanduser('~'))
|
||||
|
||||
run('npm install --no-optional rapydscript-ng')
|
||||
print(os.environ['PATH'])
|
||||
run('which rapydscript')
|
||||
run('rapydscript --version')
|
||||
|
||||
run(sys.executable, 'setup.py', 'bootstrap', '--ephemeral')
|
||||
elif action == 'test':
|
||||
if isosx:
|
||||
os.environ['SSL_CERT_FILE'] = os.path.abspath('resources/mozilla-ca-certs.pem')
|
||||
run(sys.executable, 'setup.py', 'test')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
x
Reference in New Issue
Block a user