From 6c42d36b186ba4a53fd4593135ad3f0a7ccf0246 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 9 May 2017 23:49:04 +0530 Subject: [PATCH] Move all env vars into ci script --- .travis.yml | 5 ----- setup/unix-ci.py | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 331195fc04..b9a340a091 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,12 +10,7 @@ matrix: include: - os: linux sudo: false - env: - - SW=$HOME/sw PATH=$SW/bin:$PATH CFLAGS=-I$SW/include LDFLAGS=-L$SW/lib LD_LIBRARY_PATH=$SW/qt/lib:$SW/lib PKG_CONFIG_PATH=$SW/lib/pkgconfig QMAKE=$SW/qt/bin/qmake QT_PLUGIN_PATH=$SW/qt/plugins - os: osx - env: - # On OS X the frameworks/dylibs contain hard coded paths, so we have to re-create the paths in the VM exactly - - 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: - python setup/unix-ci.py install diff --git a/setup/unix-ci.py b/setup/unix-ci.py index 708045eff6..0a0d604a88 100644 --- a/setup/unix-ci.py +++ b/setup/unix-ci.py @@ -15,6 +15,30 @@ _plat = sys.platform.lower() isosx = 'darwin' in _plat +def setenv(key, val): + os.environ[key] = os.path.expandvars(val) + + +if isosx: + # On OS X the frameworks/dylibs contain hard coded paths, so we have to re-create the paths in the VM exactly + setenv('SWBASE', '/Users/kovid') + setenv('SW', '$SWBASE/sw') + setenv('PATH', '$SW/bin:$SW/qt/bin:$SW/python/Python.framework/Versions/2.7/bin:$PWD/node_modules/.bin:$PATH') + setenv('CFLAGS', '-I$SW/include') + setenv('LDFLAGS', '-L$SW/lib') + setenv('QMAKE', '$SW/qt/bin/qmake') + setenv('QT_PLUGIN_PATH', '$SW/qt/plugins') +else: + setenv('SW', '$HOME/sw') + setenv('PATH', '$SW/bin:$PATH') + setenv('CFLAGS', '-I$SW/include') + setenv('LDFLAGS', '-L$SW/lib') + setenv('LD_LIBRARY_PATH', '$SW/qt/lib:$SW/lib') + setenv('PKG_CONFIG_PATH', '$SW/lib/pkgconfig') + setenv('QMAKE', '$SW/qt/bin/qmake') + setenv('QT_PLUGIN_PATH', '$SW/qt/plugins') + + def run(*args): if len(args) == 1: args = shlex.split(args[0]) @@ -49,9 +73,15 @@ def main(): 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']) + 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('~')) + 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']) @@ -61,7 +91,8 @@ def main(): run(python, 'setup.py', 'bootstrap', '--ephemeral') elif action == 'test': if isosx: - os.environ['SSL_CERT_FILE'] = os.path.abspath('resources/mozilla-ca-certs.pem') + os.environ['SSL_CERT_FILE' + ] = os.path.abspath('resources/mozilla-ca-certs.pem') run(python, 'setup.py', 'test')