Skip to content

Commit 7b1e3ce

Browse files
author
y-p
committed
Merge pull request #3383 from y-p/travis_make_it_faster
Travis-CI: Allow network cache opt-in for whitelisted forks
2 parents 73f5f9a + 2ce26cd commit 7b1e3ce

File tree

5 files changed

+294
-121
lines changed

5 files changed

+294
-121
lines changed

.travis.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,29 @@ language: python
22

33
python:
44
- 2.6
5-
- 3.3
65

76
env:
87
global:
9-
- NOSE_ARGS="not slow" # need at least this so travis page will show env column
8+
- secure: "O04RU5QRKEDL/SrIWEsVe8O+1TxZqZQSa28Sd+Fz48NW/XddhefYyxzqcUXh\nk/NjWMqknJRQhApLolBianVpsE577OTllzlcyKn3nUL6hjOXcoszGaYray7S\niNGKGyO8xrtB/ZQDtmupz0ksK8sLoCTscdiGotFulczbx0zt+4g="
9+
- secure: "PUJ9nC1/v2vpFUtELSoSjI53OHCVXfFTb8+t5lIGIqHtjUBkhiJSNPfCv8Bx\ndsdrx30qP8KsSceYzaa/bog6p8YNU1iih23S0KbjucutvA0LNHBTNvnxmjBR\nSJfKd5FmwnXvizRyghYBzmQ3NmGO7ADw2DBwKOhgGMqCHZ8Tlc8="
10+
- secure: "IDcMrCCW+6pgJtsI3Q163OPc0iec1ogpitaqiRhHcrEBUCXZgVeclOeiZBlw\n/u+uGyW/O0NhHMaFXKB8BdDVwlQEEHv48syN6npS/A5+O6jriWKL4ozttOhE\npOlu+yLhHnEwx6wZVIHRTVn+t1GkOrjlBcjaQi+Z13G3XmDaSG8="
11+
- secure: "Zu9aj0dTGpvMqT/HqBGQgDYl/v5ubC7lFwfE8Fqb0N1UVXqbpjXnNH/7oal1\nUsIT7klO++LWm+LxsP/A1FWENTSgdYe99JQtNyauW+0x5YR1JTuDJ8atDgx9\nSq66CaVpS5t+ov7UVm2bKSUX+1S8+8zGbIDADrMxEzYEMF7WoGM="
12+
- secure: "AfIvLxvCxj22zrqg3ejGf/VePKT2AyGT9erYzlKpBS0H8yi5Pp1MfmJjhaR4\n51zBtzqHPHiIEY6ZdE06o9PioMWkXS+BqJNrxGSbt1ltxgOFrxW5zOpwiFGZ\nZOv1YeFkuPf8PEsWT7615mdydqTQT7B0pqUKK/d6aka4TQ/tg5Q="
13+
- secure: "EM4ySBUusReNu7H1QHXvjnP/J1QowvfpwEBmjysYxJuq7KcG8HhhlfpUF+Gh\nLBzLak9QBA67k4edhum3qtKuJR5cHuja3+zuV8xmx096B/m96liJFTrwZpea\n58op3W6ZULctEpQNgIkyae20bjxl4f99JhZRUlonoPfx/rBIMFc="
14+
- secure: "pgMYS/6MQqDGb58qdzTJesvAMmcJWTUEEM8gf9rVbfqfxceOL4Xpx8siR9B2\nC4U4MW1cHMPP3RFEb4Jy0uK49aHH10snwZY1S84YPPllpH5ZFXVdN68OayNj\nh4k5N/2hhaaQuJ6Uh8v8s783ye4oYTOW5RJUFqQu4QdG4IkTIMs="
15+
16+
- NOSE_ARGS="not slow" UPLOAD=true
1017

1118
matrix:
1219
include:
1320
- python: 2.7
14-
env: NOSE_ARGS="not network" LOCALE_OVERRIDE="zh_CN.GB18030"
21+
env: NOSE_ARGS="slow and not network" LOCALE_OVERRIDE="zh_CN.GB18030" FULL_DEPS=true UPLOAD=false
1522
- python: 2.7
16-
env: NOSE_ARGS="not slow" FULL_DEPS=true
23+
env: NOSE_ARGS="not slow" FULL_DEPS=true UPLOAD=true
1724
- python: 3.2
18-
env: NOSE_ARGS="not slow" FULL_DEPS=true
25+
env: NOSE_ARGS="not slow" FULL_DEPS=true UPLOAD=true
26+
- python: 3.3
27+
env: NOSE_ARGS="not slow" UPLOAD=true
1928

2029
# allow importing from site-packages,
2130
# so apt-get python-x works for system pythons
@@ -26,11 +35,14 @@ virtualenv:
2635
before_install:
2736
- echo "Waldo1"
2837
- echo $VIRTUAL_ENV
38+
- df
2939
- date
30-
- export PIP_ARGS=-q # comment this this to debug travis install issues
31-
- export APT_ARGS=-qq # comment this to debug travis install issues
40+
# - export PIP_ARGS=-q # comment this this to debug travis install issues
41+
# - export APT_ARGS=-qq # comment this to debug travis install issues
3242
# - set -x # enable this to see bash commands
33-
- source ci/before_install.sh # we need to source this to bring in the env
43+
- export ZIP_FLAGS=-q # comment this to debug travis install issues
44+
- source ci/envars.sh # we need to source this to bring in the envars
45+
- ci/before_install.sh
3446
- python -V
3547

3648
install:
@@ -43,3 +55,4 @@ script:
4355

4456
after_script:
4557
- ci/print_versions.py
58+
- ci/after_script.sh

ci/before_install.sh

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
#!/bin/bash
22

3+
# If envars.sh determined we're running in an authorized fork
4+
# and the user opted in to the network cache,and that cached versions
5+
# are available on the cache server, download and deploy the cached
6+
# files to the local filesystem
7+
38
echo "inside $0"
49

510
# overview
6-
if [ ${TRAVIS_PYTHON_VERSION} == "3.3" ]; then
7-
sudo add-apt-repository -y ppa:doko/ppa # we get the py3.3 debs from here
8-
fi
9-
1011
sudo apt-get update $APT_ARGS # run apt-get update for all versions
1112

12-
# # hack for broken 3.3 env
13-
# if [ x"$VIRTUAL_ENV" == x"" ]; then
14-
# VIRTUAL_ENV=~/virtualenv/python$TRAVIS_PYTHON_VERSION_with_system_site_packages;
15-
# fi
13+
if $PLEASE_TRAVIS_FASTER ; then
14+
echo "Faster? well... I'll try."
15+
16+
if $CACHE_FILE_AVAILABLE ; then
17+
echo retrieving "$CACHE_FILE_URL";
18+
19+
wget -q "$CACHE_FILE_URL" -O "/tmp/_$CYTHON_HASH.zip";
20+
unzip $ZIP_FLAGS /tmp/_"$CYTHON_HASH.zip" -d "$BUILD_CACHE_DIR";
21+
rm -f /tmp/_"$CYTHON_HASH.zip"
22+
# copy cythonized c files over
23+
cp -R "$BUILD_CACHE_DIR"/pandas/*.c pandas/
24+
cp -R "$BUILD_CACHE_DIR"/pandas/src/*.c pandas/src/
25+
fi;
26+
echo "VENV_FILE_AVAILABLE=$VENV_FILE_AVAILABLE"
27+
if $VENV_FILE_AVAILABLE ; then
28+
echo "getting venv"
29+
wget -q $VENV_FILE_URL -O "/tmp/venv.zip";
30+
sudo unzip $ZIP_FLAGS -o /tmp/venv.zip -d "/";
31+
sudo chown travis -R "$VIRTUAL_ENV"
32+
rm -f /tmp/_"$CYTHON_HASH.zip"
33+
fi;
34+
fi
1635

17-
# # we only recreate the virtualenv for 3.x
18-
# # since the "Detach bug" only affects python3
19-
# # and travis has numpy preinstalled on 2.x which is quicker
20-
# _VENV=$VIRTUAL_ENV # save it
21-
# if [ ${TRAVIS_PYTHON_VERSION:0:1} == "3" ] ; then
22-
# deactivate # pop out of any venv
23-
# sudo pip install virtualenv==1.8.4 --upgrade
24-
# sudo apt-get install $APT_ARGS python3.3 python3.3-dev
25-
# sudo rm -Rf $_VENV
26-
# virtualenv -p python$TRAVIS_PYTHON_VERSION $_VENV --system-site-packages;
27-
# source $_VENV/bin/activate
28-
# fi
36+
true # never fail because bad things happened here

ci/envars.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
# This must be sourced by .travis.yml, so any envars exported here will
4+
# be available to the rest of the build stages
5+
6+
# - computes a hash based on the cython files in the codebade
7+
# - retrieves the decrypted key if any for all whitelisted forks
8+
# - checks whether the user optd int to use the cache
9+
# - if so, check for availablity of cache files on the server, based on hash
10+
# - set envars to control what the following scripts do
11+
12+
# at most one of these will decrypt, so the end result is that $STORE_KEY
13+
# either holds a single key or does not
14+
export STORE_KEY="$STORE_KEY0""$STORE_KEY1""$STORE_KEY2""$STORE_KEY3""$STORE_KEY4"
15+
export STORE_KEY="$STORE_KEY""$STORE_KEY5""$STORE_KEY6""$STORE_KEY7"
16+
17+
export CYTHON_HASH=$(find pandas | grep -P '\.(pyx|pxd)$' | sort \
18+
| while read N; do echo $(tail -n+1 $N | md5sum ) ;done | md5sum| cut -d ' ' -f 1)
19+
20+
export CYTHON_HASH=$CYTHON_HASH-$TRAVIS_PYTHON_VERSION
21+
22+
# where the cache files live on the server
23+
export CACHE_FILE_URL="https://cache27-pypandas.rhcloud.com/static/$STORE_KEY/$CYTHON_HASH.zip"
24+
export VENV_FILE_URL="https://cache27-pypandas.rhcloud.com/static/$STORE_KEY/venv-$TRAVIS_PYTHON_VERSION.zip"
25+
export CACHE_FILE_STORE_URL="https://cache27-pypandas.rhcloud.com/store/$STORE_KEY"
26+
27+
echo "Hashing:"
28+
find pandas | grep -P '\.(pyx|pxd)$'
29+
echo "Key: $CYTHON_HASH"
30+
31+
export CACHE_FILE_AVAILABLE=false
32+
export VENV_FILE_AVAILABLE=false
33+
export PLEASE_TRAVIS_FASTER=false
34+
35+
# check whether the user opted in to use the cache via commit message
36+
if [ x"$(git log --format='%s' -n 1 | grep PLEASE_TRAVIS_FASTER | wc -l)" != x"0" ]; then
37+
export PLEASE_TRAVIS_FASTER=true
38+
fi;
39+
if [ x"$(git log --format='%s' -n 1 | grep PTF | wc -l)" != x"0" ]; then
40+
export PLEASE_TRAVIS_FASTER=true
41+
fi;
42+
43+
if $PLEASE_TRAVIS_FASTER; then
44+
45+
# check whether the files exists on the server
46+
curl -s -f -I "$CACHE_FILE_URL" # silent, don;t expose key
47+
if [ x"$?" == x"0" ] ; then
48+
export CACHE_FILE_AVAILABLE=true;
49+
fi
50+
51+
52+
curl -s -f -I "$VENV_FILE_URL" # silent, don;t expose key
53+
if [ x"$?" == x"0" ] ; then
54+
export VENV_FILE_AVAILABLE=true;
55+
fi
56+
57+
# the pandas build cache machinery needs this set, and the directory created
58+
export BUILD_CACHE_DIR="/tmp/build_cache"
59+
mkdir "$BUILD_CACHE_DIR"
60+
fi;
61+
62+
# debug
63+
echo "PLEASE_TRAVIS_FASTER=$PLEASE_TRAVIS_FASTER"
64+
echo "CACHE_FILE_AVAILABLE=$CACHE_FILE_AVAILABLE"
65+
echo "VENV_FILE_AVAILABLE=$VENV_FILE_AVAILABLE"
66+
67+
true

ci/install.sh

Lines changed: 105 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,128 @@
11
#!/bin/bash
22

3+
# There are 2 distinct pieces that get zipped and cached
4+
# - The venv site-packages dir including the installed dependencies
5+
# - The pandas build artifacts, using the build cache support via
6+
# scripts/use_build_cache.py
7+
#
8+
# if the user opted in to use the cache and we're on a whitelisted fork
9+
# - if the server doesn't hold a cached version of venv/pandas build,
10+
# do things the slow way, and put the results on the cache server
11+
# for the next time.
12+
# - if the cache files are available, instal some necessaries via apt
13+
# (no compiling needed), then directly goto script and collect 200$.
14+
#
15+
316
echo "inside $0"
4-
# Install Dependencies
17+
# Install Dependencie
18+
SITE_PKG_DIR=$VIRTUAL_ENV/lib/python$TRAVIS_PYTHON_VERSION/site-packages
19+
echo "Using SITE_PKG_DIR: $SITE_PKG_DIR"
520

621
# workaround for travis ignoring system_site_packages in travis.yml
722
rm -f $VIRTUAL_ENV/lib/python$TRAVIS_PYTHON_VERSION/no-global-site-packages.txt
823

9-
# Hard Deps
10-
pip install $PIP_ARGS --use-mirrors cython nose python-dateutil pytz
11-
12-
# try and get numpy as a binary deb
24+
if [ x"$LOCALE_OVERRIDE" != x"" ]; then
25+
# make sure the locale is available
26+
# probably useless, since you would need to relogin
27+
sudo locale-gen "$LOCALE_OVERRIDE"
28+
fi;
1329

14-
# numpy is preinstalled on 2.x
15-
# if [ ${TRAVIS_PYTHON_VERSION} == "2.7" ]; then
16-
# sudo apt-get $APT_ARGS install python-numpy;
17-
# fi
30+
#scipy is not included in the cached venv
31+
if [ x"$FULL_DEPS" == x"true" ] ; then
32+
# for pytables gets the lib as well
33+
sudo apt-get $APT_ARGS install libhdf5-serial-dev;
1834

19-
if [ ${TRAVIS_PYTHON_VERSION} == "3.2" ]; then
20-
sudo apt-get $APT_ARGS install python3-numpy;
21-
elif [ ${TRAVIS_PYTHON_VERSION} == "3.3" ]; then # should be >=3,3
22-
pip $PIP_ARGS install numpy==1.7.0;
23-
else
24-
pip $PIP_ARGS install numpy==1.6.1;
35+
if [ ${TRAVIS_PYTHON_VERSION} == "3.2" ]; then
36+
sudo apt-get $APT_ARGS install python3-scipy
37+
elif [ ${TRAVIS_PYTHON_VERSION} == "2.7" ]; then
38+
sudo apt-get $APT_ARGS install python-scipy
39+
fi
2540
fi
2641

27-
# Optional Deps
28-
if [ x"$FULL_DEPS" == x"true" ]; then
29-
echo "Installing FULL_DEPS"
30-
if [ ${TRAVIS_PYTHON_VERSION} == "2.7" ]; then
31-
sudo apt-get $APT_ARGS install python-scipy;
32-
fi
42+
# Everything installed inside this clause into site-packages
43+
# will get included in the cached venv downloaded from the net
44+
# in PTF mode
45+
if ( ! $VENV_FILE_AVAILABLE ); then
46+
echo "Running full monty"
47+
# Hard Deps
48+
pip install $PIP_ARGS nose python-dateutil pytz
49+
pip install $PIP_ARGS cython
3350

34-
if [ ${TRAVIS_PYTHON_VERSION} == "3.2" ]; then
35-
sudo apt-get $APT_ARGS install python3-scipy;
51+
if [ ${TRAVIS_PYTHON_VERSION} == "3.3" ]; then # should be >=3,3
52+
pip install $PIP_ARGS numpy==1.7.0
53+
elif [ ${TRAVIS_PYTHON_VERSION} == "3.2" ]; then
54+
# sudo apt-get $APT_ARGS install python3-numpy; # 1.6.2 or precise
55+
pip install $PIP_ARGS numpy==1.6.1
56+
else
57+
pip install $PIP_ARGS numpy==1.6.1
3658
fi
3759

38-
if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then
39-
sudo apt-get $APT_ARGS install libhdf5-serial-dev;
40-
pip install numexpr
41-
pip install tables
60+
# Optional Deps
61+
if [ x"$FULL_DEPS" == x"true" ]; then
62+
echo "Installing FULL_DEPS"
63+
pip install $PIP_ARGS cython
64+
65+
if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then
66+
# installed explicitly above, to get the library as well
67+
# sudo apt-get $APT_ARGS install libhdf5-serial-dev;
68+
pip install numexpr
69+
pip install tables
70+
pip install $PIP_ARGS xlwt
71+
fi
72+
73+
pip install $PIP_ARGS matplotlib
74+
pip install $PIP_ARGS openpyxl
75+
pip install $PIP_ARGS xlrd>=0.9.0
76+
pip install $PIP_ARGS 'http://downloads.sourceforge.net/project/pytseries/scikits.timeseries/0.91.3/scikits.timeseries-0.91.3.tar.gz?r='
77+
pip install $PIP_ARGS patsy
78+
79+
# fool statsmodels into thinking pandas was already installed
80+
# so it won't refuse to install itself. We want it in the zipped venv
81+
82+
mkdir $SITE_PKG_DIR/pandas
83+
touch $SITE_PKG_DIR/pandas/__init__.py
84+
echo "version='0.10.0-phony'" > $SITE_PKG_DIR/pandas/version.py
85+
pip install $PIP_ARGS git+git://github.com/statsmodels/statsmodels@c9062e43b8a5f7385537ca95#egg=statsmodels
86+
87+
rm -Rf $SITE_PKG_DIR/pandas # scrub phoney pandas
4288
fi
4389

44-
pip install $PIP_ARGS --use-mirrors openpyxl matplotlib;
45-
pip install $PIP_ARGS --use-mirrors xlrd xlwt;
46-
pip install $PIP_ARGS 'http://downloads.sourceforge.net/project/pytseries/scikits.timeseries/0.91.3/scikits.timeseries-0.91.3.tar.gz?r='
47-
fi
90+
# pack up the venv and cache it
91+
if [ x"$STORE_KEY" != x"" ] && $UPLOAD; then
92+
VENV_FNAME="venv-$TRAVIS_PYTHON_VERSION.zip"
4893

49-
if [ x"$VBENCH" == x"true" ]; then
50-
if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then
51-
sudo apt-get $APT_ARGS install libhdf5-serial-dev;
52-
pip install numexpr
53-
pip install tables
94+
zip $ZIP_FLAGS -r "$HOME/$VENV_FNAME" $SITE_PKG_DIR/
95+
ls -l "$HOME/$VENV_FNAME"
96+
echo "posting venv"
97+
# silent, don't expose key
98+
curl -s --form upload=@"$HOME/$VENV_FNAME" "$CACHE_FILE_STORE_URL/$VENV_FNAME"
5499
fi
55-
pip $PIP_ARGS install sqlalchemy git+git://github.com/pydata/vbench.git;
56-
fi
57100

58-
#build and install pandas
59-
python setup.py build_ext install
60-
61-
#HACK: pandas is a statsmodels dependency
62-
# so we need to install it after pandas
63-
if [ x"$FULL_DEPS" == x"true" ]; then
64-
pip install patsy
65-
# pick recent 0.5dev dec/2012
66-
pip install git+git://github.com/statsmodels/statsmodels@c9062e43b8a5f7385537ca95#egg=statsmodels
67101
fi;
68102

69-
# make sure the desired locale is generated
70-
if [ x"$LOCALE_OVERRIDE" != x"" ]; then
71-
# piggyback this build for plotting tests. oh boy.
72-
pip install $PIP_ARGS --use-mirrors matplotlib;
103+
#build and install pandas
104+
if [ x"$BUILD_CACHE_DIR" != x"" ]; then
105+
scripts/use_build_cache.py -d
106+
python setup.py install;
107+
else
108+
python setup.py build_ext install
109+
fi
73110

74-
sudo locale-gen "$LOCALE_OVERRIDE"
111+
# package pandas build artifacts and send them home
112+
# that's everything the build cache (scripts/use_build_cache.py)
113+
# stored during the build (.so, pyx->.c and 2to3)
114+
if (! $CACHE_FILE_AVAILABLE) ; then
115+
echo "Posting artifacts"
116+
strip "$BUILD_CACHE_DIR/*" &> /dev/null
117+
echo "$BUILD_CACHE_DIR"
118+
cd "$BUILD_CACHE_DIR"/
119+
zip -r $ZIP_FLAGS "$HOME/$CYTHON_HASH".zip *
120+
cd "$TRAVIS_BUILD_DIR"
121+
pwd
122+
zip "$HOME/$CYTHON_HASH".zip $(find pandas | grep -P '\.(pyx|pxd)$' | sed -r 's/.(pyx|pxd)$/.c/')
123+
124+
# silent, don't expose key
125+
curl -s --form upload=@"$HOME/$CYTHON_HASH".zip "$CACHE_FILE_STORE_URL/$CYTHON_HASH.zip"
75126
fi
127+
128+
true

0 commit comments

Comments
 (0)