forked from xolox/python-coloredlogs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtravis.sh
More file actions
executable file
·53 lines (49 loc) · 1.93 KB
/
travis.sh
File metadata and controls
executable file
·53 lines (49 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash -e
# Even though Travis CI supports Mac OS X [1] and several Python interpreters
# are installed out of the box, the Python environment cannot be configured in
# the Travis CI build configuration [2].
#
# As a workaround the build configuration file specifies a single Mac OS X job
# with `language: generic' that runs this script to create and activate a
# Python virtual environment.
#
# Recently the `virtualenv' command seems to no longer come pre-installed on
# the MacOS workers of Travis CI [3] so when this situation is detected we
# install it ourselves.
#
# [1] https://github.com/travis-ci/travis-ci/issues/216
# [2] https://github.com/travis-ci/travis-ci/issues/2312
# [3] https://travis-ci.org/xolox/python-humanfriendly/jobs/411396506
main () {
if [ "$TRAVIS_OS_NAME" = osx ]; then
local environment="$HOME/virtualenv/python2.7"
if [ -x "$environment/bin/python" ]; then
msg "Activating virtual environment ($environment) .."
source "$environment/bin/activate"
else
if ! which virtualenv &>/dev/null; then
msg "Installing 'virtualenv' in per-user site-packages .."
pip install --user virtualenv
msg "Figuring out 'bin' directory of per-user site-packages .."
LOCAL_BINARIES=$(python -c 'import os, site; print(os.path.join(site.USER_BASE, "bin"))')
msg "Prefixing '$LOCAL_BINARIES' to PATH .."
export PATH="$LOCAL_BINARIES:$PATH"
fi
msg "Creating virtual environment ($environment) .."
virtualenv "$environment"
msg "Activating virtual environment ($environment) .."
source "$environment/bin/activate"
msg "Checking if 'pip' executable works .."
if ! pip --version; then
msg "Bootstrapping working 'pip' installation using get-pip.py .."
curl -s https://bootstrap.pypa.io/get-pip.py | python -
fi
fi
fi
msg "Running command: $*"
eval "$@"
}
msg () {
echo "[travis.sh] $*" >&2
}
main "$@"