Skip to content

Commit

Permalink
Remove pyenv shims from PATH.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Sep 7, 2018
1 parent bbaa169 commit 2d84c19
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions build-support/bin/travis-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,31 @@ set -euo pipefail

cd "$(git rev-parse --show-toplevel)"

PYENV="$(pyenv which pyenv 2>/dev/null || true)"
PYENV_ROOT="$(cd "$(dirname "${PYENV}")/.." && pwd -P)"

function pyenv_path {
local -r pyenv_root="$(cd "$(dirname "$(which pyenv)")/.." && pwd -P)"
pyenv versions --bare | while read v; do
echo "${pyenv_root}/versions/${v}/bin"
"${PYENV}" versions --bare --skip-aliases | while read v; do
echo "${PYENV_ROOT}/versions/${v}/bin"
done
}

# TravisCI uses pyenv to provide some interpreters pre-installed for images. Unfortunately it places
# `~/.pyenv/shims` on the PATH and these shims are broken (see:
# https://github.com/travis-ci/travis-ci/issues/8363). We work around this by placing
# `~/.pyenv/versions/<version>/bin` dirs on the PATH ahead of the broken shims.
if which pyenv &>/dev/null; then
# removing shims from the PATH and adding `~/.pyenv/versions/<version>/bin`.
if [ -n "${PYENV}" ]; then
PYENV_PYTHONS="$(pyenv_path)"
PYENV_PATH="$(echo ${PYENV_PYTHONS} | tr ' ' ':')"

echo "Executing ./build-support/bin/ci.sh "$@" with ${PYENV_PATH} preprended to the PATH"
SHIMLESS_PATH="$(echo "${PATH}" | tr : '\n' | grep -v "${PYENV_ROOT}/shims")"
PATH="$(echo ${SHIMLESS_PATH} | tr ' ' ':')"

cat <<EOF
Executing ./build-support/bin/ci.sh "$@" with ${PYENV_PATH} preprended to the PATH
and ${PYENV_ROOT}/shims removed from the PATH.
EOF

export PATH="${PYENV_PATH}:${PATH}"
fi
Expand Down

0 comments on commit 2d84c19

Please sign in to comment.