Skip to content

Commit 5f067bf

Browse files
committed
Copy MacOS workarounds from 'humanfriendly' package
1 parent 94559e1 commit 5f067bf

File tree

1 file changed

+41
-20
lines changed

1 file changed

+41
-20
lines changed

scripts/install-on-travis.sh

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

3-
# On Mac OS X workers we are responsible for creating the Python virtual
4-
# environment, because we set `language: generic' in the Travis CI build
5-
# configuration file (to bypass the lack of Python runtime support).
6-
if [ "$TRAVIS_OS_NAME" = osx ]; then
7-
VIRTUAL_ENV="$HOME/virtualenv/python2.7"
8-
if [ ! -x "$VIRTUAL_ENV/bin/python" ]; then
9-
if ! which virtualenv &>/dev/null; then
10-
# Install `virtualenv' in ~/.local (doesn't require `sudo' privileges).
11-
pip install --user virtualenv
12-
# Make sure ~/.local/bin is in the $PATH.
13-
LOCAL_BINARIES=$(python -c 'import os, site; print(os.path.join(site.USER_BASE, "bin"))')
14-
export PATH="$PATH:$LOCAL_BINARIES"
3+
main () {
4+
5+
# On Mac OS X workers we are responsible for creating the Python virtual
6+
# environment, because we set `language: generic' in the Travis CI build
7+
# configuration file (to bypass the lack of Python runtime support).
8+
if [ "$TRAVIS_OS_NAME" = osx ]; then
9+
local environment="$HOME/virtualenv/python2.7"
10+
if [ -x "$environment/bin/python" ]; then
11+
msg "Activating virtual environment ($environment) .."
12+
source "$environment/bin/activate"
13+
else
14+
if ! which virtualenv &>/dev/null; then
15+
msg "Installing 'virtualenv' in per-user site-packages .."
16+
pip install --user virtualenv
17+
msg "Figuring out 'bin' directory of per-user site-packages .."
18+
LOCAL_BINARIES=$(python -c 'import os, site; print(os.path.join(site.USER_BASE, "bin"))')
19+
msg "Prefixing '$LOCAL_BINARIES' to PATH .."
20+
export PATH="$LOCAL_BINARIES:$PATH"
21+
fi
22+
msg "Creating virtual environment ($environment) .."
23+
virtualenv "$environment"
24+
msg "Activating virtual environment ($environment) .."
25+
source "$environment/bin/activate"
26+
msg "Checking if 'pip' executable works .."
27+
if ! pip --version; then
28+
msg "Bootstrapping working 'pip' installation using get-pip.py .."
29+
curl -s https://bootstrap.pypa.io/get-pip.py | python -
30+
fi
1531
fi
16-
virtualenv "$VIRTUAL_ENV"
1732
fi
18-
source "$VIRTUAL_ENV/bin/activate"
19-
fi
2033

21-
# Install the required Python packages.
22-
pip install --requirement=requirements-travis.txt
34+
# Install the required Python packages.
35+
pip install --requirement=requirements-travis.txt
36+
37+
# Install the project itself, making sure that potential character encoding
38+
# and/or decoding errors in the setup script are caught as soon as possible.
39+
LC_ALL=C pip install .
40+
41+
}
42+
43+
msg () {
44+
echo "[install-on-travis.sh] $*" >&2
45+
}
2346

24-
# Install the project itself, making sure that potential character encoding
25-
# and/or decoding errors in the setup script are caught as soon as possible.
26-
LC_ALL=C pip install .
47+
main "$@"

0 commit comments

Comments
 (0)